jed-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Word-wrapping


WAS: Re: Esc-q and new line / line feed chars

Romano Giannetti wrote:
I think that the misunderstanding lies here. Jack, in JED (as in any "real"
text editor [1]) the lines you see are not visual lines. They are _physical_
lines, and when you do "Esc-q" to reformat the text, JED changes the real
lines of the "paragraph". What your Solaris collegues see is that they see
(in Staroffice Word, maybe, or whatever) is that they see every line as a
different paragraph, because all word processor out there use the newlines
as the end-of-paragraph marker [2].
Really, JED knows nothing about paragraph. You can change the idea of JED
paragraph by changing a function...
Some editors use word-wrapping to achieve the desired effect. If a line of
text is too long to fit on the screen it is continued into the next line on
screen - a virtual line-break.

How hard would it be to implement word-wrapping in JED?
Let mi think...

JED stores lines in memory as a linked list. When displaying
a buffer, the dislpay routine visits the list and copies
each (visible) line of the buffer to the screen buffer.

To implement word-wrapping we would probably need another list
that would hold line fragments each at most as wide as the
screen buffer.

Currently:
	Line1    -->  Screen1
	Line2    -->  Screen2  $
	Line3    -->  Screen3
	...

Word-wrapped (Line2 is long):
	Fragment1.1   -->  Screen1
	Fragment2.1   -->  Screen2       \
	Fragment2.2   -->  Screen3       \
	Fragment2.3   -->  Screen4
	Fragment3.1   -->  Screen5
	...

'$' marks line continuation off-screen, '\' marks
line continuation on-screen.

The structure for fragments would look sth. like:

typedef struct Fragment
{
   Line* line;
   long  offset;
   Fragment* next;
} Fragment;

A function word_wrap_lines(int nColumns, Line*) would create
a list of fragments from a list of lines.

The solution seems trivial, but I think JED does many calculations
that are based on the list of lines and the change would require
many modifications deep in the code.

There are more solutions to the problem:
   * each line has a list of fragment offsets
   * there is no list of fragments - the line is wrapped when
     it is copied to the screen buffer
   *...

But with word-wrapping there are some questions to answer:
   * how are lines numbered - by line or by fragment
   * how are columns numbered
   * is the topline of the window the top _line_ or the top _fragment_
   * when user presses down-arrow, does he move to the next line
     or the next fragment
   * can a fragment mark the beginning of a fold
   * can a buffer be narrowed to a set of fragments or only to a set
     of lines - does struct Fragment need flags
   * ...


Marko

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]