📄 swedit.java
字号:
boolean link = false; for (int line=0; line < blockHeight; line++){ pos = editor.getOffsetAtLine(startLine + line) + startCol; editor.replaceTextRange(pos, blockWidth, ""); history.push(new Command(block[line], "", pos, link)); // If more than one cut, the commands must be linked link = true; } // Clear the redo stack rehistory.clear(); return new CmdReturn(true, true, false); } public String toString(){ return "Cut Block"; } }//============================================================================= final class SweditCopyBlock extends SweditCommand{ public CmdReturn exec(){ copyBlock(); return new CmdReturn(true, true, false); } public String toString(){ return "Copy Block"; } } //============================================================================= // Paste a block-copied block of text into the document final class SweditPasteBlock extends SweditCommand{ public CmdReturn exec(){ // On the first (or only) line, the undo command does not need to link boolean link = false; // If text is selected, fail out if (editor.getSelectionCount() > 0){ return new CmdReturn(false, true, false); } if (block == null){ return new CmdReturn(false, true, false); } if (block.length <= 0){ return new CmdReturn(false, true, false); } // Go through each selected line int startLine = getLine(); int startCol = getColumn(); for (int line=0; line < block.length; line++){ // Position the caret at the start of the line if ((startLine + line) >= editor.getLineCount()){ editor.setCaretOffset(editor.getCharCount() - 1); editor.insert("\n"); } editor.setCaretOffset(editor.getOffsetAtLine(startLine + line)); setColumn(startCol, true); editor.insert(block[line]); // Remember the command in the undo stack history.push(new Command("", block[line], editor.getCaretOffset(), link)); // If more than one insert, the commands must be linked link = true; } // Clear the redo stack rehistory.clear(); return new CmdReturn(true, true, false); } public String toString(){ return "Paste Block"; } }//============================================================================= // Lots of cursor movement with selection options, largely self-explanatory final class SweditLineDown extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.LINE_DOWN); setColumn(lastColumn, false); return new CmdReturn(true, true, false); } public String toString(){ return "Line Down"; } } final class SweditLineUp extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.LINE_UP); setColumn(lastColumn, false); return new CmdReturn(true, true, false); } public String toString(){ return "Line Up"; } } final class SweditColNext extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.COLUMN_NEXT); lastColumn = getColumn(); return new CmdReturn(true, true, false); } public String toString(){ return "Column Next"; } } final class SweditColPrev extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.COLUMN_PREVIOUS); lastColumn = getColumn(); return new CmdReturn(true, true, false); } public String toString(){ return "Column Previous"; } } final class SweditWordNext extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.WORD_NEXT); lastColumn = getColumn(); return new CmdReturn(true, true, false); } public String toString(){ return "Word Next"; } } final class SweditWordPrev extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.WORD_PREVIOUS); lastColumn = getColumn(); return new CmdReturn(true, true, false); } public String toString(){ return "Word Previous"; } } final class SweditLineStart extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.LINE_START); lastColumn = 1; return new CmdReturn(true, true, false); } public String toString(){ return "Line Start"; } } final class SweditLineEnd extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.LINE_END); lastColumn = -1; return new CmdReturn(true, true, false); } public String toString(){ return "Line End"; } } final class SweditPageDown extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.PAGE_DOWN); setColumn(lastColumn, false); return new CmdReturn(true, true, false); } public String toString(){ return "Page Down"; } } final class SweditPageUp extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.PAGE_UP); setColumn(lastColumn, false); return new CmdReturn(true, true, false); } public String toString(){ return "Page Up"; } } final class SweditWindowStart extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.WINDOW_START); lastColumn = 1; return new CmdReturn(true, true, false); } public String toString(){ return "Window Start"; } } final class SweditWindowEnd extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.WINDOW_END); lastColumn = getColumn(); return new CmdReturn(true, true, false); } public String toString(){ return "Window End"; } } final class SweditTextStart extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.TEXT_START); lastColumn = 1; return new CmdReturn(true, true, false); } public String toString(){ return "Text Start"; } } final class SweditTextEnd extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.TEXT_END); return new CmdReturn(true, true, false); } public String toString(){ return "Text End"; } } final class SweditScrollUp extends SweditCommand{ public CmdReturn exec(){ int index = editor.getTopIndex() + 1; if (index < editor.getLineCount()){ editor.setTopIndex(index); } return new CmdReturn(false, true, false); } public String toString(){ return "Scroll Up"; } } final class SweditScrollDown extends SweditCommand{ public CmdReturn exec(){ int index = editor.getTopIndex() - 1; if (index > 0){ editor.setTopIndex(index); } return new CmdReturn(false, true, false); } public String toString(){ return "Scroll Down"; } } final class SweditSelectLineDown extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.SELECT_LINE_DOWN); return new CmdReturn(false, true, false); } public String toString(){ return "Select Line Down"; } } final class SweditSelectLineUp extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.SELECT_LINE_UP); return new CmdReturn(false, true, false); } public String toString(){ return "Select Line Up"; } } final class SweditSelectColNext extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.SELECT_COLUMN_NEXT); lastColumn = getColumn(); return new CmdReturn(false, true, false); } public String toString(){ return "Select Column Next"; } } final class SweditSelectColPrev extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.SELECT_COLUMN_PREVIOUS); lastColumn = getColumn(); return new CmdReturn(false, true, false); } public String toString(){ return "Select Column Previous"; } } final class SweditSelectWordNext extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.SELECT_WORD_NEXT); lastColumn = getColumn(); return new CmdReturn(false, true, false); } public String toString(){ return "Select Word Next"; } } final class SweditSelectWordPrev extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.SELECT_WORD_PREVIOUS); lastColumn = getColumn(); return new CmdReturn(false, true, false); } public String toString(){ return "Select Word Previous"; } } final class SweditSelectLineStart extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.SELECT_LINE_START); lastColumn = 1; return new CmdReturn(false, true, false); } public String toString(){ return "Select To Line Start"; } } final class SweditSelectLineEnd extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.SELECT_LINE_END); lastColumn = -1; return new CmdReturn(false, true, false); } public String toString(){ return "Select To Line End"; } } final class SweditSelectPageDown extends SweditCommand{ public CmdReturn exec(){ editor.invokeAction(ST.SELECT_PAGE_DOWN); return new CmdReturn(false, true, false); } public String toString(){ return "Select Page Down"; } } final class SweditSelectPageUp extends SweditCommand{ public CmdReturn exec(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -