1 # Create a file named autoload.nm in your (NEDIT_)HOME directory, cf. the NEdit
2 # help, and load this file with the load_macro_file() function.
3
4
5 # Some COMPATIBILITY issues
6
7 #for compatibility with Windows paths
8 define path2win {
9 path = $1
10 start = search_string(path,"/cygdrive/c",0)
11 path = "c:" substring(path,$search_end, length(path))
12 t= replace_in_string(path,"/","\\\\")
13 if (t!="") {
14 path = t
15 }
16
17 return(path)
18 }
19
20 # for filtering out when interacting with Windows applications
21 # takes a string and deletes all in it
22 define remove_cr {
23 if (search_string($1, "\r", 0) != -1) {
24 return(replace_in_string($1,"\r",""))
25 }
26 else {
27 return($1)
28 }
29
30 }
31
32 # To workaround a Cygwin BUG with filtering
33 # Cygwin refuses to read the standard streams reliably through the Xt
34 # callbacks in shell.c
35 # This function pipes the output of a filter in a temporary file and reads
36 # it back into the buffer (this is quick and dirty, just as Vim does it)
37 define filtering_on_cygwin {
38 path = getenv("HOME") #"/nedata/"
39 if ($n_args != 2) {
40 dialog("Wrong number of parameters! Canceling.")
41 return ""
42 }
43 command = $1
44 input = $2
45 file_in = path "tmp_in"
46 file_out = path "tmp_out"
47 write_file(input, file_in)
48 shell_command(command " < " file_in " > " file_out, "")
49 #dialog($shell_cmd_status)
50 if ($shell_cmd_status == 0) {
51 output = remove_cr(read_file(file_out))
52 if ($read_status == 1) {
53 #clean up
54 write_file("", file_in)
55 write_file("", file_out)
56 return(output)
57 }
58 }
59 dialog("Something failed")
60 }
61
62 define lesstif_bug {
63 if ($wrap_text == "continuous") {
64 # in 5.5 renamed to split_pane() !!!
65 split_pane()
66 close_pane()
67 }
68 }
69