📄 view.java
字号:
* Splits the view vertically. * @since jEdit 4.1pre2 */ public EditPane splitVertically() { return split(JSplitPane.HORIZONTAL_SPLIT); } //}}} //{{{ split() method /** * Splits the view. * @since jEdit 4.1pre2 */ public EditPane split(int orientation) { editPane.saveCaretInfo(); EditPane oldEditPane = editPane; setEditPane(createEditPane(oldEditPane.getBuffer())); editPane.loadCaretInfo(); JComponent oldParent = (JComponent)oldEditPane.getParent(); final JSplitPane newSplitPane = new JSplitPane(orientation); newSplitPane.setOneTouchExpandable(true); newSplitPane.setBorder(null); newSplitPane.setMinimumSize(new Dimension(0,0)); if(oldParent instanceof JSplitPane) { JSplitPane oldSplitPane = (JSplitPane)oldParent; int dividerPos = oldSplitPane.getDividerLocation(); Component left = oldSplitPane.getLeftComponent(); if(left == oldEditPane) oldSplitPane.setLeftComponent(newSplitPane); else oldSplitPane.setRightComponent(newSplitPane); newSplitPane.setLeftComponent(oldEditPane); newSplitPane.setRightComponent(editPane); oldSplitPane.setDividerLocation(dividerPos); } else { this.splitPane = newSplitPane; newSplitPane.setLeftComponent(oldEditPane); newSplitPane.setRightComponent(editPane); oldParent.add(newSplitPane); oldParent.revalidate(); } SwingUtilities.invokeLater(new Runnable() { public void run() { newSplitPane.setDividerLocation(0.5); editPane.focusOnTextArea(); } }); return editPane; } //}}} //{{{ unsplit() method /** * Unsplits the view. * @since jEdit 2.3pre2 */ public void unsplit() { if(splitPane != null) { EditPane[] editPanes = getEditPanes(); for(int i = 0; i < editPanes.length; i++) { EditPane _editPane = editPanes[i]; if(editPane != _editPane) _editPane.close(); } JComponent parent = (JComponent)splitPane.getParent(); parent.remove(splitPane); parent.add(editPane); parent.revalidate(); splitPane = null; updateTitle(); SwingUtilities.invokeLater(new Runnable() { public void run() { editPane.focusOnTextArea(); } }); } else getToolkit().beep(); } //}}} //{{{ unsplitCurrent() method /** * Removes the current split. * @since jEdit 2.3pre2 */ public void unsplitCurrent() { if(splitPane != null) { // find first split pane parenting current edit pane Component comp = editPane; while(!(comp instanceof JSplitPane)) { comp = comp.getParent(); } // get rid of any edit pane that is a child // of the current edit pane's parent splitter EditPane[] editPanes = getEditPanes(); for(int i = 0; i < editPanes.length; i++) { EditPane _editPane = editPanes[i]; if(GUIUtilities.isAncestorOf(comp,_editPane) && _editPane != editPane) _editPane.close(); } JComponent parent = (JComponent)comp.getParent(); if(parent instanceof JSplitPane) { JSplitPane parentSplit = (JSplitPane)parent; int pos = parentSplit.getDividerLocation(); if(parentSplit.getLeftComponent() == comp) parentSplit.setLeftComponent(editPane); else parentSplit.setRightComponent(editPane); parentSplit.setDividerLocation(pos); } else { parent.remove(comp); parent.add(editPane); splitPane = null; } parent.revalidate(); updateTitle(); SwingUtilities.invokeLater(new Runnable() { public void run() { editPane.focusOnTextArea(); } }); } else getToolkit().beep(); } //}}} //{{{ nextTextArea() method /** * Moves keyboard focus to the next text area. * @since jEdit 2.7pre4 */ public void nextTextArea() { EditPane[] editPanes = getEditPanes(); for(int i = 0; i < editPanes.length; i++) { if(editPane == editPanes[i]) { if(i == editPanes.length - 1) editPanes[0].focusOnTextArea(); else editPanes[i+1].focusOnTextArea(); break; } } } //}}} //{{{ prevTextArea() method /** * Moves keyboard focus to the previous text area. * @since jEdit 2.7pre4 */ public void prevTextArea() { EditPane[] editPanes = getEditPanes(); for(int i = 0; i < editPanes.length; i++) { if(editPane == editPanes[i]) { if(i == 0) editPanes[editPanes.length - 1].focusOnTextArea(); else editPanes[i-1].focusOnTextArea(); break; } } } //}}} //{{{ getSplitPane() method /** * Returns the top-level split pane, if any. * @since jEdit 2.3pre2 */ public JSplitPane getSplitPane() { return splitPane; } //}}} //{{{ getBuffer() method /** * Returns the current edit pane's buffer. */ public Buffer getBuffer() { if(editPane == null) return null; else return editPane.getBuffer(); } //}}} //{{{ setBuffer() method /** * Sets the current edit pane's buffer. */ public void setBuffer(Buffer buffer) { editPane.setBuffer(buffer); } //}}} //{{{ getTextArea() method /** * Returns the current edit pane's text area. */ public JEditTextArea getTextArea() { if(editPane == null) return null; else return editPane.getTextArea(); } //}}} //{{{ getEditPane() method /** * Returns the current edit pane. * @since jEdit 2.5pre2 */ public EditPane getEditPane() { return editPane; } //}}} //{{{ getEditPanes() method /** * Returns all edit panes. * @since jEdit 2.5pre2 */ public EditPane[] getEditPanes() { if(splitPane == null) { EditPane[] ep = { editPane }; return ep; } else { Vector vec = new Vector(); getEditPanes(vec,splitPane); EditPane[] ep = new EditPane[vec.size()]; vec.copyInto(ep); return ep; } } //}}} //{{{ getSplitConfig() method /** * Returns a string that can be passed to the view constructor to * recreate the current split configuration in a new view. * @since jEdit 3.2pre2 */ public String getSplitConfig() { // this code isn't finished yet StringBuffer splitConfig = new StringBuffer(); //if(splitPane != null) // getSplitConfig(splitPane,splitConfig); //else splitConfig.append(getBuffer().getPath()); return splitConfig.toString(); } //}}} //{{{ updateGutterBorders() method /** * Updates the borders of all gutters in this view to reflect the * currently focused text area. * @since jEdit 2.6final */ public void updateGutterBorders() { EditPane[] editPanes = getEditPanes(); for(int i = 0; i < editPanes.length; i++) editPanes[i].getTextArea().getGutter().updateBorder(); } //}}} //}}} //{{{ Synchronized scrolling //{{{ isSynchroScrollEnabled() method /** * Returns if synchronized scrolling is enabled. * @since jEdit 2.7pre1 */ public boolean isSynchroScrollEnabled() { return synchroScroll; } //}}} //{{{ toggleSynchroScrollEnabled() method /** * Toggles synchronized scrolling. * @since jEdit 2.7pre2 */ public void toggleSynchroScrollEnabled() { setSynchroScrollEnabled(!synchroScroll); } //}}} //{{{ setSynchroScrollEnabled() method /** * Sets synchronized scrolling. * @since jEdit 2.7pre1 */ public void setSynchroScrollEnabled(boolean synchroScroll) { this.synchroScroll = synchroScroll; JEditTextArea textArea = getTextArea(); int firstLine = textArea.getFirstLine(); int horizontalOffset = textArea.getHorizontalOffset(); synchroScrollVertical(textArea,firstLine); synchroScrollHorizontal(textArea,horizontalOffset); } //}}} //{{{ synchroScrollVertical() method /** * Sets the first line of all text areas. * @param textArea The text area that is propagating this change * @param firstLine The first line * @since jEdit 2.7pre1 */ public void synchroScrollVertical(JEditTextArea textArea, int firstLine) { if(!synchroScroll) return; EditPane[] editPanes = getEditPanes(); for(int i = 0; i < editPanes.length; i++) { if(editPanes[i].getTextArea() != textArea) editPanes[i].getTextArea()._setFirstLine(firstLine); } } //}}} //{{{ synchroScrollHorizontal() method /** * Sets the horizontal offset of all text areas. * @param textArea The text area that is propagating this change * @param horizontalOffset The horizontal offset * @since jEdit 2.7pre1 */ public void synchroScrollHorizontal(JEditTextArea textArea, int horizontalOffset) { if(!synchroScroll) return; EditPane[] editPanes = getEditPanes(); for(int i = 0; i < editPanes.length; i++) { if(editPanes[i].getTextArea() != textArea) editPanes[i].getTextArea()._setHorizontalOffset(horizontalOffset); } } //}}} //}}} //{{{ quickIncrementalSearch() method /** * Quick search. * @since jEdit 4.0pre3 */ public void quickIncrementalSearch(boolean word) { if(searchBar == null) { addToolBar(TOP_GROUP,SEARCH_BAR_LAYER, new SearchBar(this,true)); } JEditTextArea textArea = getTextArea(); String text = textArea.getSelectedText(); if(text == null && word) { textArea.selectWord(); text = textArea.getSelectedText(); } else if(text != null && text.indexOf('\n') != -1) text = null; searchBar.setHyperSearch(false); searchBar.getField().setText(text); searchBar.getField().requestFocus(); searchBar.getField().selectAll(); } //}}} //{{{ quickHyperSearch() method /** * Quick HyperSearch. * @since jEdit 4.0pre3 */ public void quickHyperSearch(boolean word) { JEditTextArea textArea = getTextArea(); String text = textArea.getSelectedText(); if(text == null && word) { textArea.selectWord(); text = textArea.getSelectedText(); } if(text != null && text.indexOf('\n') == -1) { HistoryModel.getModel("find").addItem(text); SearchAndReplace.setSearchString(text); SearchAndReplace.setSearchFileSet(new CurrentBufferSet()); SearchAndReplace.hyperSearch(this); } else { if(searchBar == null) { addToolBar(TOP_GROUP,SEARCH_BAR_LAYER, new SearchBar(this,true)); } searchBar.setHyperSearch(true); searchBar.getField().setText(null); searchBar.getField().requestFocus(); searchBar.getField().selectAll(); } } //}}} //{{{ isClosed() method /** * Returns true if this view has been closed with * {@link jEdit#closeView(View)}. */ public boolean isClosed() { return closed; } //}}} //{{{ isPlainView() method /** * Returns true if this is an auxilliary view with no dockable windows. * @since jEdit 4.1pre2 */ public boolean isPlainView() { return plainView; } //}}} //{{{ getNext() method /** * Returns the next view in the list. */ public View getNext()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -