Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Text Editor in C (Univ assignment)

Name: Anonymous 2011-01-12 4:39

So hey guys :3

I've got this paper that I have to do, and I need to make a text editor. Please assist me and offer tips as I'm currently trying to think this thing through before I get to the actual coding.

•I'm going to be saving everything in a 20x80 matrix, or a string[1601] so I can use every individual character written, is this correct? (I'm declaring the maximum number of chars on screen to 20 lines with 80 columns, fuck anything more, this is a first semester assignment, hence the matric and string lengths)

•How on earth does I shot cursor? I mean, I'm supposed to have the cursor move up and down so the user can write at different parts of his text. Now, I can think of a way to shove the characters of the string "left" or "right" by making an individual proc, but how would one actually go and make the cursor move? Any ideas would be welcome.

•I'm unfamiliar with C extracting anything in .txt format, derp, will google later. Everything we've worked so far is hurrr command prompt calculations.

•In general, any ideas from you experienced coders, feedback, tips, anything, will be bloody welcome. Although I've worked with BYOND and Space Station 13 (/tg/station13) before so I'm familiar with reading Spaghetti code or structured coding using and calling procs() (oh hey I can probably go look at the code there and gather ideas and code formations) I think I'm at a stage where, being confused, I don't even know what QUESTIONS to ask to myself before I start solving the problem.

Just for the record, im studying CS at AUTH university, greece.

Name: Anonymous 2011-01-12 5:18

... but if you don't here's my advice.

static not-growable editor = FAGGOT SHIT.

use a linked list of lines.  Each line can be a static buffer with a max of 256 or something reasonable.

That way line insertion / deletion will be fast as it's just a simple update of the list.   Insertion/deletion of characters will need an inefficient for loop pushing things forward or back one, but as lines are relevativly short it's not a problem.

how would one actually go and make the cursor move? .. wtf...IHBTC. You would require at the very least cursorx and cursory variables to store it's position on the screen.  Then some sort of viewportx variable that will store the offset of the top visible line to the top of the file.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List