re-fresh
[nedit-bw.git] / nmvarNEDIT_HOME2.diff
blob338ac2c26ad1c623547d5181d96b9a12f96d7025
1 From: Thorsten Haude <yoo@vranx.de>
2 Subject: New NEdit Macro variables $NEDIT_HOME
4 Part of "patch collection", see
6 http://sourceforge.net/tracker/index.php?func=detail&aid=1058246&group_id=11005&atid=311005
7 [ 1058246 ] Patch Collection
9 2006-11-22
11 Updaed to track CVS Head,
13 ---
15 doc/help.etx | 6 ++++++
16 source/built-ins.h | 1 +
17 source/highlightData.c | 2 +-
18 source/macro.c | 15 +++++++++++++++
19 source/nedit.c | 11 +++++++++++
20 util/utils.c | 16 ++++++++++++++++
21 util/utils.h | 1 +
22 7 files changed, 51 insertions(+), 1 deletion(-)
24 diff --quilt old/source/macro.c new/source/macro.c
25 --- old/source/macro.c
26 +++ new/source/macro.c
27 @@ -4458,6 +4458,21 @@ static int versionMV(WindowInfo* window,
31 +** Returns the name of the directory where NEdit's run control files reside.
32 +** This is either the value of the environmental variable $NEDIT_HOME, the
33 +** default of ~/.nedit or $HOME. (See the online documentation for details
34 +** about the algorithm.)
35 +*/
36 +static int neditHomeMV(WindowInfo *window, DataValue *argList, int nArgs,
37 + DataValue *result, char **errMsg)
39 + result->tag = STRING_TAG;
40 + AllocNStringCpy(&result->val.str, GetNEditHome());
42 + return True;
45 +/*
46 ** Built-in macro subroutine to create a new rangeset or rangesets.
47 ** If called with one argument: $1 is the number of rangesets required and
48 ** return value is an array indexed 0 to n, with the rangeset labels as values;
49 diff --quilt old/doc/help.etx new/doc/help.etx
50 --- old/doc/help.etx
51 +++ new/doc/help.etx
52 @@ -2538,6 +2538,12 @@ Macro Subroutines
53 **$VERSION**
54 Returns NEdit's version number ('5006' for NEdit 5.6).
56 +**$NEDIT_HOME**
57 + Returns the name of the directory where NEdit's run control files reside.
58 + This is either the value of the environmental variable $NEDIT_HOME, the
59 + default of ~/.nedit or $HOME. (See Preferences_ for details
60 + about the algorithm.)
62 **$n_display_lines**
63 The number of lines visible in the currently active pane.
65 diff --quilt old/source/highlightData.c new/source/highlightData.c
66 --- old/source/highlightData.c
67 +++ new/source/highlightData.c
68 @@ -548,7 +548,7 @@ static char *DefaultPatternSets[] = {
69 "NEdit Macro:2:0{\n\
70 README:\"NEdit Macro syntax highlighting patterns, version 2.6, maintainer Thorsten Haude, nedit at thorstenhau.de\":::Flag::D\n\
71 Comment:\"#\":\"$\"::Comment::\n\
72 - Built-in Misc Vars:\"(?<!\\Y)\\$(?:active_pane|calltip_ID|column|cursor|display_width|empty_array|file_name|file_path|language_mode|line|locked|max_font_width|min_font_width|modified|n_display_lines|n_panes|rangeset_list|read_only|selection_(?:start|end|left|right)|server_name|text_length|top_line|VERSION)>\":::Identifier::\n\
73 + Built-in Misc Vars:\"(?<!\\Y)\\$(?:active_pane|calltip_ID|column|cursor|display_width|empty_array|file_name|file_path|language_mode|line|locked|max_font_width|min_font_width|modified|n_display_lines|n_panes|rangeset_list|read_only|selection_(?:start|end|left|right)|server_name|text_length|top_line|VERSION|NEDIT_HOME)>\":::Identifier::\n\
74 Built-in Pref Vars:\"(?<!\\Y)\\$(?:auto_indent|em_tab_dist|file_format|font_name|font_name_bold|font_name_bold_italic|font_name_italic|highlight_syntax|incremental_backup|incremental_search_line|make_backup_copy|match_syntax_based|overtype_mode|show_line_numbers|show_matching|statistics_line|tab_dist|use_tabs|wrap_margin|wrap_text)>\":::Identifier2::\n\
75 Built-in Special Vars:\"(?<!\\Y)\\$(?:args|[1-9]|list_dialog_button|n_args|read_status|search_end|shell_cmd_status|string_dialog_button|sub_sep)>\":::String1::\n\
76 Built-in Subrs:\"<(?:args|append_file|beep|call|calltip|clipboard_to_string|dialog|filename_dialog|focus_window|get_character|get_pattern_(by_name|at_pos)|get_range|get_selection|get_style_(by_name|at_pos)|getenv|kill_calltip|length|list_dialog|max|min|n_args|rangeset_(?:add|create|destroy|get_by_name|includes|info|invert|range|set_color|set_mode|set_name|subtract)|read_file|replace_in_string|replace_range|replace_selection|replace_substring|search|search_string|select|select_rectangle|set_cursor_pos|shell_command|split|string_compare|string_dialog|string_to_clipboard|substring|t_print|tolower|toupper|valid_number|write_file)(?=\\s*\\()\":::Subroutine::\n\
77 diff --quilt old/source/built-ins.h new/source/built-ins.h
78 --- old/source/built-ins.h
79 +++ new/source/built-ins.h
80 @@ -112,3 +112,4 @@ MV($backlight_string, backlightString)
82 MV(rangeset_list, rangesetList)
83 MV(VERSION, version)
84 +MV(NEDIT_HOME, neditHome)
85 diff --quilt old/source/nedit.c new/source/nedit.c
86 --- old/source/nedit.c
87 +++ new/source/nedit.c
88 @@ -53,6 +53,7 @@ static const char CVSID[] = "$Id: nedit.
89 #include "../util/fileUtils.h"
90 #include "../util/getfiles.h"
91 #include "../util/motif.h"
92 +#include "../util/utils.h"
94 #include <ctype.h>
95 #include <limits.h>
96 @@ -486,6 +487,16 @@ int main(int argc, char **argv)
97 fixupBrokenXKeysymDB();
98 patchResourcesForVisual();
99 patchResourcesForKDEbug();
101 + /* export NEDIT_HOME into the environment, force override */
103 + char *neditHomeVar;
104 + size_t len = strlen("NEDIT_HOME=") + strlen(GetNEditHome()) + 1;
105 + neditHomeVar = XtMalloc(len);
106 + strcpy(neditHomeVar, "NEDIT_HOME=");
107 + strcat(neditHomeVar, GetNEditHome());
108 + putenv(neditHomeVar);
111 /* Initialize global symbols and subroutines used in the macro language */
112 InitMacroGlobals();
113 diff --quilt old/util/utils.c new/util/utils.c
114 --- old/util/utils.c
115 +++ new/util/utils.c
116 @@ -27,6 +27,7 @@ static const char CVSID[] = "$Id: utils.
117 #endif
119 #include "utils.h"
120 +#include "fileUtils.h"
122 #include <stdlib.h>
123 #include <stdio.h>
124 @@ -63,6 +64,8 @@ static void buildFilePath(char* fullPath
125 static Boolean isDir(const char* file);
126 static Boolean isRegFile(const char* file);
128 +static char neditHome[MAXPATHLEN+1];
130 /* return non-NULL value for the current working directory.
131 If system call fails, provide a fallback value */
132 const char* GetCurrentDir(void)
133 @@ -321,6 +324,8 @@ const char* GetRCFileName(int type)
137 + ParseFilename(rcFiles[0], NULL, neditHome);
139 namesDetermined = True;
142 @@ -393,6 +398,17 @@ static Boolean isRegFile(const char* fil
146 +** return the value of NEDIT_HOME
148 +const char *GetNEditHome(void)
150 + /* GetRCFileName fills in neditHome, so call it */
151 + GetRCFileName(NEDIT_RC);
153 + return neditHome;
157 ** Part of the simple stack. Accepts a stack and the pointer you want to
158 ** store. NULL is not allowed, as it is used in Pop() to signal an empty
159 ** stack.
160 diff --quilt old/util/utils.h new/util/utils.h
161 --- old/util/utils.h
162 +++ new/util/utils.h
163 @@ -44,6 +44,7 @@ const char *GetUserName(void);
164 const char *GetNameOfHost(void);
165 int Min(int i1, int i2);
166 const char* GetRCFileName(int type);
167 +const char* GetNEditHome(void);
170 ** Simple stack implementation which only keeps void pointers.