📄 cooledit.1
字号:
As an example, the find file dialog can be reproduced as follows:.RE.PP.nfx = generic_dialog ("Find file", \\ (".", "*.[ch]", ""), \\ ( "Starting directory", \\ "Filenames matching glob expression", \\ "Containing" ), \\ ( "find-start_dir", \\ "find-glob_express", \\ "find-containing" ), \\ ( "Starting directory for the recursive search", \\ "Glob expressions such as *.[ch] or *.doc", \\ "Check if file contains this sequence" ), \\ (0, 0, 0, 0), \\ ( "Containing reg. exp.", \\ "Containing case insens.", \\ "Search follows symlinks", \\ "Search is case insens." ), \\ ( "Enter regular expression pattern to find within file", \\ "Match case insensitively when searching within files", \\ "Dive into symlinks to directories", \\ "Filenames are matched case insensitively" ), \\ 60, INPUTS_WITH_OPTIONS_BROWSE_DIR_1 \\)if x: inputs = x[1] checks = x[2].fi.PPThe following are more simplistic utility dialogs:.TP\fIstring\fP \fBinput_dialog(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fIstring\fP\fB)\fPBrings up an input dialog. Takes a title, prompt string and defaultvalue as input. Returns the entered string or \fBNone\fP if cancelled..TP\fIstring\fP \fBsave_file_dialog(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fIstring\fP\fB)\fPBrings up a file browser dialog. Takes a title, a starting directoryand a default value as input. Returns the entered string or \fBNone\fPif cancelled..TP\fIstring\fP \fBload_file_dialog(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fIstring\fP\fB)\fPThis has a slightly different behaviour to \fBsave_file_dialog\fP - if anon existing file is entered, it reports an error..TP\fBmessage_dialog(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB)\fPBrings up a message dialog with the given title and message..TP\fBerror_dialog(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB)\fPBrings up an error dialog with the given title and message..TP\fIint\fP \fBquery_dialog(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fI...\fP\fB)\fPBrings up a query dialog. Takes a header, a prompt and a number ofalternative buttons. Returns the button number or -1 on cancel..TP\fBstatus(\fP\fIstring\fP\fB)\fPSets the status line of the current editor. The status line will returnto its usual when a key is pressed. This can be used with \fBgetkey()\fPto inform the user of possible key presses..TP\fIstring\fP \fBstatus_input(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB)\fPSets the status line to an entry widget with the first argument as theprompt string, and the second argument as the default text. Returnsthe entered text or \fBNone\fP if Esc is pressed..TP\fB(\fP\fIstring\fP\fB,\fP \fIint\fP\fB)\fP \fBget_key()\fPThis blocks waiting for a key press, and grabs the application. Itreturns the string equivalent of the key press as in the X Window headerfile \fBkeysymdef.h\fP without the \fBXK_\fP prefix. It also returnsthe current state of the keyboard modifiers, being the inclusive orof \fBShiftMask ... \fP etc. as listed above..PPThe following function allows display of shell output as those inthe \fBScripts\fP menu..TP\fIint\fP \fBshell_output(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fIstring\fP\fB)\fP.RSThis displays the output of a shell command continuously in its ownwindow in the background. As always, clicking on \fIfile\fP:\fIline\fPtype messages will cause the editor to jump to that file and linenumber..PPThe arguments are: the title of the output dialog, the shell program(which should begin with \fB#!/bin/sh\fP or similar), and a uniquedescriptive magic string that identifies the dialog. An example of amagic string is \fBFindfIlEmAgiC\fP used by the find file dialog - ifyou use the same magic string, then a new window will not be created ifthe find file display window exists..RE.PPThe following functions manipulate editor windows:.TP\fB(\fP\fIstring\fP\fB,\fP \fI...\fP\fB)\fP \fBget_editors()\fPReturns a tuple with an entry for each editor window. These are thefull path names of the open files..TP\fBset_editor(\fP\fIstring\fP\fB)\fPSets the current editor with the full path name. This allowsmanipulation of a different edit buffer, but does not set input to thatbuffer..TP\fBfocus()\fPRaises and the current editor window and sets the input focus to thecurrent editor..TP\fBclose_window(\fP\fIint\fP\fB)\fPClose the current edit window. If a non-zero value is passed, then thisforces a close, regardless of whether the buffer is modified or not..TP\fBnew_window()\fPCreate a new editor window with no text in it..TP\fBload(\fP\fIstring\fP\fB)\fPLoad a file into the current window. This will replace any text in thecurrent edit window..PPThe following are further miscellaneous commands:.TP\fBcommand(\fP\fIstring\fP\fB)\fPExecutes an arbitrary editor command. These are listed in the \fBDefineKeys\fP dialog..TP\fBredraw_page()\fPAfter the edit buffer has been modified, the window must refresh.Usually just the current line is redrawn. If you have made changes whichmay reflect a different display on other lines, then call\fBredraw_page()\fP before returning to ensure that the entire screendisplays correctly..TP\fIstring\fP \fBfile_type(\fP\fI[string]\fP\fB)\fP.RSForces the current file type as though you had selected it fromthe \fBOptions\fP, \fBSyntax highlighting...\fP menu item.Forcing the type disables automatic file type selection for thiswindow thereafter. The old file type is returned.If no arguments are passed, \fBfile_type\fP just returns thecurrent file type. This is useful for creating actions specificto the type of text being edited.New syntax rule sets are being added all thetime, but the passed and returns string is least one of:.PP\fB.nfNoneUnified Diff OutputContext Diff OutputLSM FileShell ScriptPerl ProgramPython ProgramNROFF SourceHTML FilePascal ProgramAda ProgramLaTeX 2.09 DocumentTexinfo DocumentC/C++ ProgramSWIG SourceJava ProgramSmallTalk ProgramML ProgramGNU Distribution ChangeLog FileMakefileMail folderSyntax Highlighting definitions.fi\fP.RE.PP.SH SYNTAX HIGHLIGHTINGAs of version 3.6.0, \fBcooledit\fP has syntax highlighting. This meansthat keywords and contexts (like C comments, string constants, etc) arehighlighted in different colours. The following section explains theformat of the file \fB~/.cedit/syntax\fP.The file \fB~/.cedit/Syntax\fP is rescanned on opening of any new editorfile. It contains a list of file types and how to identify what rule setthe text you are editing belongs to. The \fBfile\fP token dictates howto match up your text. On the same line as a \fBfile\fP token mustappear a regular expression to match the filename, a string to bedisplayed on the left of the editor window for description purposes, anda regular expression to match the first line of the file. If either ofthe regular expressions match, the file is deemed to have the particulartype. For example.PP.nffile ..\\*\\\\.(py|PY])$ Python\\sProgram ^#!\\s\\*/.\\*/python.fi.PPWill cause a file to be labelled as \fBPython Program\fP if it containssay, \fB#!/usr/bin/python\fP, on the first line OR of it ends in say\fB.py\fP.Note that \fB*\fP, \fB+\fP and \fB\\\fP have to be escaped witha \fB\\\fP, and space must be presented with a \fB\\s\fP.After the \fBfile\fP keyword may come the \fBinclude\fP keyword. The\fBinclude\fP keyword says to load a rule set from a separate file, andis the preferred way of adding new rule sets. The path from where itloads defaults to \fBcooledit/syntax/\fP under the \fBlib/\fP directorywhere you installed \fBCooledit\fP. See the examples in your own\fBSyntax\fP file and in this directory.Each rule set is divided into contexts, and each context containskeyword definitions. A context is a scope within the text that aparticular set of keywords applies to. For instance, the region within aC style quote (i.e. between \fB"\fP quotations) has its own separatecolour and hence its own separate context. Within it, the normal Ctokens, like \fBif\fP and \fBwhile\fP, will not apply, but \fB%d\fPshould be highlighted in a different colour. Contexts are usually forwhen you have something that must be coloured across multiple lines. The\fBdefault\fP context contains the list of keywords to fall back onshould there be no other applicable context. This is usually normalprogramming code.A trivial C programming rule set might look like this:.PP.nffile .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_# default colorscontext 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 commentscontext /\\* \\*/ brown/22# C preprocessor directivescontext linestart # \\n brightred/18 keyword \\\\\\n yellow/24# C string constantscontext " " green/6 keyword %d yellow/24 keyword %s yellow/24 keyword %c yellow/24 keyword \\\\" yellow/24.fi.PPEach context starts with a line of the form:.br\fBcontext\fP [\fBexclusive\fP] [\fBwhole\fP|\fBwholeright\fP|\fBwholeleft\fP] [\fBlinestart\fP] \fIdelim\fP [\fBlinestart\fP] \fIdelim\fP [\fIforeground\fP] [\fIbackground\fP].brOne exception is the first context. It must start with the command.br\fBcontext\fP \fBdefault\fP [\fIforeground\fP] [\fIbackground\fP].bror else \fBcooledit\fP will return an error.The \fBlinestart\fP option dictates that \fIdelim\fP must start atthe beginning of a line.The \fBwhole\fP option tells that delim must be a whole word. Whatconstitutes a whole word are a set of characters that can bechanged at any point in the file with the \fBwholechars\fPcommand. The \fBwholechars\fP command at the top just sets theset exactly to its default and could therefore have been omitted. Tospecify that a word must be whole on the left only, you can usethe \fBwholeleft\fP option, and similarly on the right. The left andright set of characters can be set separately with,.br\fBwholechars\fP [\fBleft\fP|\fBright\fP] \fIcharacters\fPThe \fBexclusive\fP option causes the text between the delimiters to becolourised, but not the delimiters themselves.Each rule is a line of the form:.br\fBkeyword\fP [\fBwhole\fP|\fBwholeright\fP|\fBwholeleft\fP] [\fBlinestart\fP] \fIstring\fP \fIforeground\fP [\fIbackground\fP].brImportant to note is the line.nf\fB keyword \\\\\\n yellow/24\fP.fiThis line defines a keyword containing the \\ and newline characters.Because keywords have a higher precedence than context delimiters, thiskeyword prevents the context from ending at the end of a line if theline ends in a \\ thus allowing C preprocessor directive to continueacross multiple lines.The colours themselves need to apply to the Midnight Commander internaleditor as well as to \fBCooledit\fP. Therefore the form.br \fImidnight-commander-color\fP\fB/\fP\fIcooledit-color\fP.bris used. See some of the many rule sets given, for examples on usingthis. Usually the background colour is omitted, thus defaulting to theusual background colour.Context or keyword strings are interpreted so that you can include tabsand spaces with the sequences \\t and \\s. Newlines and the \\ arespecified with \\n and \\\\ respectively. Since whitespace is used as aseperator, it may not be used explicitedly. Also, \\* must be used tospecify a *, and a \\+ to specify a +. The * itself is a wildcard thatmatches any length of characters. The + is like the * but matches alength of non-whitespace characters only. For example,.nf\fB keyword '+' green/6\fP\fB keyword '\\s' green/6\fP.fi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -