ajbj NEdit Patches as on 2008-May-21 03:03:38

anonArrayNamedArgs7.diff Modified: 2008-Mar-26 23:45:55

Allow inline construction of anonymous arrays and "named arguments"

Available as a patch: http://sourceforge.net/tracker/index.php?func=detail&aid=1592340&group_id=11005&atid=311005
    [ 1592340 ] Array literals and named arguments
    anonArrayNamedArgs3.diff 2006-11-16 02:34

This patch allows arrays to be created in-line as anonymous entities. For example:
    my_array = { \
        1, 2, 3,                # assigns elements [0] to [2] \
         ["word"] = "val",      # assigns element ["word"] \
        ,                       # don't assign to [3] \
        4,                      # assigns element [4] = 4 \
        [7] = 7, 8,             # assigns elements [7] and [8] \
        ["sub"] = { "a", "b" }  # assigns an array to element ["sub"] \
    }
The anonymous array is available in contexts where a whole array is needed; for example:
    val0 = { [0] = "zero"}[0]
    my_array += { [val0] = 4 + 5 - 9 }

The patch also allows macro functions to be called with array element style assignments. These cannot use simple numeric or numeric string indices, but multidimensional numeric indices are allowed.

The array element style ("named") arguments are inserted into the called routine's $args array, and accessible using array syntax. Simple argument expressions are counted from the first ($1), with numeric index 1 in $args, up to $n_args. Note that $args[] and $n_args may now be different since the former will include the count of "named" arguments.

For example:
    define returnArgs {
        return $args
    }
    a = returnArgs(1, 2, 3, 4, 5, [6,7]=8, ["hello"] = "hi")
    b = { , 1, 2, 3, 4, 5, [6,7]=8, ["hello"] = "hi" }
Here the arrays a and b are equal. (Note the comma at the start of b's assigned array.) But:
    a = returnArgs(1, [2]="no") # fails: name for arg cannot be numeric

Finally, calling a built-in macro function always makes sure an extra argument is present at argList[nArgs] - in calls using positional values only, this argument will have a tag value of NO_TAG. If "named" arguments have been passed, the argument will have tag ARRAY_TAG, and the named arguments be present in the array, indexed by name. (The positional arguments will not be in this array but can be added to it readily.) Use the ArrayGet() function or iterate over entries as required.

arrayConstructor2.diff Modified: 2007-Jan-17 17:11:05

Allow inline construction of anonymous arrays

This patch allows arrays to be created in-line as anonymous entities. For example:
    my_array = { \
        1, 2, 3,                # assigns elements [0] to [2] \
         ["word"] = "val",      # assigns element ["word"] \
        ,                       # don't assign to [3] \
        4,                      # assigns element [4] = 4 \
        [7] = 7, 8,             # assigns elements [7] and [8] \
        ["sub"] = { "a", "b" }  # assigns an array to element ["sub"] \
    }
The anonymous array is available in contexts where a whole array is needed; for example:
    val0 = { [0] = "zero"}[0]
    my_array += { [val0] = 4 + 5 - 9 }

arrayReplacesArglist5.diff Modified: 2008-Jan-31 01:14:49

Allow an array to take the place of function arguments in a call

The macro syntax is:
        func( =array )

Exactly one array argument is allowed. The content of this array is made available to the called function as $args. The positional arguments, $1 and so on, are copied from the array to the stack, using the corresponding numeric indices, increasing from 1 until there is a break in the sequence.

2008-01-31

Corrected this patch: resolving inconsistent stacking between ExecuteMacro() or RunMacroAsSubrCall() and callSubroutineFromSymbol(). Things would work unless you had executable statements in a macro file.

Another correction handles how the argument array is passed when using the new syntax. Firstly, a copy is passed to the called function (before this would be the actual array); then the unnamed (numbered) arguments are removed from this copy as they are loaded onto the stack. If the called function then accesses "$args" the arguments are copied back into the array copy. This is to allow for further functions which reoder arguments such as call(function_name,arg1,arg2,...) to work when invoked with the new syntax.

avoidMenuRebuild.diff Modified: 2006-Jul-19 16:10:30

Avoid rebuilding menu structures if only macro/shell text has changed

If you change a macro or shell commmand menu entry using the appropriate dialog, this patch checks what has changed so that menus are only rebuilt if their structure is altered in any way. If only the text of the macro or command has changed, the menus are not rebuilt.

This avoids losing tear-off menus in many cases.

backlightCharTypeDefault3.diff Modified: 2007-Oct-18 19:36:11

Fix the default backlighting string

This makes plain text and spaces have the same backlight, a little paler than the default background (when backlighting is enabled, of course).

It also makes this resource saveable to the settings file.

BacklightForeground6.diff Modified: 2008-May-15 20:46:41

Applying foreground color using backlighting

This patch adds the ability to specify a foreground color for a backlighting class. The foreground color takes priority over syntax highlighting colors. This allows (in particular) space and tab characters displayed as glyphs to appear with a uniform color no matter in which highlighting pattern they appear. (It isn't very useful in other cases.)

To specify both foreground and background in the backlightCharTypes resource, just separate them with a slash. (Note that this syntax should be changed, as well as that for background text styles, to allow new color specification formats, eg rgb:/e7/e7/c0.) If two colors are found, the first will be treated as foreground, the second as background.

(We should really separate out the color allocation currently in highlighting.h.)

2006-11-22

Changes made to track CVS Head.

2008-03-12

Added the macro built-in set_backlight() which allows a simple interface for changing backlighting specifications.

BannerWait1sec.diff Modified: 2005-Oct-05 10:54:05

Reduce pause time before changing status line to busy banner to 1 second

buttonsArrays2.diff Modified: 2006-Oct-03 08:59:59

Allow an array to pass button names to macro dialog functions

Instead of calling a dialog as
    btn = dialog("What to do next?", "Stop", "Retry", "Skip", "Cancel")
you can use an array, eg
    btns[1] = "Stop"
    btns[2] = "Retry"
    btns[3] = "Skip"
    btns[4] = "Cancel"
    btn = dialog("What to do next?", btns)

This allows you to test the validity of the button number like this:
    if (!(btn in btns))
        return "Cancel"
and to use the button names in button value tests, as in
    if (btns[btn] == "Stop")
        doStop()

In fact, by including a zero-indexed element, you can handle all results returned as the dialog button, eg
    btns[0] = "Cancel"
    ... # assign btns[1] to btns[4] as before
    btn = dialog("What to do next?", btns)
    # now we know that all possible button values are indices into btns
    # so the following will not fail:
    if (btns[btn] == "Stop")
        ...

callMacroFnByName2.diff Modified: 2007-Oct-16 20:03:31

Provide a call() macro function which calls another function given its name

The function invokes new code in interpret.c which calls the desired, named function with any remaining arguments to call(). In this way, the function is called using the same interpretation environment as call()'s invoker.

calltipTagLookBack.diff Modified: 2005-Oct-05 10:54:32

Allow tag-based calltips to pick up text before and after the target

Previously only a few lines of text at and following the tag target would be retrieved; now a number of lines preceding the target are retrieved too. This is for people who expect commentary in front of an item.

CDEdragAndDrop3.diff Modified: 2007-Nov-20 16:37:00

dt Drag And Drop in CDE (Solaris, HP-UX)

Originally by Fredrik Jönsson from his cde_dnd.tar.gz patch.

Adds new files dragAndDrop.[ch].

Using the CDE desktop file manager, you can drag a file onto a NEdit window. A normal or Ctrl-modified drag ("move" or "copy" operation) will open a new window or tab page according to your preference. With Ctrl+Shift modifiers (a "link" operation) the opposite occurs.

Otherwise, if you drag text from a regular Motif widget, this gets copied into a new NEdit document (in a tab page, if that is your preference).

closeTabNoPrompt.diff Modified: 2006-Sep-04 16:50:42

Close without prompting if close-tab button pressed with Shift or Control

ColoredWinMenu6.diff Modified: 2007-Jul-02 15:03:35

Add coloring to the windows menu to indicate modified buffers

This is a modified version of Arne Førlie's patch:

http://sourceforge.net/tracker/index.php?func=detail&aid=937063&group_id=11005&atid=311005
    [ 937063 ] Coloured file names in Windows menu
    89330: colored_win _v2.patch        2004-06-02 16:17

This patch color-codes the file names in the windows menu according to state. By default the patch uses the following colours

  • modified (unsaved) files are red
  • read-only files are blue
  • otherwise they are black

For modified and read-only, you can also change the background color used; this is normally set to "white"; set it to "default" to use the normal menu background color.

A set of X resources are used to modify the defaults. They are documented in the help (do 'make docs' to update the help files before building the executables).
    nedit.coloredWinMenu: True
    nedit.defaultWinMenuColor: black
    nedit.modifiedWinMenuColor: red
    nedit.readOnlyWinMenuColor: blue
    nedit.backgroundWinMenuColor: white

2006-08-14, ...

Updated to be synchronised with CVS head.

2007-06-12

Added new resource backgroundWinMenuColor

2007-07-02

Removed irrelevant help info (thanks to Bert Wesarg)

ColorWin2.diff Modified: 2005-Oct-05 10:54:07

Allow the color dialog to set colors for JUST the current tab of its owner window

CursorLine6.diff Modified: 2008-Jan-14 17:59:56

[INACTIVE] Highlighted Cursorline

This is Thorsten Haude's patch, modified from Fredrik Corneliusson's patch to provide a background color for the current line. You can find it here:

http://sourceforge.net/tracker/index.php?func=detail&aid=683567&group_id=11005&atid=311005
    [ 683567 ] Highlighted Cursorline
    cursorline.ajbj.2004-03-28.1.diff 2004-03-28 05:52

This coloring takes precedence over rangesets, syntax highlighting backgrounds (if specified) and backlighting, but not over parenthesis match highlighting nor selection.

It still requires work, for example for turning the cursorline highlighting on and off through the GUI and through macros.

Thorsten has taken over this patch, integrating it with other functionality. Check the patch page:

http://sourceforge.net/tracker/index.php?func=detail&aid=1058246&group_id=11005&atid=311005
    [ 1058246 ] Patch Collection

cygwinDebug.diff Modified: 2007-Oct-23 19:50:31

Changes optimisation flag (-O) to debug information flag (-g) for cygwin

DeleteTheAppShell.diff Modified: 2008-May-21 02:36:20

Tidy up the invisible application shell created at startup

DragDocTabs4.diff Modified: 2007-Oct-17 18:58:05

Drag a document tab from one window to another

This patch was written by the Tab Master, TK Soh. You can find it here:

http://sourceforge.net/tracker/index.php?func=detail&aid=920929&group_id=11005&atid=311005
    [ 920929 ] move tab by drag and drop
    drag-move-v1_1.diff.gz 2004-03-23 21:52

2006-07-15

Updated to TK's newer version, on the same page:
    drag-move-v1_2.diff 2005-11-29 05:36

dropFile5.diff Modified: 2008-Jan-14 16:53:13

Drop files on nedit to open them

This is Scott Tringali's patch for allowing NEdit to accept files dropped from a file manager. You can find it here:

https://sourceforge.net/tracker/?func=detail&atid=311005&aid=1371164&group_id=11005
    [ 1371164 ] Drop files on nedit to open them
    dropfile.patch 2005-12-01 11:49

His comments:

Drop files on to nedit from a file manager to load them. This is just a proof of concept, and needs lots of work. Specifically:

  • 1) We don't do any real URI decoding. Files with spaces in the names won't load.
  • 2) Error checking - users can attempt to drag files located on different machines, and we should probably ignore those files instead of aborting.
  • 3) Protocol checking - right now, all we use is "file:" but it may be possible to support others.
  • 4) Badly formed URIs - different apps formulate URIs differently and incorrectly. See comment in patch.
  • 5) Errors posted during a drag will wind up with a dialog under the drag icon. Not good.
  • 6) Handle multiple files - seems okay for text/uri-list (nautilus) but not done for FILE_NAME (CDE).
  • 7) What other atom types should we support? What do other apps provide?
  • 8) Better awareness of windows and tabs (and prefs) if need be. Right now the drop site is the entire application.

I've tried it out with CDE dtfile on tru64, and Nautilus under Fedora Core 2.

2006-09-21

Corrected to fix a compiler warning.

DropPrevIfNotFound2.diff Modified: 2007-Oct-17 18:58:05

Drop entry in Open Previous file list if the file no longer exists

If you select an entry in the File -> Open Previous menu list for a file which cannot be found, the entry in the menu list (and history file) will be removed. Otherwise, the only way to remove such entries is by "pushing them out" with other file names until they drop off the history list, meaning that you can often see dead entries in the list.

Calls to the new function RemoveFromPrevOpenMenu() could perhaps be made elsewhere, when document windows are closed for lost files.

FastConcat3.diff Modified: 2007-Oct-18 19:04:24

Perform faster macro concatenation

Available as a patch:

http://sourceforge.net/tracker/index.php?func=detail&aid=971477&group_id=11005&atid=311005
    [ 971477 ] Perform faster macro concatenation
    FastConcat.diff        2004-06-11 15:55

Previously, concatenation was treated as a binary operator, taking two values from the stack and concatenating them. Where an expression involves more than one concatenation, this involved creating temporary strings, requiring separate allocation, which would only be discarded later, for each application of the binary concatenation. To make matters worse, concatenation would rescan each string to determine its length using strlen().

This modification changes the way the concatenation operator is handled. Instead of treating it as a binary operator, it sees it as a list operator, rather like the comma in an argument list. Thus a concatenation expression is treated as a counted sequence of subexpressions. The count is coded into the "bytecode" to tell the concat() function (in interpret.c) how many expression values to pull off the stack. The function then exploits the fact that string DataValue structures now include the strings' lengths to work out the total allocation length required for the whole result. (This is based on the previous implementation of makeArrayKeyFromArgs().)

I have also added static functions longAsStr() and lenLongAsStr() to generate a string representation of a number, or just to work out its length. This allows us to avoid calling sprintf() with "%d" all the time. The new AllocStringOfNumber() exploits this, and is used in various places in interpret.c. Note that longAsStr() returns the string value in a static buffer which must be used/copied immediately to avoid a second call overwriting its content.

ForbackwardSame3.diff Modified: 2008-Jan-05 23:51:16

New arrow key action routines improving the "word jump" action procedures

Available as a patch:

http://sourceforge.net/tracker/index.php?func=detail&aid=970496&group_id=11005&atid=311005
    [ 970496 ] New arrow key action routines improving "word jump" actions
    ForbackwardSame.diff        2004-06-10 08:41

Instead of always stopping at the fronts of words, you can set these action routines to stop at line ends, the ends of runs of spaces, etc. by setting appropriate translations. This patch also allows "jump to end of selection": if you have an active selection, you can get your left/right keys to move to the end of it before deselecting it, rather than just moving one character position.

  • Added forward_same/backward_same action routines, to bind to ctrl-right/left for word skipping
  • Added forward/backward_character skipselect argument, to move to either end of an active selection before clearing it
  • Added forward_same/backward_same skipselect, skipblanks arguments, allowing fine control over where the cursor ends up

Example translations


  NEdit*text.translations: #override \
    Shift Ctrl<KeyPress>osfLeft: backward_same("extend")\n\
    Ctrl<KeyPress>osfLeft: backward_same("skipselect","skipblanks")\n\
    Shift Ctrl<KeyPress>osfRight: forward_same("extend","skipblanks")\n\
    Ctrl<KeyPress>osfRight: forward_same("skipselect","skipblanks")\n\
    ~Alt ~Shift ~Ctrl ~Meta<KeyPress>osfRight: forward_character(skipselect)\n\
    ~Alt ~Shift ~Ctrl ~Meta<KeyPress>osfLeft: backward_character(skipselect)\n\
    ...
getColors6.diff Modified: 2008-May-07 22:00:44

Retrieve standard color settings in macro code

This can be useful in macros for preparing rangeset colors related to the current background/foreground color settings.

The new macro function get_colors() returns an array with the following indices:

  • ["default_text_fg"] Foreground color name
  • ["default_text_bg"] Background color name
  • ["default_select_fg"] Foreground selection color name
  • ["default_select_bg"] Background selection color name
  • ["default_hilite_fg"] Foreground match-highlight color name
  • ["default_hilite_bg"] Background match-highlight color name
  • ["default_lineno_fg"] Foreground line number color name
  • ["default_cursor_fg"] Foreground cursor color name
  • ["rgb_text_fg"] Foreground color RGB value
  • ["rgb_text_bg"] Background color RGB value
  • ["rgb_select_fg"] Foreground selection color RGB value
  • ["rgb_select_bg"] Background selection color RGB value
  • ["rgb_hilite_fg"] Foreground match-highlight color RGB value
  • ["rgb_hilite_bg"] Background match-highlight color RGB value
  • ["rgb_lineno_fg"] Foreground line number color RGB value
  • ["rgb_cursor_fg"] Foreground cursor color RGB value

Currently, the RGB color value retrieval mechanism, using the text widget's resources, is not perfect - the following values are not set: rgb_select_fg, rgb_lineno_fg, rgb_cursor_fg; the following values are set initially, but if changed using the color settings dialog, will not be updated: rgb_select_bg, rgb_hilite_fg, rgb_hilite_bg.

2008-03-29

Added another group prefixed with "window_" for the color names used for the current window. Also added a function called set_color() for changing values. This can be done using the names starting with "window_" only, or formed by dropping the "rgb_" or "default_" prefix.

GTsAndAtsInMenus.diff Modified: 2006-Feb-08 02:37:45

Allow '>' and '@' to appear in menu items

Two consecutive '>'s are treated as a single '>' in a displayed menu item, rather than being used to generate a submenu. Similarly, doubled '@'s will not start language mode interpretation.

HairlineMargin9.diff Modified: 2008-Jan-11 00:02:04

