📄 readme
字号:
cooledit(1) cooledit(1) string status_input(string, string) Sets the status line to an entry widget with the first argument as the prompt string, and the second argument as the default text. Returns the entered text or None if Esc is pressed. (string, int) get_key() This blocks waiting for a key press, and grabs the application. It returns the string equivalent of the key press as in the X Window header file keysymdef.h without the XK_ prefix. It also returns the current state of the keyboard modifiers, being the inclusive or of ShiftMask ... etc. as listed above. The following function allows display of shell output as those in the Scripts menu. int shell_output(string, string, string) This displays the output of a shell command contin- uously in its own window in the background. As always, clicking on file:line type messages will cause the editor to jump to that file and line num- ber. The arguments are: the title of the output dialog, the shell program (which should begin with #!/bin/sh or similar), and a unique descriptive magic string that identifies the dialog. An example of a magic string is FindfIlEmAgiC used by the find file dialog - if you use the same magic string, then a new window will not be created if the find file display window exists. The following functions manipulate editor windows: (string, ...) get_editors() Returns a tuple with an entry for each editor win- dow. These are the full path names of the open files. set_editor(string) Sets the current editor with the full path name. This allows manipulation of a different edit buffer, but does not set input to that buffer. focus() Raises and the current editor window and sets the input focus to the current editor. close_window(int) Close the current edit window. If a non-zero value is passed, then this forces a close, regardless of whether the buffer is modified or not. 27 October 2001 21cooledit(1) cooledit(1) new_window() Create a new editor window with no text in it. load(string) Load a file into the current window. This will replace any text in the current edit window. The following are further miscellaneous commands: command(string) Executes an arbitrary editor command. These are listed in the Define Keys dialog. redraw_page() After the edit buffer has been modified, the window must refresh. Usually just the current line is redrawn. If you have made changes which may reflect a different display on other lines, then call redraw_page() before returning to ensure that the entire screen displays correctly. string file_type([string]) Forces the current file type as though you had selected it from the Options, Syntax highlight- ing... menu item. Forcing the type disables auto- matic file type selection for this window there- after. The old file type is returned. If no arguments are passed, file_type just returns the current file type. This is useful for creating actions specific to the type of text being edited. New syntax rule sets are being added all the time, but the passed and returns string is least one of: None Unified Diff Output Context Diff Output LSM File Shell Script Perl Program Python Program NROFF Source HTML File Pascal Program Ada Program LaTeX 2.09 Document Texinfo Document C/C++ Program SWIG Source Java Program SmallTalk Program ML Program 27 October 2001 22cooledit(1) cooledit(1) GNU Distribution ChangeLog File Makefile Mail folder Syntax Highlighting definitionsSYNTAX HIGHLIGHTING As of version 3.6.0, cooledit has syntax highlighting. This means that keywords and contexts (like C comments, string constants, etc) are highlighted in different colours. The following section explains the format of the file ~/.cedit/syntax. The file ~/.cedit/Syntax is rescanned on opening of any new editor file. It contains a list of file types and how to identify what rule set the text you are editing belongs to. The file token dictates how to match up your text. On the same line as a file token must appear a regular expression to match the filename, a string to be displayed on the left of the editor window for description purposes, and a regular expression to match the first line of the file. If either of the regular expressions match, the file is deemed to have the particular type. For example file ..\*\\.(py|PY])$ Python\sProgram ^#!\s\*/.\*/python Will cause a file to be labelled as Python Program if it contains say, #!/usr/bin/python, on the first line OR of it ends in say Note that *, + and \ have to be escaped with a \, and space must be presented with a \s. After the file keyword may come the include keyword. The include keyword says to load a rule set from a separate file, and is the preferred way of adding new rule sets. The path from where it loads defaults to cooledit/syntax/ under the lib/ directory where you installed Cooledit. See the examples in your own Syntax file and in this direc- tory. Each rule set is divided into contexts, and each context contains keyword definitions. A context is a scope within the text that a particular set of keywords applies to. For instance, the region within a C style quote (i.e. between " quotations) has its own separate colour and hence its own separate context. Within it, the normal C tokens, like if and while, will not apply, but %d should be highlighted in a different colour. Contexts are usually for when you have something that must be coloured across multiple lines. The default context contains the list of keywords to fall back on should there be no other applicable con- text. This is usually normal programming code. 27 October 2001 23cooledit(1) cooledit(1) A trivial C programming rule set might look like this: file .\*\\.c C\sProgram\sFile (#include|/\\\*) wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_ # default colors context default keyword whole if yellow/24 keyword whole else yellow/24 keyword whole for yellow/24 keyword whole while yellow/24 keyword whole do yellow/24 keyword whole switch yellow/24 keyword whole case yellow/24 keyword whole static yellow/24 keyword whole extern yellow/24 keyword { brightcyan/14 keyword } brightcyan/14 keyword '*' green/6 # C comments context /\* \*/ brown/22 # C preprocessor directives context linestart # \n brightred/18 keyword \\\n yellow/24 # C string constants context " " green/6 keyword %d yellow/24 keyword %s yellow/24 keyword %c yellow/24 keyword \\" yellow/24 Each context starts with a line of the form: context [exclusive] [whole|wholeright|wholeleft] [lines- tart] delim [linestart] delim [foreground] [background] One exception is the first context. It must start with the command context default [foreground] [background] or else cooledit will return an error. The linestart option dictates that delim must start at the beginning of a line. The whole option tells that delim must be a whole word. What constitutes a whole word are a set of characters that can be changed at any point in the file with the wholechars command. The wholechars command at the top just sets the set exactly to its default and could therefore have been omitted. To specify that a word must be whole on the left only, you can use the wholeleft option, and 27 October 2001 24cooledit(1) cooledit(1) similarly on the right. The left and right set of charac- ters can be set separately with, wholechars [left|right] characters The exclusive option causes the text between the delim- iters to be colourised, but not the delimiters themselves. Each rule is a line of the form: keyword [whole|wholeright|wholeleft] [linestart] string foreground [background] Important to note is the line keyword \\\n yellow/24 This line defines a keyword containing the \ and newline characters. Because keywords have a higher precedence than context delimiters, this keyword prevents the context from ending at the end of a line if the line ends in a \ thus allowing C preprocessor directive to continue across multiple lines. The colours themselves need to apply to the Midnight Com- mander internal editor as well as to Cooledit. Therefore the form midnight-commander-color/cooledit-color is used. See some of the many rule sets given, for exam- ples on using this. Usually the background colour is omit- ted, thus defaulting to the usual background colour. Context or keyword strings are interpreted so that you can include tabs and spaces with the sequences \t and \s. New- lines and the \ are specified with \n and \\ respectively. Since whitespace is used as a seperator, it may not be used explicitedly. Also, \* must be used to specify a *, and a \+ to specify a +. The * itself is a wildcard that matches any length of characters. The + is like the * but matches a length of non-whitespace characters only. For example, keyword '+' green/6 keyword '\s' green/6 colours all C single character constants green. You could also have used keyword "*" green/6 to colour string constants, except that the matched string may not cross newlines. The \{ wild card matches any characters that exists between it and its matching \}. For example, the following matches C style octals: keyword '\\\{0123\}\{01234567\}\{01234567\}' brightgreen/16 The \[ \] wild card is similar and matches any number of characters. All wild cards may be used within context delimiters as 27 October 2001 25cooledit(1) cooledit(1) well, but you cannot have a wildcard as the first charac- ter of a context delimiter. In addition, using a wildcard as the first character of a keyword, impacts hugely on performance. The colours themselves are numbered 0 to 26 and are explained below in FURTHER BEHAVIOUR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -