📄 vtexted.h
字号:
//===============================================================// vtexted.h - vTextEditor class definitions - based on vTextCanvas//// Copyright (C) 1995,1996 Bruce E. Wampler//// This file is part of the V C++ GUI Framework, and is covered// under the terms of the GNU Library General Public License,// Version 2. This library has NO WARRANTY. See the source file// vapp.cxx for more complete information about license terms.//===============================================================#ifndef VTEXTED_H#define VTEXTED_H#include <v/vtextcnv.h>// for X version#ifndef V_EXPORT#define V_EXPORT#endif class V_EXPORT vCmdWindow; class V_EXPORT vTextEdCmdInterp; // These values may be used a the id paramater of the // EditCommand method, which will then carry out the // specfied command. The val parameter is used to // pass a count when necessary, and can usually be // a positive or negative value. Thus edCharRight with // a positive val moves right; with a negative val, left. enum // editor commands { edBalMatch = 10000, // find matching paren (if > 1, up to val lines away) edBufferBottom, // move to bottom of file (no val) edCenterScreen, // center cursor in display window edCharDelete, // delete +/- val chars edCharFoldCase, // swap case of +/- val letters edCharInsert, // insert char val edCharRight, // move +/- val chars right edCut, // Cut edCopy, // Copy edPaste, // Paste edFill, // fill current line edFind, // invoke TextEd's find dialog (no val) edFindNext, // find next occurrence of prev (no val) edHelp, // show help screen edIndent, // autoindent if on edLineBeginning, // move to line beginning (no val) edLineDown, // move down +/- val lines in column edLineDownBeg, // move down +/- val lines edLineDelete, // delete +/- val lines edLineDeleteFront, // delete to beginning of line (no val) edLineDeleteToEnd, // delete to end of line (no val) edLineEnd, // move to end of line (no val) edLineGoto, // move cursor to line val edLineOpen, // open val new blank lines edFormatC, // format a C Line edNoteLocation, // note which line we are on edNoteGoto, // goto noted locateion edScrollDown, // scroll val lines without changing cursor edReplace, // Find/Replace edUndo, // UnDo the last edit edUnDoMove, // UnDo the last move edVerify, // force repaint of screen (no val) edWordRight, // move cursor +/- val words right edNoOp }; enum FileType { Text, CPP, HTML, Java, TeX, gccError, bccError, javaError, Perl, Fortran, Lisp, XML, Python, Tcl, Makefile, Shellscript }; enum ReplaceConfirm { YesRepl = 800, // Replace this instance YesReplNext, // Replace, go to next NoRepl, // Don't replace NoReplNext, // Don't replace, goto next QuitR, // Quit replacing RepAll // Quit confirming, replace all }; const int MAX_LINE = 500; // Max line length we will handle const int MAX_UNDO = 4094; typedef char* BUFFPTR; typedef struct MARK_RANGE { long beg_lin; /* first line of marked range */ long end_lin; /* last line of marked range */ int beg_col; /* col where first line begins */ int end_col; /* col where last line ends */ BUFFPTR beg_chr; /* first chr */ BUFFPTR end_chr; } MARK_RANGE; typedef struct edState { long changes; // count of changes FileType ftype; // what kind of file type int autoIndent, // autoindent flag counter, // counter for + insert echof, // whether or not to echo action ins_mode, // true if insert mode delOnInsert, // true if delete selection on insert readOnly; // true if read only } edState; typedef struct globalState { int findAtBeginning, // leave find at beginning of pattern fixed_scroll, // flag if using fixed scroll delOnInsert, // true if delete selection on insert tabspc, // tab spacing wraplm, // right limit braceIndent; // indenting for {}'s } globalState;#include <v/vmodald.h> class V_EXPORT vTEConfirm : protected vModalDialog { public: vTEConfirm(VCONST vCmdWindow *bw, VCONST char* title = "Replace?"): vModalDialog((vBaseWindow*)bw,title) {added = 0;} ~vTEConfirm() {} int ConfirmRep(); protected: static DialogCmd ConfirmCmds[]; private: virtual void DialogCommand(ItemVal id, ItemVal val, CmdType ctype); int added; }; class V_EXPORT vTextEditor : public vTextCanvasPane // The main way to deal with a file { public: //---------------------------------------- public vTextEditor(VCONST vCmdWindow* parent); ~vTextEditor(); // Destructor virtual void resetBuff(); // open the buffer virtual int addLine(char* line); // add a line to end of buffer virtual int getFirstLine(char* line, int maxChars); // first line in buffer virtual int getNextLine(char* line, int maxChars); // next line in buffer, -1 = END virtual int getLine(char* line, int maxChars, long lineNum); // retrieve given line virtual void displayBuff(long lineNum = 1, int paintIt = 1); // finished with buffer virtual int insertLine(char* line, long before, bool doUndo = true); virtual void adjustLines(long line_1, int by); // Editor command interpreter virtual int EditCommand(int id, long val); virtual int EditKeyIn(vKey key, unsigned int shift); void ChangeCmdInterp(vTextEdCmdInterp* newCI); vTextEdCmdInterp* GetCmdInterp() VCONST { return _teCInt; } // State Notification virtual void ChangeLoc(long line, int col) {} // just state change virtual void ChangeInsMode(int IsInsMode, char* msg = 0) {} virtual void StatusMessage(char *msg) {} virtual void ErrorMsg(char *str) {}; globalState GetGlobalState() VCONST { return gState; } void SetGlobalState(globalState setGState) { gState = setGState; } edState GetEdState() VCONST { return state; } void SetEdState(edState setState) { state = setState; } void SetRdOnly(int ro) {state.readOnly = ro;} void SetInsMode(int ins) {state.ins_mode = ins;} void SetEchoF(int e) {state.echof = e;} void SetAutoIndent(int ai) {state.autoIndent = ai;} FileType GetFileType() VCONST { return state.ftype; } void SetFileType(FileType ft) {state.ftype = ft; } long JLine() VCONST {return b_lastln; } void SetJLine(long j) {b_lastln = j;} void SetFindPat(char* newpat) {if (strlen(newpat) < MAX_LINE) strcpy(theFindPat,newpat); } char* GetFindPat() VCONST { return theFindPat; } long GetLines() VCONST { return lastLine; } long GetCurLine() VCONST { return curlin; } int getColPos() {return col_pos(curchr);} int OldLen() VCONST { return oldlen; } void SetOldLen(int val) {oldlen = val; } int Changed() VCONST { return state.changes > 0; } void IncChanges() { ++state.changes; }; void Verify(void); // repaint screen // ******* Methods used by command interpreters ************ // Character oriented methods int charDelete(long cnt, bool doUndo = true, bool removeRange = true); // delete next cnt chars int charFoldCase(long cnt); // swap case of letter int charInsert(int ival, bool doUndo = true); // forced insert int charRight(long cnt, int clear_mark = 1); // move char right // line oriented methods void lineAutoFill(void); // automatic filling void lineBeginning(); // move to line beginning int lineDown(long cnt, int clrRange = 1);// move down cnt lines int lineDownBeg(long cnt, int notify = 1, int clrRange = 1); // move down cnt lines void lineDelete(long cnt, bool doUndo = true); // delete cnt lines int lineDeleteFront(bool doUndo = true); // delete to beginning of line int lineDeleteToEnd(bool doUndo = true); // delete to end of line void lineEnd(int clrRange = 1); // move to end of line int lineFill(long count); // fill count lines
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -