⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cooledit.1

📁 具有IDE功能的编辑器
💻 1
📖 第 1 页 / 共 5 页
字号:
Everything else you need to know is obvious from the menu. You would dowell to read gdb's info pages if you have never used a debugger underUnix before..PP.SH PYTHON MACRO PROGRAMMINGAs of version 3.8.0, \fBCooledit\fP has a builtin \fBPython\fP interpretor.This means that \fBCooledit\fP can execute arbitrary \fBPython\fP scriptsfrom within its environment and bind scripts to keys and so forth. Thisis analogous to the way that \fBEmacs\fP uses a \fBLisp\fP interpretor.\fBPython\fP is an object orientated scripting language like java, butwith a much saner syntax. It is used for \fIRapid Application Development\fP,and as a replacement for other intepretor languages like \fBPerl\fP, \fBTcl\fP and \fBLisp\fP.On startup, \fBCooledit\fP reads the top level \fBPython\fP file\fBlib/cooledit/global.py\fP, and then the user's personal file\fB~/.cedit/global.py\fP. Any \fBPython\fP code can go into thesefiles. No other files are explicitely read, but the code within\fBglobal.py\fP will call other \fBPython\fP files. The location ofthe directory \fBlib/cooledit/\fP is dependant on your installationand is added to the default search path for modules.To learn to program in \fBPython\fP, consult the tutorials andreference manuals that come with the \fBPython\fP sources.One of the reasons for the python interpretor is to enable emulation ofother editors such as \fBvi\fP and \fBEmacs\fP. It is quite feasable towrite python scripts that will emulate all of the functions of theseeditors, and have user dialogs and menu items to switch betweendifferent editor emulations....PP.nfdef get_ctrl_x_key():    status ("\\034Press \\030s\\033\\035")    k, m = get_key ()    if m == 0:        if k == "s":            command (Save_As)key ("x", ControlMask, "get_ctrl_x_key()").fi.PPThe \\034 and \\035 means to draw a bevel around the enclosed text. Theother escape characters cause colour changes (1 - 26, 27 = black)..PPAnother powerful capacity is to have utilities specific to theparticular file type that is being edited. When the type of an editwindow is changed, the function \fBtype_change()\fP from the\fBglobal.py\fP script is run. This function must run an appropriatefile for the given file type which defines keys and creates menu itemsin that window's \fBUtil\fP menu.The following low level function are defined for manipulating the editbuffers. The functions operate on the current edit buffer. This isusually the one with the focus..TP\fBmove(\fP\fIint\fP\fB)\fPMoves the cursor relative to its current position in units of one character..TP\fBmove_to(\fP\fIint\fP\fB)\fPMoves the cursor to an absolute position in the buffer..TP\fBmove_lines(\fP\fIint\fP\fB)\fPMoves the cursor relative to its current position up or down..TP\fIint\fP \fBbuffer_size()\fPReturns the size in bytes of the edit buffer..TP\fBinsert(\fP\fIstring\fP\fB)\fPTypes out the given string at the current cursor position..TP\fBindent(\fP\fI[int]\fP\fB)\fPInserts tabs and spaces according to the current half-tab and tabsettings. The inserted margin copies the margin from the first non-blankline above the current line. If an argument is given, then it makes themargin bigger or smaller by this many tabs. i.e. \fBinsert ("\\n");indent (3)\fP is like hitting Enter and then hitting Tab three times..TP\fBinsert_ahead(\fP\fIstring\fP\fB)\fPInserts the given string ahead of the current cursor position..TP\fBback_space(\fP\fIint\fP\fB)\fPDeletes the given number of characters behind the cursor..TP\fBdelete(\fP\fIint\fP\fB)\fPDeletes the given number of characters ahead of the cursor..TP\fIint\fP \fBcurrent()\fPReturns the current absolute cursor position..TP\fIint\fP \fBcurrent_line()\fPReturns the current line number counting from zero for the first line..TP\fIint\fP \fBbol(\fP\fIint\fP\fB)\fPReturns the absolute offset of the start of the given line..TP\fIint\fP \fBeol(\fP\fIint\fP\fB)\fPReturns the absolute offset of the end of the given line..TP\fIint\fP \fBfind_forwards(\fP\fIint\fP, \fIstring\fP\fB)\fPSearches forward from the given offset and returns the absoluteoffset of the found string..TP\fIint\fP \fBfind_backwards(\fP\fIint\fP, \fIstring\fP\fB)\fPSearches backward from the given offset and returns the absoluteoffset of the found string..TP\fIint\fP \fBline(\fP\fIint\fP\fB)\fPReturns the line number of the given offset. Repeated calls to thisfunction will be slow..TP\fIstring\fP \fBget_text(\fP\fI[int[\fP\fB,\fP \fIint]]\fP\fB)\fPReturns a string containing the characters between the givenoffsets. If the second argument is omitted, then this returns astring one character in length at the given offset. If both argumentsare omitted then this returns the character under the cursor..TP\fIstring\fP \fBget_line(\fP\fI[int[\fP\fB,\fP \fIint]]\fP\fB)\fPReturns a string containing the characters between the given linesinclusive. If the second argument is omitted, then this returns a stringcontaining the given line. If both arguments are omitted, then thisreturns the current line of the cursor. The trailing newline is notincluded..PPThe following functions allow binding of arbitrary python codeto menu items and keys:.TP\fBkey(\fP\fIstring\fP\fB,\fP \fIint[\fP\fB,\fP \fIstring]\fP\fB)\fPBinds a python statement to a key. The last argument contains pythoncode. If it is omitted then the action is to unbind the key if it isbound. The first argument is the string representation of a key from the\fBkeysymdef.h\fP X Window header file (with or without the \fBXK_\fPprefix). The second argument is zero or the inclusive OR of any of thefollowing modifiers:.RS.TP.B ShiftMask.TP.B LockMask.TP.B ControlMask.TP.B AltMask.TP.B Mod1Mask.TP.B Mod2Mask.TP.B Mod3Mask.TP.B Mod4Mask.TP.B Mod5Mask.PP\fBAltMask\fP is defined in the \fBglobal.h\fP header file in thedistribution and is system dependant.The usual usage of this function is to bind a key to a shortpython statement. The statement itself would then call functions thatwere previously defined.The key binding will be seen through all edit windows..RE.TP\fBbind(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fIint[\fP\fB,\fP \fIfunction]\fP\fB)\fP.RSBinds a python function to a range of keys in the current editor. If thelast argument is omitted then the action is to unbind those keys if theyare bound. The first two arguments are the string representation of a rangeof keys from the \fBkeysymdef.h\fP X Window header file (with or withoutthe \fBXK_\fP prefix) (for example \fBbind ("A", "Z", ControlMask,control_keys)\fP, which binds the keys \fBA\fP through \fBZ\fP to thefunction \fBcontrol_keys\fP). The third argument is the modifier as with the\fBkey()\fP function. The bound function must take two arguments: thekey name as a string and the modifier as an integer..PPThe key binding will be seen in the current (focussed) editor windowonly. If the same key is bound globally (using the \fBkey()\fP function),then it will be overridden by \fBbind()\fP..PPThis is useful for binding particular keys depending on the type oftext being edited. \fBbind()\fP should hence be used within the\fBtype_change()\fP function..RE.TP\fBmenu(\fP\fIstring\fP\fB,\fP \fI[string[\fP\fB,\fP \fIstring]]\fP\fB)\fP.RSCreates a menu item. The last argument contains python code. If itis omitted then the action is to remove the menu item if it exists. Thefirst argument is the name of one of the menus and can be one of\fBFile\fP, \fBEdit\fP, \fBSearch\fP, \fBCommand\fP, \fBOptions\fP,\fBReadme\fP or \fBUtil\fP. The second argument is the menu item text tobe added to the given menu. If this text contains a \fB\\t\fPthen the text after the \fB\\t\fP will be right justified (eg\fI"Open...\fP\fB\\t\fP\fIC-o"\fP). The \fBUtil\fP menu isspecific to each editor window, hence this is useful fordefining tools specific to a particular file type. The\fBUtil\fP menu is activated by pressing on the \fBUtil\fP toolbutton of each editor window, or\fBMeta-U\fP.If only one argument is given, then this command clears the menu of allits items..RE.TP\fBreplace_menu(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fIstring\fP,\fP \fIstring\fP\fB)\fPReplaces an existing menu item with a new menu item. The argumentsare respectively: The menu (i.e. \fBFile\fP, \fBEdit\fP, etc.),the old menu item, the new menu item, and the python code..TP\fBinsert_menu(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fIstring\fP,\fP \fIstring\fP\fB)\fPInserts a menu item after an existing menu item. The argumentsare respectively: The menu (i.e. \fBFile\fP, \fBEdit\fP, etc.),the menu item before which the insertion is to be made, the new menu item,and the python code..PPThe following functions return information about the current edit buffer:.TP\fIstring\fP \fBfile()\fPReturns the file-name excluding the path..TP\fIstring\fP \fBdirectory()\fPReturns the directory..TP\fIint\fP \fBmodified()\fPReturns the flag to indicate if the buffer has been modified sincethe last load or save..TP\fIint\fP \fBoverwrite(\fP\fI[int]\fP\fB)\fPReturns the overwrite flag (indicating type-over mode). If an integer isgiven, then this sets the overwrite flag and returns the previous valueof the overwrite flag..TP\fB(\fP\fIint\fP\fB,\fP \fIint\fP\fB,\fP \fIint\fP\fB,\fP \fIint\fP\fB,\fP \fIint\fP\fB)\fP \fBmarkers(\fP\fI[int\fP\fB,\fP \fIint[\fP\fB,\fP \fIint\fP\fB,\fP \fIint\fP\fB,\fP \fIint]]\fP\fB)\fP.RSReturns the state of the markers. The five values returned are: thestarting marker, the ending marker, a flag indicating whether columnhighlighting mode is on, the starting column and the ending column. Thelast two values should be ignored if column highlighting (the thirdvalue) is found to be zero.If nothing is highlighted then this function returns \fBNone\fP.If values are passed to the function, then the state of the markers willbe set to those values. Note that if the end marker is -1, then theending marker is the cursor and movements of the cursor will change theselection. If the third argument is zero then that last two argumentsare ignored..RE.PPThe following functions display and return information to/from the user:.TP\fB(\fP\fItuple\fP\fB,\fP \fItuple\fP\fB)\fP \fBgeneric_dialog(\fP\fIstring\fP\fB, \fP\fItuple\fP\fB, \fP\fItuple\fP\fB, \fP\fItuple\fP\fB, \fP\fItuple\fP\fB, \fP\fItuple\fP\fB, \fP\fItuple\fP\fB, \fP\fItuple [[\fP\fB, \fP\fIint]\fP\fB, \fP\fIint]\fP\fB)\fP.RSThis function takes a string value as the title to a dialog, thendisplays the dialog, returning the results of various checkboxes orinput widgets. The dialog has the same format as what you will see whendoing a \fBFind file\fP from the \fBFile\fP menu. An arbitrary number ofinput widgets or check boxes can be specified. The arguments passed to\fBgeneric_dialog\fP are as follows..TP\fIstring\fPTitle of the dialog..TP\fB(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fI...\fP\fB)\fPA list of default strings to go into each of the input widgets..TP\fB(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fI...\fP\fB)\fPA list of labels to go above each of the input widgets..TP\fB(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fI...\fP\fB)\fPA list of names used internally to store histories of entries to thatinput widget. These can be anything, although a descriptive name,of about 20 characters in length, will ensure uniqueness for each widget.This is actually the internal name of the widget which must be uniquewithin the entire application. Something of the form \fIdialogname\fP\fB.\fP\fIentryname\fP for each input widget is fine..TP\fB(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fI...\fP\fB)\fPA list of tool hints for each input widget. Elements may benull or there may be less elements than the number if widgets..TP\fB(\fP\fIint\fP\fB,\fP \fIint\fP\fB,\fP \fI...\fP\fB)\fPA list of values for check boxes - either 0 for off or 1 for on..TP\fB(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fI...\fP\fB)\fPA list labels for each check box..TP\fB(\fP\fIstring\fP\fB,\fP \fIstring\fP\fB,\fP \fI...\fP\fB)\fPA list of tool hints for each checkbox. Elements may benull or there may be less elements than the number if widgets..TP\fIint\fPAn optional width of the dialog. This is in units of the mean characterwidth for the current font. The default value is 60..TP\fIint\fPAn optional options integer being the inclusive OR of one or more of the followingvalues:.nf    \fBINPUTS_WITH_OPTIONS_BROWSE_LOAD_1\fP    \fBINPUTS_WITH_OPTIONS_BROWSE_SAVE_1\fP    \fBINPUTS_WITH_OPTIONS_BROWSE_DIR_1\fP    \fBINPUTS_WITH_OPTIONS_BROWSE_LOAD_2\fP    \fBINPUTS_WITH_OPTIONS_BROWSE_SAVE_2\fP    \fBINPUTS_WITH_OPTIONS_BROWSE_DIR_2\fP    \fBINPUTS_WITH_OPTIONS_BROWSE_LOAD_3\fP    \fBINPUTS_WITH_OPTIONS_BROWSE_SAVE_3\fP    \fBINPUTS_WITH_OPTIONS_BROWSE_DIR_3\fP.fiThis indicates that a `Browse' button shouldaccompany the entry widget. The browse buttonwill open a file with behaviour appropriate toloading, saving or selecting a directory..PPThe return values are two tuples containing a list of the valuesof the input widgets and checkbox's respectively. If the dialog wascanceled, the return value is null..PP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -