[Gretl-devel] remarks on the script editor

Allin Cottrell cottrell at wfu.edu
Wed Jan 16 22:36:18 EST 2008


Hello all,

futurdorko has made some good suggestions in regard to gretl's 
built-in script editor lately, and I've made some changes in CVS.  
If people could beat on the new stuff and expose any bugs that 
would be great.

The main thing is new handling of Tab and Enter.  I've tried to 
make these keys behave pretty much as they do in, say, Emacs' C 
mode.

Tab: when the Tab key is pressed at the beginning of a line (or in 
white space to the left of any non-space characters on a given 
line), instead of simply entering a Tab character, try to 
determine what the logical indent is for the current line, and 
enter enough space characters to go to that indent.

Enter: when Enter is pressed, check the indentation of the line 
being completed, and if it's not correct, adjust it.

So, for example, if you type

loop 100<Enter>
<Tab>if x > 3<Enter>
<Tab>print "x > 3"<Enter>
<Tab>else<Enter>
<Tab>print "x <= 3"<Enter>
endif<Enter>
endloop<Enter>

you get

loop 100
    if x > 3
        print "x > 3"
    else
        print "x <= 3"
    endif
endloop

This assumes the default of 4 spaces per "Tab", but if you 
right-click in the editor window you get a configure option in the 
popup menu that lets you set this value from 2 to 8 spaces.
You also get the option of turning off the "smart" Tab behavior 
if you don't like it; and if you have an existing script open in 
the editor you get the option of applying "canonical" indentation 
to the whole thing.

Allin.





More information about the Gretl-devel mailing list