Add a visual hairline to show any fixed wrap margin

This patch is based on
    http://www.vranx.de/nedit/hairline.2004-07-13.1.diff.gz

ImprovedMacroGC.diff Modified: 2008-May-21 01:50:33

Allow macro data garbage collector to run during macro execution

An old limitation of the garbage collector (GC) is its inability to tidy during macro execution.

This patch converts NEdit macro's mark/sweep technique so that it can run during macro execution. What needs to be done is to allow the mark part to run through the active macro call stacks, allowing marking of function-local strings and arrays. For this all continuation contexts need to be accessible. This is done by linking them together in a circular linked list. It is also necessary to add a new data value type for array iterators, so that the GC can mark their underlying arrays.

Although this is all quite easy to do, it is not clear how often it should be done (other than at the end of macro execution). This implementation invokes the GC following an earlier call after a maximum number of allocations (MAX_N_ALLOC_LIMIT=10000), or after allocation of a certain amount of space (SIZE_ALLOC_LIMIT=1MB), along with a minimum number of allocations (MIN_N_ALLOC_LIMIT=200), has occurred. Since the mark/sweep itself (particularly for situations where lots of global data are accessible) itself requires much time, calling the GC shouldn't be performed too frequently.

A more complete solution, which could, in particular, cut down on copying array structural data, would be a reference counted approach. This patch though seems a reasonable improvement.

IncreaseMaxDupTags.diff Modified: 2008-May-21 02:45:57

Increase the maximum number of displayed tag collisions

indexNotInArray.diff Modified: 2005-Dec-01 17:47:45

[INACTIVE] Allow easy negative testing of array index inclusion

This patch provides the composite operator "! in" (for "not in"), which can be used in array tests. This allows the current negative test
    if (!(index in theArray)) ...
to be written
    if (index !in theArray) ...

The Enhancements to NEdit macro parsing patch includes this small change.

InterpretDebug5.diff Modified: 2008-May-21 02:04:30

Provide NEdit Macro stack traces

Avaliable as a patch:

http://sourceforge.net/tracker/index.php?func=detail&aid=970501&group_id=11005&atid=311005
    [ 970501 ] Provide NEdit Macro stack traces
    InterpretDebug.diff 2004-06-10 11:51

Macro function names are listed when a crash occurs in one of your macros. The usual error message is followed by a list of the NEdit macro functions called before getting there. (It doesn't tell you how the macro was invoked however.) This provides a good clue as to where a macro programming problem lies.

Also, debug tracing enhanced to show symbol values in stack traces listed to terminal output: a boon to interpret.c hackers.

Try changing the definition
  #define STACKDUMP(n, x) stackdump(n, x)
to
  #define STACKDUMP(n, x) stackdump(n, x + 50)
and watching the output of NEdit in an xterm generated while running your favorite macros!

(You will need to add -DDEBUG_STACK and -DDEBUG_ASSEMBLY in your compilation flags to enable the debug tracing.)

Thanks to Eddy De Greef!


    InterpretDebug2.diff        2004-06-11 17:13

This version passes an extra "name" string to ParseMacro(). This name is used as a "function name" in the stack dumps, when there is no available function symbol name available (usually at the top level of invocation from NEdit's user interface). It allows the user to determine which macro is being invoked or which file is being interpreted when an error occurs.

lesstifTabCtxMenu.diff Modified: 2005-Dec-01 17:47:47

[INACTIVE] Tab context menu calls AddTabContextMenuAction() always

(Normally this is done only for LessTif versions.)

This is an attempt to make tab context menus (from mouse button 3) appear on Solaris. It allows them to appear, but they disappear as soon as the mouse button is released, and the menu buttons don't work.

I don't use this anymore: it doesn't seem to help.

linuxDebug.diff Modified: 2007-Oct-23 19:50:47

Changes optimisation flag (-O) to debug information flag (-g) for linux

listDialogKeyWords.diff Modified: 2007-Nov-20 16:36:32

Provide support for behaviour keywords in list_dialog()

The keywords, if any, can be supplied as individual string arguments to list_dialog(). They will be checked for validity until either an empty string is found or a non-keyword string is found, which is then used as the first button label.

Currently the keywords are "single_sel", "multi_sel", "browse_sel" and "extend_sel" (specifying selection policy for the list; only one of these is allowed), and "string_entry" (whether a freeform string can be entered).

If only one entry can be selected ("single_sel" and "browse_sel"), this will be the text of the entered string (if "string_entry" is active and the string is not empty), or the value of the selected list line.

If multiple selections can be made from the list, they are copied into the result, separated with newlines. Any non-empty string (if "string_entry" is active) will get added at the end in the same way.

This patch is intended to replace the ListMultiSel patch, avoiding the creation of a new list_multisel_dialog() function.

ListMultiSel6.diff Modified: 2007-Oct-18 19:31:41

Provide a new list_multisel_dialog() function

Avaliable as a patch:

http://sourceforge.net/tracker/index.php?func=detail&aid=988172&group_id=11005&atid=311005
    [ 988172 ] Provide a new list_multisel_dialog() function
    ListMultiSel.diff        2004-07-09 12:00

The new builtin macro function, list_multisel_dialog(), acts as a complement to the current list_dialog() function. It works in exactly the same way, except that the user can choose more than one of the presented lines in the list. These lines are returned to the user as a single string, with the lines separated by the newline "\n" character. (Note that there is no "\n" at the end of the last of the selected lines returned in the string.)

The same pseudovariable, $list_dialog_button, is used by both functions to return the number of the dialog button pressed.

I decided to use a single string return value rather than an array value for two reasons. Firstly, the input and output are in the same format. Second, doing things this way avoids having to deal with indices to an array, and conversion to an array can already be performed very readily using split. It was also easier to implement this way.

As part of this patch I increased the list's maximum display length on dialog creation from 10 to 25. (I spend a lot of time simply resizing such dialogs since 10 lines is usually too small a window for me.) Ideally, this should be configurable (through a non-saved X resource would be sufficient).


    ListMultiSel2.diff 2004-07-27 19:03

Corrected a bug whereby the string result had a badly set length (the character count was too great by 1).

macroKeywords2.diff Modified: 2007-Jan-17 17:11:08

Provide parsing support for macro function keyword parameters

The routines allow a sort of preprocessor for function arguments.

  • Any arguments following an empty string argument are handled as usual, although the first empty string argument is dropped.
  • Before an empty string argument, strings of the form "KeyWord=Value" or "KeyWord=Value, KeyWord=Value; KeyWord: Value\n ..." etc are treated as keywords, and removed from the argument list. Instead they are added to a keyword array. Note that this allows nested keyword arrays for strings like "KeyWord=[ key:val, ]", with brackets, parentheses or braces used to delimit the sub-array.
  • Before an empty string argument, arrays are handled as follows: all entries with keys that look like words ([A-Za-z_][A-Za-z_0-9]*) are copied to the keyword array; any elements with numeric keys are treated as normal arguments (by copying to an argument list array) if the keys don't contain whitespace and form an unbroken sequence of increasing values starting at 1.

The set_keywords_and_args_array(...) built-in serves as an example, and can also be used for building such arrays in macro code. For example, the code
    s = "a=b, c=d\n e=f; subarray = { x=1; y: 2, label:'right on' }"
    z[0] = "not there"
    z[1] = "hello"
    z[2] = "there"
    z["zed"] = "dead"
    a = set_keywords_and_args_array(s, z, "", s, z)

does the same thing as
    s = "a=b, c=d\n e=f; subarray = { x=1; y: 2, label:'right on' }"
    z[0] = "not there"
    z[1] = "hello"
    z[2] = "there"
    z["zed"] = "dead"
    # --- positioned arguments
    a[1] = "hello"      # from z before ""
    a[2] = "there"      # from z
    a[3] = s            # the s argument following ""
    a[4] = z            # the z argument following ""
    # --- keywords
    a["a"] = "b"
    a["c"] = "d"
    a["e"] = "f"
    a["subarray"] = $empty_array
    a["subarray"]["x"] = 1
    a["subarray"]["y"] = 2
    a["subarray"]["label"] = "right on"

MacroMenuAdjust.diff Modified: 2005-Oct-05 10:54:21

Add (Customize) Macro/Background Menu to Macro menu

(because I hate Preferences->Default Settings->Customize Menus)

It also changes the "Help" menu label to "Help 5.6dev" just as a reminder.

macroSemicolons.diff Modified: 2006-Jan-12 22:28:17

[INACTIVE] Optional semicolons for statement termination

Derived from N8 Gray's patch:

http://sourceforge.net/tracker/?func=detail&atid=311005&aid=1185506&group_id=11005
    [ 1185506 ] Optional semicolons for statement termination

The Enhancements to NEdit macro parsing patch includes this change.

macroSplit2.diff Modified: 2008-Feb-19 23:59:17

Extending the split() macro built-in

This patch extends split()'s functionality. It allows limited splitting, where only a certain number of elements should be retrieved, and also allows the dropping of the last element found if it is empty.

The limited count avoids the perhaps unnecessary overhead of generating a large array if only the first few elements are to be used. The dropping of the empty last element allows simple reconstruction after simple splits, very useful for lines. For example, given:


    a = get_range(0, $text_length)
    lines = split(a, "\n", "lastnotnull")
    b = ""
    for (i = 0; i < lines[]; i++)
        b = b lines[i] "\n"

assuming that all lines are '\n' terminated, b == a at the end. Otherwise we have to resort to something like:


    a = get_range(0, $text_length)
    lines = split(a, "\n")
    b = ""
    sep = ""
    for (i = 0; i < lines[]; i++) {
        b = b sep lines[i]
        sep = "\n"
    }

to make a == b at the end. which is trickier (albeit more general).

2008-02-19

Added "nonull" alternative to "lastnotnull": if used, no empty (zero-length) pieces will be stored in the array; the count limits the number of pieces stored in this case, and does not account for the empty pieces skipped.

macroStringLiterals3.diff Modified: 2007-Oct-17 18:58:10

Unlimited macro string literal length and single-quoted strings

Available as a patch:

http://sourceforge.net/tracker/?func=detail&atid=311005&aid=1598271&group_id=11005
    [ 1598271 ] Unlimited macro string literal length, single-quoted strings
    macroStringLiterals.diff 2006-11-21

String literals are scanned twice, firstly to calculate their space requirements, secondly to read their contents into allocated memory.

Separate string literals that follow one another are combined into one, avoiding run-time concatenation of the pieces. Also single-quoted string literals are allowed, within which backslash ('\') has no special meaning (so you can't include a single-quote in a single-quoted string).

Note that a double-quoted string can be continued over multiple lines by ending each line but the last with a backslash, like in C.

2006-11-21:

Fixed adjacent string literal merging to allow concatenation with "".

minmaxArrays3.diff Modified: 2007-Oct-17 18:58:07

Allow min() and max() macro built-in functions to accept a single array

If an array is passed instead of a list of arguments, each entry of the array is examined, and must be a numeric value. (The keys are ignored.) No other arguments are allowed.

moreMenuEntries.diff Modified: 2006-Jul-18 12:56:03

Increase the maximum number of user menu entries from 400 to 1000

MultipleAssignment.diff Modified: 2008-Mar-15 00:43:32

Assign multiple lvalues in one statement

This patch allows you to assign a set of variables in a lvalue list from the content of an array. This has the appearance of a tuple. The keys used to retrieve the values from the array expression on the right are numeric values starting with 1. If a key is missing, your macro will fail.

Given the following (implemented as new built-in functions in this patch):
    define args {
        return $args
    }
    define n_args {
        i = 0;
        while (i in $1)
            ++i
        return i
    }
You can assign a list of symbols to the content of such an array using a list assign, thus:


    (x, y, z) = args(a, b, c)

This is equivalent to


    x = a
    y = b
    z = c

This technique can be useful for retrieving argument values in your functions:


    (str, regex, count) = $args

or for returning "tuples" from them:


    define myfunc {
        ...
        return args(isOk, message)
    }
    ...
    (success, msg) = myfunc()

If you need to count the number of variables that can be assigned in this way, use the n_args() function:


    ...
    result = myfunc()       # we expect result is an array
    if (n_args(result) >= 2)
        (success, msg) = result
ncAskFailsWithN.diff Modified: 2005-Oct-05 10:54:36

Make nc fail if a user does not want to start a NEdit server

Although a negative response will make the process exit successfully, if there was no standard input to read, the process exits with a failure.

This allows scripts to take action if a server is not available, using tests like:


    if [ -n "$SVRNAME" ]
    then
      if : | nc -svrname "$SVRNAME" -ask "$@" > /dev/null 2>&1
      then
        exit    # great: all done
      fi
    fi
    # if we get here, we need to set up a new NEdit server
    ...
NegatedEscapesInClassesFix.diff Modified: 2007-Jul-27 01:01:17

Fix for negated class escape misinterpretation in regex character classes

See the following bug entry:

http://sourceforge.net/tracker/index.php?func=detail&aid=1760116&group_id=11005&atid=111005
    [ 1760116 ] Negated escape sequences misinterpreted in character class

This fix simply adds a few more character tables so that the negated charset's characters can be added to the []-bracketed custom charset, as is the case for the positive charset escapes.

Interestingly, I notice that (?n\W) does not match newlines (my patch allows (?n[\W]) to do so, which is rather inconsistent). This is true also for \L, \D. Also \y without (?n ) around it will match newline. I believe these to be faults.

newMacroFnRegistration3.diff Modified: 2008-Mar-26 03:12:01

Change the registration of macro built-ins to improve maintenance

The association of name and value (either a function pointer or an integer) is made explicit here. It also allows for other tables of such associations elsewhere, allowing for separate (theme-based) macro function definition files. It makes macro definition more like the action routine naming too.

nmReadWriteRelToWin.diff Modified: 2006-Aug-24 11:31:46

Make read/write/append macro built-ins use paths relative to the window

If the file name given to read_file(), write_file or append_file() is a relative path, the path associated with the invoking window is used as a base to determine the absolute path before accessing the file.

Before, these built-ins would use the directory in which the NEdit program was invoked as the base. This presented many inconsistencies, not least with shell invocations.

nmvarNEDIT_HOME2.diff Modified: 2006-Nov-22 18:15:13

Thorsten Haude's inclusion of new NEdit Macro variables $NEDIT_HOME and $VERSION.

Part of his "patch collection", see

http://sourceforge.net/tracker/index.php?func=detail&aid=1058246&group_id=11005&atid=311005
    [ 1058246 ] Patch Collection

2006-11-22

Updaed to track CVS Head,

NoIconForCDE.diff Modified: 2006-Jan-11 14:39:32

Do not provide window icons.

This is suitable for CDE systems where the Window Manager can provide a nice color icon, but only if the application hasn't supplied its own (or so I gather).

I assume that a CDE implementation will be using the CDE DnD patch, hence the use of the NEDIT_DT_DRAGANDDROP definition flag.

openSelAllowSpaces2.diff Modified: 2006-Sep-25 16:34:38

Do not remove whitespace from file names when using "Open Selected"

Previously, any spaces in a file name/path are elided. In a Windows environment, you often get paths with spaces included: this patch allows you to open files with such paths.

This patch has been included as part of the following bug:

http://sourceforge.net/tracker/index.php?func=detail&aid=1565125&group_id=11005&atid=111005
    [ 1565125 ] No spaces in paths for "Open Selected"

parseEnhance3.diff Modified: 2007-Jan-17 17:11:11

Enhancements to NEdit macro parsing

Available as a patch:

http://sourceforge.net/tracker/index.php?func=detail&aid=1249914&group_id=11005&atid=311005
    [ 1249914 ] Enhancements to NEdit macro parsing
    parseEnhance2.diff         2005-08-03 18:51

This patch adds the following features to NEdit's macro language:

  • the conditional expression
            ( key ! in array )
    acts as the logical opposite of
            ( key in array )
  • the do ... while loop has been lifted from C, as
            do block-or-statement while ( condition )
  • N8 Gray's "optional semicolons for statement termination" (SF patch 1185506) has been included
  • added a few productions to group assignment increment/decrement operators
  • allowed for linebreaks in places where their statement-terminating behaviour makes no sense, ie in argument lists, after prefix or binary operators, after keywords if, while, for and do (They are also allowed in the comma-separated simple-statements in the for loop's initialisation and iteration phrases) and after opening parentheses; you only need "\" in a few cases now, in particular when concatenating strings on different lines
  • general reformatting of the parse.y file to "condense" the smaller code blocks (this undoes some of Steve LoBasso's reformatting from some time ago) - I think this enhances the grammar productions over the injected code
parseErrorLineNo.diff Modified: 2006-Sep-21 01:20:58

Show the line number at which a parse error occured

This patch counts the number of newlines from the start of the source buffer whose parse has failed. This will be the line number in a macro or macro file where the error was detected. If an error is found in the parsing of the NEdit configuration (nedit.rc), the line number is that of the unit being parsed, not the whole file.

ParseFields3.diff Modified: 2007-Jan-17 17:10:57

Use the '.' operator as an array accessor

Available as a patch: http://sourceforge.net/tracker/index.php?func=detail&aid=974211&group_id=11005&atid=311005
    [ 974211 ] Use the '.' operator as an array accessor
    ParseFields2.diff 2004-06-21 22:34

This allows you to view NEdit macro language arrays as records (both are aggregates of heterogeneously typed objects). The only constraint is that the accessor must appear like a valid symbol name, although internally it is handled as a string. Thus the following statements are equivalent:
    array["member"] = array["field"]
    array.member = array.field

This implementation uses a flag, set when a '.' is scanned, to determine whether the next identifier is a field - if so, it doesn't make a symbol out of the identifier (leading to a variable in the resultant macro), but instead returns a field token, which is just a constant string value used as an index into the array.

PrevfileTree3.diff Modified: 2008-Jan-14 18:10:34

Display the File->Open Previous menu as a tree.

This is another TK Soh patch:

http://sourceforge.net/tracker/index.php?func=detail&aid=714486&group_id=11005&atid=311005
    [ 714486 ] prevfile menu in tree-view
    nedit-prevfiles-v1_0.diff.gz 2003-04-03 01:41

pwdInMake.diff Modified: 2006-Sep-22 00:17:27

Add paths to file names in compilation for more explicit diagnostics

Changes the compilation instructions to include the full path in front of each source file so that compilation diagnostics include full file paths. This allows you to run the NEdit build make in a NEdit window, then simply select the whole file path in an error message for opening a file.

radioOpenPrev2.diff Modified: 2006-Jan-12 17:36:33

Display the File->Open Previous menu using radio buttons

The radio buttons indicate which files are currently open.

The rebuilding of the Open Previous menu is also performed when a document is closed, to allow the refresh of "torn-off" copies of this menu. This is why the invalidatePrevOpenMenus() function was made public rather than static.

radioOpenPrevTree4.diff Modified: 2008-Feb-20 01:59:05

Display the File->Open Previous menu using radio buttons

This patch includes (and supercedes) the PrevfileTree.diff and radioOpenPrev2.diff patches.

The radio buttons indicate which files are currently open.

The rebuilding of the Open Previous menu is also performed when a document is closed, to allow the refresh of "torn-off" copies of this menu. This is why the invalidatePrevOpenMenus() function was made public rather than static.

This version includes the essentials of TK Soh's patch [ 714486 ] prevfile menu in tree-view.

2008-02-20

Added window-local sort/tree options, triggered by two buttons at the top of the Open Previous menu. These are set by default to the global preference, but then change with user actions in the menu (especially useful when torn off). Also allows the user to remove an entry by shift-clicking (no clue to this in the menu though).

RaiseWindowForMacro2.diff Modified: 2006-Oct-03 02:25:26

Extend the raise_window action routine.

Available as a patch:

http://sourceforge.net/tracker/index.php?func=detail&aid=970492&group_id=11005&atid=311005
    [ 970492 ] Extend the raise_window action routine
    RaiseWindowForMacro.diff        2004-06-10 08:37

Adds the following functionality to the raise_window() action routine:

  • if the first argument is "focus", raises the window which currently has the macro focus
  • if the first argument looks like the name of an open file, raises the relevant window
  • if no argument is given, uses the macro focus window explicitly
relativeFileNormalization.diff Modified: 2008-Feb-04 22:29:45

Allow NormalizePathname() and ParseFilename() to use windows path

Various operations require the extension of an incomplete file specification to a full, absolute path. Before this patch, this completion uses the current directory of the NEdit process as the base for relative file lookup. However, this works against NEdit's file dialogs and shell processing which start off in the directory of the current document, which may well not be the same as the process' directory. Using "File > Open Selected" may not, in this situation, find the file you would expect.

This patch alters NormalizePathname() and ParseFilename(), the utility functions that perform the expansion so that the base for relative file specifications can be passed, then changes all relevant calls to supply the current window's file path value. It includes the nmReadWriteRelToWin.diff adjustments to macro file functions read_file(), write_file() and append_file() for this same behaviour, and adds a new one, full_file_name(), which provides the macro writer with a way of obtaining the relative file name from a relative file path.

ReplaceSubString2.diff Modified: 2006-Oct-03 03:14:02

Allow the replace_substring() macro built-in to take three parameters

Avaliable as a patch:

http://sourceforge.net/tracker/index.php?func=detail&aid=1494174&group_id=11005&atid=311005
    [ 1494174 ] 3 argument version of replace_substring() macro built-in
    ReplaceSubString.diff 2006-05-24 06:36

This patch allows the macro programmer to drop the parameter providing the end position of the substring to replace. Normally replace_substring() is called as
    result = replace_substring(string, start, end, replacement)

This patch allows the call
    result = replace_substring(string, start, replacement)
to be the equivalent of
    result = replace_substring(string, start, length(string), replacement)

This patch also changes the behaviour of the function where negative values of start and end are provided, and where the start position is beyond the end position indicated. (These effects were never documented, so they can be assumed not to break well built macro programs.) The new handling matches that of changes made to the substring() built-in, checked in on 2005-02-11.

Now, negative values of start and end are treated as relative to the end of the first string argument (before negative values were reset to zero). Also, if the indicated start position is greater than the end position, the end position used is set to the start position, and the zero-length substring at the start position is replaced with the replacement string; essentially an insertion. This has the nice effect of not requiring an insert position to be specified twice; just set end to zero; instead of
    result = replace_substring(string, start, start, insert_piece)
to insert a piece of string, use
    result = replace_substring(string, start, 0, insert_piece)
Previously, if the start position was greater than the end position, the two positions would be swapped.

Finally, this patch corrects a small bug in the original code: if both string and replacement are provided to replace_substring() as integers, only the second would be used. For example, the call
    result = replace_substring(12345, 2, 3, 9876)
would give
    result == "9898766"
instead of
    result == "12987645"
which this patch produces.

RSunderlineStyle.diff Modified: 2008-Apr-07 23:59:57

Allow rangesets to be displayed underlined.

This patch depends on the UnderlineStyle.diff patch (or its derivative). APPLY THAT PATCH FIRST! This patch uses the syntax highlighting style's underlining mechanism (from the earlier patch) to provide an underline for a rangeset.

To apply underlining to a rangeset, use the following macro functioon:
    rangeset_set_underline(id, mode)
where mode is one of "leave" (don't change underlining from syntax highlighting's attributes), "remove" (don't show syntax highlighting underlines for the ranges of the set, and "add" (make sure all text in the rangeset is undelined). The ramgeset_info() function will return the underline mode keyword for a set.

search8191_2.diff Modified: 2006-Aug-14 14:40:54

Increase the size of a literal search string to 8191

Also switch order of compares for upper and lower case

2006-08-14

Modified to take into account new "official" buffer size of 5119 in CVS head.

selectionCountPatch3.diff Modified: 2007-Oct-17 18:58:06

Selected characters/rectangle statistics line feedback

Based on Arne Forlie's Selected character count patch

http://sourceforge.net/tracker/index.php?func=detail&aid=1043759&group_id=11005&atid=311005
    [ 1043759 ] Selected character count

This patch implements a continuously updated count of selected characters in the status line. It only works for normal selections (not for rectangular selections) and it doesn't work when quadruple clicking to select the whole file.

It is a response to feature request 1040294, which asked for something similar.

Augmented to show rectangle dimensions when a rectangular selection is active.

setWindowTitleFormat3.diff Modified: 2007-Jan-17 17:11:11

Allow a macro to set the document's window title or title format

This is done by allowing the document window to carry a custom version of the title format string. The new macro function, set_window_title_format(), is called as follows:
    set_window_title_format(string)
    set_window_title_format(string, "text")
    set_window_title_format(string, "format")
The string will be interpreted as a title format if the "format" keyword is supplied, or as a fixed title string otherwise. The format directives are those used in Preferences> Default Settings> Customize Window Title... dialog. If an empty string is used, the default format (from the Preferences) is applied.

ShellCommandOptInput.diff Modified: 2008-May-21 02:21:34

Make second argument to shell_command() optional

If missing, the command input argument to shell_command() is set to the empty string internally.

singleClickMacroEditing.diff Modified: 2008-Feb-27 01:46:09

Access macro editor with a shift-click

By shift+(mouse-)clicking on a macro or windows background menu item, you invoke the macro editor dialog. Very useful if, like me, you want to access these easily for frequent changes.

stringToNum.diff Modified: 2005-Oct-05 10:54:39

A new StringToNum() function without a call to sscanf()

It seems a shame to scan a string twice, as the older version does.

syncscroll-v2d.diff Modified: 2007-Oct-04 18:22:48

TK Soh's synchronised scrolling patch lets you scroll multiple split-panes and/or windows synchronously.

The original is available as a patch here:

http://sourceforge.net/tracker/index.php?func=detail&aid=774820&group_id=11005&atid=311005
    [ 774820 ] Synchronous Scrolling
    syncscroll-v1.diff.gz 2003-07-20 22:54

Synchronous scrolling occurs to split-panes and/or windows when the "Synchronous Scrolling" preference is enabled, when you scroll a sync-scrolling enabled window, by scrolling its vertical scrollbar, or through the wheelmouse.

2006-08-18

Updated to use a new action routine set_sync_scrolling([0|1]) and the corresponding macro variable $sync_scrolling. This patch is now also compatible with the tabbed interface.

2006-08-21

Made a small change to avoid crashes when scrolling help windows.

tagstack-nedit-5.5.-p0.diff Modified: 2005-Oct-20 16:21:05

TK Soh's extension to tag navigation: tagstack

This is a patch to add vim-like tagstack capability to NEdit. When you make a successful call to "Find Definition", the current window position is pushed into a LIFO stack before make jump, where you can later return the position by popping the tagstack.

http://sourceforge.net/tracker/?func=detail&aid=588380&group_id=11005&atid=311005
    [ 588380 ] tagstack

tinyMarksForWindowsTitles.diff Modified: 2008-Jan-19 01:16:41

Use minimal changed, locked and read-only title indicators

The short form of the locked and read-only indicators (previously "LO" and "RO") are now ":" and "!" to reduce titlebar/icon text length and avoid distraction from the filename itself.

toolbar-patch-v1_0b.diff Modified: 2006-Aug-16 20:03:54

TK Soh's Toolbar patch

Available as a patch here:

http://sourceforge.net/tracker/index.php?func=detail&aid=714489&group_id=11005&atid=311005
    [ 714489 ] toolbars
    nedit-toolbar-patch-v1.0b.txt.gz 2006-07-29 16:28

This patch adds toolbar below the main menu.

typeInReturnValue.diff Modified: 2006-Oct-21 03:15:39

Allow Smart Indent Type-in Macro to change typed text

Available as a patch:

http://sourceforge.net/tracker/index.php?func=detail&aid=1581640&group_id=11005&atid=311005
    [ 1581640 ] Allow Type-in Macro to change typed text
    typeInReturnValue.diff        2006-10-21 03:11

If the macro returns a string or integer, this value will be used in place of the original character typed, and inserted at the cursor's position after the macro's execution.

In particular, this allows for a return value of "" (the empty string), in which case no insert occurs after the macro.

This allows you to program (for example) word completion as part of the type-in macro process, without having to worry about dealing with left-over characters.

If no value is returned, the behaviour is as before.

UnderlineStyle3.diff Modified: 2008-Jan-14 17:29:14

Allows styles to specify the underlining of text.

This patch adds an "Underline" check box to the Text Drawing Styles dialog. If selected, it causes text of the corresponding style to be underlined.

The position of the underline for underlining is determined differently from the underline used for secondary selection, so you can distinguish between the two. The text-style underline is at the bottom of the glyphs' descenders whereas the secondary select underline is just below their baseline.

The underline flag is stored as the word "underline" in the nedit.rc saved preferences file. If missing, no underline attribute is registered.

vmclonewin-v2_3s.diff Modified: 2008-Mar-18 00:25:58

TK Soh's implementation of clonable windows

http://sourceforge.net/tracker/index.php?func=detail&aid=1180552&group_id=11005&atid=311005
    [ 1180552 ] MV's cloned windows

MV's cloned windows:

This is a port of Max Vohlken's window cloning patch, which is part of his original patch for NEdit 5.0.2.

Use the menu Windows->Clone Tab to create a new window, which is a clone of the invoking tab. Split panes will also be cloned.

The tabs, window and icon titles will reflect the clone status with an additional "<#>" appended to the filenames, with # being the index of the clone.

As of v1.0, you can't move or detach a clone, but we may expect this to change in the future version.

Have fun!

[modified to adjust for changing base source code]

zzzzzzzz.diff Modified: 2007-Nov-20 16:36:57

This is not a real patch, just a set of links to stuff I don't stay up to date with.