Page 1 of 1

fopen issues

Posted: Fri Jul 09, 2004 11:38 pm
by St8ic
So I opened a text file to 1000h:200h, and i have one question.

Does anyone have asm code for reading lines, inserting and deleting text, dumping the file to screen, etc? I know it's alot to ask, but I want to get a head start in this major area of development ::)

Re:fopen issues

Posted: Sat Jul 10, 2004 9:25 am
by Solar
St8ic wrote:
Does anyone have asm code for reading lines, inserting and deleting text, dumping the file to screen, etc?
All of these are 100% dependent on your OS architecture....

Re:fopen issues

Posted: Thu Jul 15, 2004 8:01 am
by Pype.Clicker
this is mostly a matter of *application* than a matter of kernel programming.
When you said "opened at 1000:200 (or whatever), i assume you mean the whole file content has been dumped to that memory location, right ?"
how do i dump it on screen
foreach $line (in @all_lines[$start ... $start+$SCREEN_HEIGHT])
print $line
how do i insert/delete lines
scan your initial content for 'end of line' characters and create a list of lines (holding a pointer to the line data and a pointer to the next 'line' structure). Deleting a line will mean removing a 'line' structure from the list, inserting a line means inserting a new 'line' structure pointing to newly allocated memory with new data.

When committing the file (e.g. at 'SAVE' command from user), sweep the lines list and write back each line to the file ...

This is a Quick&Dirty approach and will probably suffer problems with larger files, longer sessions, etc. but it should suffice for application-level QeDitor