📄 macro_subrs.html
字号:
position, and it guarantees that the tip will appear on-screen somewhere evenif the cursor is not. The upper-left corner of the calltip will appear belowwhere the cursor would appear if it were at this position. <mode> is one of"tipText" (default), "tipKey", or "tagKey". "tipText" displays the text as-is,"tagKey" uses it as the key to look up a tag, then converts the tag to acalltip, and "tipKey" uses it as the key to look up a calltip, then falls backto "tagKey" behavior if that fails. You'll usually use "tipKey" or "tipText".Finally, you can modify the placement of the calltip relative to the cursorposition (or <pos>) with one or more of these optional position modifiers:"center" aligns the center of the calltip with the position. "right" alignsthe right edge of the calltip with the position. ("center" and "right" may not both be used.) "above" places the calltip above the position. "strict"does not allow the calltip to move from its position in order to avoid going off-screen or obscuring the cursor. Returns the ID of the calltip if it was found and/or displayed correctly, 0 otherwise.</P><P><PRE><B>clipboard_to_string()</B> </PRE>Returns the contents of the clipboard as a macro string. Returns emptystring on error.</P><P><PRE><B>dialog( message, btn_1_label, btn_2_label, ... )</B> </PRE>Pop up a dialog for querying and presenting information to the user. Firstargument is a string to show in the message area of the dialog. Up to eightadditional optional arguments represent labels for buttons to appear alongthe bottom of the dialog. Returns the number of the button pressed (thefirst button is number 1), or 0 if the user closed the dialog via the windowclose box.</P><P><PRE><B>focus_window( window_name )</B> </PRE>Sets the window on which subsequent macro commands operate. window_name canbe either a fully qualified file name, or one of "last" for the last windowcreated, or "next" for the next window in the chain from the currentlyfocused window (the first window being the one returned from callingfocus_window("last"). Returns the name of the newly-focused window, or anempty string if the requested window was not found.</P><P><PRE><B>get_character( position )</B> </PRE>Returns the single character at the positionindicated by the first argument to the routine from the current window.</P><P><PRE><B>get_range( start, end )</B> </PRE>Returns the text between a starting and ending position from the currentwindow.</P><P><PRE><B>get_selection()</B> </PRE>Returns a string containing the text currently selected by the primaryselection either from the current window (no keyword), or from anywhere onthe screen (keyword "any").</P><P><PRE><B>getenv( name )</B></PRE>Gets the value of an environment variable.</P><P><PRE><B>kill_calltip( [calltip_ID] )</B></PRE>Kills any calltip that is being displayed in the window in which the macro isrunning. If there is no displayed calltip this does nothing. If a calltipID is supplied then the calltip is killed only if its ID is calltip_ID.</P><P><PRE><B>length( string )</B></PRE>Returns the length of a string</P><P><PRE><B>list_dialog( message, text, btn_1_label, btn_2_label, ... )</B> </PRE>Pop up a dialog for prompting the user to choose a line from the given textstring. The first argument is a message string to be used as a title for thefixed text describing the list. The second string provides the list data:this is a text string in which list entries are separated by newlinecharacters. Up to seven additional optional arguments represent labels forbuttons to appear along the bottom of the dialog. Returns the line of textselected by the user as the function value (without any newline separator) orthe empty string if none was selected, and number of the button pressed (thefirst button is number 1), in $list_dialog_button. If the user closes thedialog via the window close box, the function returns the empty string, and$list_dialog_button returns 0.</P><P><PRE><B>max( n1, n2, ... )</B></PRE>Returns the maximum value of all of its arguments</P><P><PRE><B>min( n1, n2, ... )</B></PRE>Returns the minimum value of all of its arguments</P><P><PRE><B>read_file( filename )</B> </PRE>Reads the contents of a text file into a string. On success, returns 1 in$read_status, and the contents of the file as a string in the subroutinereturn value. On failure, returns the empty string "" and an 0 $read_status.</P><P><PRE><B>replace_in_string( string, search_for, replace_with [, type, "copy"] )</B> </PRE>Replaces all occurrences of a search string in a string with a replacementstring. Arguments are 1: string to search in, 2: string to search for, 3:replacement string. There are two optional arguments. One is a search type, either "literal", "case", "word", "caseWord", "regex", or "regexNoCase". The default search type is "literal". If the optional "copy" argument isspecified, a copy of the input string is returned when no replacements wereperformed. By default an empty string ("") will be returned in this case.Returns a new string with all of the replacements done.</P><P><PRE><B>replace_range( start, end, string )</B> </PRE>Replaces all of the text in the current window between two positions.</P><P><PRE><B>replace_selection( string )</B> </PRE>Replaces the primary-selection selected text in the current window.</P><P><PRE><B>replace_substring( string, start, end, replace_with )</B> </PRE>Replacing a substring between two positions in a string within another string.</P><P><PRE><B>search( search_for, start [, search_type, wrap, direction] )</B> </PRE>Searches silently in a window without dialogs, beeps, or changes to theselection. Arguments are: 1: string to search for, 2: starting position.Optional arguments may include the strings: "wrap" to make the search wraparound the beginning or end of the string, "backward" or "forward" to changethe search direction ("forward" is the default), "literal", "case", "word","caseWord", "regex", or "regexNoCase" to change the search type (default is"literal"). Returns the starting position of the match, or -1 if nothingmatched. Also returns the ending position of the match in $search_end.</P><P><PRE><B>search_string( string, search_for, start [, search_type, direction] )</B> </PRE></P><P>Built-in macro subroutine for searching a string. Arguments are 1: string tosearch in, 2: string to search for, 3: starting position. Optional argumentsmay include the strings: "wrap" to make the search wrap around the beginningor end of the string, "backward" or "forward" to change the search direction("forward" is the default), "literal", "case", "word", "caseWord", "regex",or "regexNoCase" to change the search type (default is "literal"). Returnsthe starting position of the match, or -1 if nothing matched. Also returnsthe ending position of the match in $search_end.</P><P><PRE><B>select( start, end )</B> </PRE>Selects (with the primary selection) text in the current buffer between astarting and ending position.</P><P><PRE><B>select_rectangle( start, end, left, right )</B> </PRE>Selects a rectangular area of text between a starting and ending position,and confined horizontally to characters displayed between positions "left",and "right".</P><P><PRE><B>set_cursor_pos( position )</B></PRE>Set the cursor position for the current window.</P><P><PRE><B>shell_command( command, input_string )</B> </PRE>Executes a shell command, feeding it input from input_string. On completion,output from the command is returned as the function value, and the command'sexit status is returned in the global variable $shell_cmd_status.</P><P><PRE><B>split(string, separation_string [, search_type])</B></PRE>Splits a string using the separator specified. Optionally the search_typeargument can specify how the separation_string is interpreted. The default is "literal". The returned value is an array with keys beginning at 0.</P><P><PRE><B>string_dialog( message, btn_1_label, btn_2_label, ... )</B> </PRE>Pops up a dialog prompting the user to enter information. The first argumentis a string to show in the message area of the dialog. Up to nine additionaloptional arguments represent labels for buttons to appear along the bottom ofthe dialog. Returns the string entered by the user as the function value,and number of the button pressed (the first button is number 1), in$string_dialog_button. If the user closes the dialog via the window closebox, the function returns the empty string, and $string_dialog_button returns0.</P><P><PRE><B>string_compare(string1, string2 [, consider-case])</B></PRE>Compare two strings and return 0 if they are equal, -1 if string1 is lessthan string2 or 1 if string1 is greater than string2. The values for theoptional consider-case argument is either "case" or "nocase". The default is to do a case sensitive comparison.</P><P><PRE><B>string_to_clipboard( string )</B> </PRE>Copy the contents of a macro string to the clipboard.</P><P><PRE><B>substring( string, start, end )</B> </PRE>Returns the portion of a string between a starting and ending position.</P><P><PRE><B>t_print( string1, string2, ... )</B> </PRE>Writes strings to the terminal (stdout) from which NEdit was started.</P><P><PRE><B>tolower( string )</B></PRE>Return an all lower-case version of string.</P><P><PRE><B>toupper( string )</B></PRE>Return an all upper-case version of string.</P><P><PRE><B>valid_number( string )</B></PRE>Returns 1 if the string can be converted to a number without errorfollowing the same rules that the implicit conversion would. Otherwise 0.</P><P><PRE><B>write_file( string, filename )</B> </PRE>Writes a string (parameter 1) to a file named in parameter 2. Returns 1 onsuccessful write, or 0 if unsuccessful.</P><P><H3>Deprecated Functions</H3></P><P>Some functions are included only for supporting legacy macros. You should notuse any of these functions in any new macro you write. Among these are allaction routines with hyphens in their names; use underscores instead('find-dialog' -> 'find_dialog').</P><P><PRE><B>match()</B></PRE><B>DEPRECATED</B> Use select_to_matching() instead.</P><P><P><HR></P><P></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -