jed-users mailing list

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

Re: Line numbers and Visible Tabs


On Sat, May 31, 2003 at 08:13:44PM +0200, Robert Lillack wrote:
> Hi,
> 
> I have two small feature requests and would like to
> discuss them/ask about the possibility to add them:
> 
> 1. Always visible line numbers.
>    I sometimes really need them at the left side, not only
>    the actual line number at the status line. Would it be
>    possible to have them displayed (of course not in the
>    normal text color)?

This little function adds line-numbers

public define number_lines ()
{
   push_spot;
   if(is_visible_mark, dup) % leave return-value on stack
     narrow;
   eob;
   variable i = 1, digits = strlen(string(what_line()));
   variable format = ["%0d ", "%1d ", "%2d ", "%3d ", "%4d "];
   bob;
   do
     { bol;
        insert(sprintf(format[digits], i));
	i++;
     }
   while (down_1);
   if (()) % was_visible_mark
     widen;
   pop_spot;
}

The numbers are written into the buffer. This makes editing such a buffer
a cumbersome task. You would need to program suitable hooks for
format_buffer, wrap, and newline_and_indend.

Also, a save_buffer_before_hook would be needed to remove the linenumbers
again.

Removing could be done by a function marking the rectangle containing the
linenumbers and calling kill_rect().

Color is possible with

   set_column_colors(color_number( "menu_selection"), 1, digits+2);

However, this would interfere with the syntax-highlighting and I do not know
the way to remove the column-colors again.
Another option would be DFA Syntax Highlighting of all numbers at bol (plus
preceeding whitespace).

> 2. Visible Tabs.
>    I often need to edit files normally managed by other
>    people and then it's hard to see if there are "real" tabs
>    inside --> so I destruct the "layout" of code not written
>    by me. If I could "see" the tabs I could insert real tabs
>    and everything would be fine.

Simple solution: M-X TAB = 0; Tabs will now be shown as ^I
(and take up exactly two spaces)

>    I'd love to see something like:
> 
>    |-->    text|-->text
>    |-->    |-->    text
> 
>    with "|-->" drawn in a user defined color. Maybe it
>    would even be possible to make the shown string user
>    definable.

Again, one could write a function, that replaces all "\t" with "|-->\t".
(And another, that inserts "|-->\t" and bind it to Key_Tab.) A
global_mode_hook could ad the color (which is not trivial, as we need to
consider 3 cases: no syntax table, traditional syntax table, DFA syntax
table). Making it user definable is no problem. The problem is with cases
where this will lead to the "hopping" of the following text/code to the next
tab-stop. You will get an even messier layout as the indendation is broken.

So, maybe it is easier to adjust your tab setting (variables TAB and
USE_TABS) to the sources values. (e.g. a find_file hook could set USE_TABS =
1 if there are hard-Tabs in the file and USE_TABS = 0 if not)

PS: The documentation in hooks.txt (Help>Browse_Docs>hooks) might be
helpfull.

Günter

-- 
Milde at ife.et.tu-dresden.de

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


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