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 September 28, 2003 6:26 PM, Robert Lillack" <rob@xxxxxxxxxx> wrote

> It occurs to me that a really nice and relatively straightforward way of
> doing this would be to use syntax coloring to show the whitespace ...
> Obviously it would be the background color that would be the key.  With
> color you could make the distinction very subtle.  For example by making
> the background just enough more/less red or green or blue to be obvious.
> 
> This would be even better if you could set it in an additive way, so
> that you could turn it on and off like a sub-mode.  However given that
> it could be kept very subtle, you could probably leave it on all the
> time without distraction or annoyance so that's not a big deal...

Some time ago I posted a small script to colorize spaces and tabs by
abusing some syntax-functions. This abusing has one drawback: the
colorized items in other buffers are affected by this. To avoid this, we
would need some additional syntax/color-objects, which are meant to
be used only for this purpose.

The following script is a rudimentary binary-mode, which needs
only two syntax/color-objects: one for control-chars including tab
and the other for ordinary text-chars including space. Maybe this
minimum approach can satisfy most.

As it is, bin_mode has to be issued a second time on the same
buffer to remove the side effects on syntax-colors in other mode-buffers.
To make it  more pleasant, bin_mode tries additionally to reset
the mode which was active before. Yet not elaborated:
useful key-bindings, e.g. goto byte-offset instead of goto line,
combination with find_binary_file and any file-extensions.

% binmode.sl
static variable M= "bin";

if (not keymap_p( M)) copy_keymap( M, "global");

create_syntax_table(M);
{
   variable s="", i;
   
   for (i=1;i<32;i++) s+= char(i);
   
   % text- and control-chars
   define_syntax( "\d032-\d999",  '0', M); % number
   define_syntax( s,              '+', M); % operator
}

public define bin_mode()
{
   variable m;
   
   if ((what_mode(),pop()) == M)
     {
        ()= evalfile( _Jed_Color_Scheme);
        @__get_reference( get_blocal_var( M));
        return;
     }
   
   m= strlow((what_mode(),pop()))+"_mode";
   if ( __get_reference( m) == NULL) m= "no_mode";
   create_blocal_var( M);
   set_blocal_var( m, M);
        
   set_mode( M, 0);
   use_keymap( M);
   use_syntax_table( M);
   
   % colorize text- and control-chars
   set_color( "number", get_color( "string"));
   set_color( "operator", get_color( "comment"));
   
   run_mode_hooks( M+"_mode_hook");
}


-- Klaus

--------------------------
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]