fopen issues

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
St8ic

fopen issues

Post 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 ::)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:fopen issues

Post 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....
Every good solution is obvious once you've found it.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:fopen issues

Post 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
Post Reply