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

📄 jedit.java

📁 Linux下面最好用的程序、文本编辑工具之一。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
					return false;				VFSManager.waitForRequests();				if(buffer.getBooleanProperty(BufferIORequest					.ERROR_OCCURRED))				{					return false;				}			}			else if(result != JOptionPane.NO_OPTION)				return false;		}		_closeBuffer(view,buffer);		return true;	} //}}}	//{{{ _closeBuffer() method	/**	 * Closes the buffer, even if it has unsaved changes.	 * @param view The view, may be null	 * @param buffer The buffer	 *	 * @exception NullPointerException if the buffer is null	 *	 * @since jEdit 2.2pre1	 */	public static void _closeBuffer(View view, Buffer buffer)	{		if(buffer.isClosed())		{			// can happen if the user presses C+w twice real			// quick and the buffer has unsaved changes			return;		}		PerspectiveManager.setPerspectiveDirty(true);		if(!buffer.isNewFile())		{			if(view != null)				view.getEditPane().saveCaretInfo();			Integer _caret = (Integer)buffer.getProperty(Buffer.CARET);			int caret = (_caret == null ? 0 : _caret.intValue());			BufferHistory.setEntry(buffer.getPath(),caret,				(Selection[])buffer.getProperty(Buffer.SELECTION),				buffer.getStringProperty(Buffer.ENCODING));		}		String path = buffer.getSymlinkPath();		if((VFSManager.getVFSForPath(path).getCapabilities()			& VFS.CASE_INSENSITIVE_CAP) != 0)		{			path = path.toLowerCase();		}		bufferHash.remove(path);		removeBufferFromList(buffer);		buffer.close();		DisplayManager.bufferClosed(buffer);		EditBus.send(new BufferUpdate(buffer,view,BufferUpdate.CLOSED));		// Create a new file when the last is closed		if(buffersFirst == null && buffersLast == null)			newFile(view);	} //}}}	//{{{ closeAllBuffers() method	/**	 * Closes all open buffers.	 * @param view The view	 */	public static boolean closeAllBuffers(View view)	{		return closeAllBuffers(view,false);	} //}}}	//{{{ closeAllBuffers() method	/**	 * Closes all open buffers.	 * @param view The view	 * @param isExiting This must be false unless this method is	 * being called by the exit() method	 */	public static boolean closeAllBuffers(View view, boolean isExiting)	{		if(view != null)			view.getEditPane().saveCaretInfo();		boolean dirty = false;		Buffer buffer = buffersFirst;		while(buffer != null)		{			if(buffer.isDirty())			{				dirty = true;				break;			}			buffer = buffer.next;		}		if(dirty)		{			boolean ok = new CloseDialog(view).isOK();			if(!ok)				return false;		}		// Wait for pending I/O requests		VFSManager.waitForRequests();		if(VFSManager.errorOccurred())			return false;		// close remaining buffers (the close dialog only deals with		// dirty ones)		buffer = buffersFirst;		// zero it here so that BufferTabs doesn't have any problems		buffersFirst = buffersLast = null;		bufferHash.clear();		bufferCount = 0;		while(buffer != null)		{			if(!buffer.isNewFile())			{				Integer _caret = (Integer)buffer.getProperty(Buffer.CARET);				int caret = (_caret == null ? 0 : _caret.intValue());				BufferHistory.setEntry(buffer.getPath(),caret,					(Selection[])buffer.getProperty(Buffer.SELECTION),					buffer.getStringProperty(Buffer.ENCODING));			}			buffer.close();			DisplayManager.bufferClosed(buffer);			if(!isExiting)			{				EditBus.send(new BufferUpdate(buffer,view,					BufferUpdate.CLOSED));			}			buffer = buffer.next;		}		if(!isExiting)			newFile(view);		PerspectiveManager.setPerspectiveDirty(true);		return true;	} //}}}	//{{{ saveAllBuffers() method	/**	 * Saves all open buffers.	 * @param view The view	 * @since jEdit 4.2pre1	 */	public static void saveAllBuffers(View view)	{		saveAllBuffers(view,jEdit.getBooleanProperty("confirmSaveAll"));	} //}}}	//{{{ saveAllBuffers() method	/**	 * Saves all open buffers.	 * @param view The view	 * @param confirm If true, a confirmation dialog will be shown first	 * @since jEdit 2.7pre2	 */	public static void saveAllBuffers(View view, boolean confirm)	{		if(confirm)		{			int result = GUIUtilities.confirm(view,"saveall",null,				JOptionPane.YES_NO_OPTION,				JOptionPane.QUESTION_MESSAGE);			if(result != JOptionPane.YES_OPTION)				return;		}		Buffer current = view.getBuffer();		Buffer buffer = buffersFirst;		while(buffer != null)		{			if(buffer.isDirty())			{				if(buffer.isNewFile())					view.setBuffer(buffer);				buffer.save(view,null,true);			}			buffer = buffer.next;		}		view.setBuffer(current);	} //}}}	//{{{ reloadAllBuffers() method	/**	 * Reloads all open buffers.	 * @param view The view	 * @param confirm If true, a confirmation dialog will be shown first	 *	if any buffers are dirty	 * @since jEdit 2.7pre2	 */	public static void reloadAllBuffers(final View view, boolean confirm)	{		boolean hasDirty = false;		Buffer[] buffers = jEdit.getBuffers();		for(int i = 0; i < buffers.length && hasDirty == false; i++)			hasDirty = buffers[i].isDirty();		if(confirm && hasDirty)		{			int result = GUIUtilities.confirm(view,"reload-all",null,				JOptionPane.YES_NO_OPTION,				JOptionPane.QUESTION_MESSAGE);			if(result != JOptionPane.YES_OPTION)				return;		}		// save caret info. Buffer.load() will load it.		View _view = viewsFirst;		while(_view != null)		{			EditPane[] panes = _view.getEditPanes();			for(int i = 0; i < panes.length; i++)			{				panes[i].saveCaretInfo();			}			_view = _view.next;		}		for(int i = 0; i < buffers.length; i++)		{			Buffer buffer = buffers[i];			buffer.load(view,true);		}	} //}}}	//{{{ _getBuffer() method	/**	 * Returns the buffer with the specified path name. The path name	 * must be an absolute, canonical, path.	 *	 * @param path The path name	 * @see MiscUtilities#constructPath(String,String)	 * @see MiscUtilities#resolveSymlinks(String)	 * @see #getBuffer(String)	 *	 * @since jEdit 4.2pre7	 */	public static Buffer _getBuffer(String path)	{		// paths on case-insensitive filesystems are stored as lower		// case in the hash.		if((VFSManager.getVFSForPath(path).getCapabilities()			& VFS.CASE_INSENSITIVE_CAP) != 0)		{			path = path.toLowerCase();		}		synchronized(bufferListLock)		{			return (Buffer)bufferHash.get(path);		}	} //}}}	//{{{ getBuffer() method	/**	 * Returns the buffer with the specified path name. The path name	 * must be an absolute path. This method automatically resolves	 * symbolic links. If performance is critical, cache the canonical	 * path and call {@link #_getBuffer(String)} instead.	 *	 * @param path The path name	 * @see MiscUtilities#constructPath(String,String)	 * @see MiscUtilities#resolveSymlinks(String)	 */	public static Buffer getBuffer(String path)	{		return _getBuffer(MiscUtilities.resolveSymlinks(path));	} //}}}	//{{{ getBuffers() method	/**	 * Returns an array of open buffers.	 */	public static Buffer[] getBuffers()	{		synchronized(bufferListLock)		{			Buffer[] buffers = new Buffer[bufferCount];			Buffer buffer = buffersFirst;			for(int i = 0; i < bufferCount; i++)			{				buffers[i] = buffer;				buffer = buffer.next;			}			return buffers;		}	} //}}}	//{{{ getBufferCount() method	/**	 * Returns the number of open buffers.	 */	public static int getBufferCount()	{		return bufferCount;	} //}}}	//{{{ getFirstBuffer() method	/**	 * Returns the first buffer.	 */	public static Buffer getFirstBuffer()	{		return buffersFirst;	} //}}}	//{{{ getLastBuffer() method	/**	 * Returns the last buffer.	 */	public static Buffer getLastBuffer()	{		return buffersLast;	} //}}}	//{{{ checkBufferStatus() method	/**	 * Checks each buffer's status on disk and shows the dialog box	 * informing the user that buffers changed on disk, if necessary.	 * @param view The view	 * @since jEdit 4.2pre1	 */	public static void checkBufferStatus(View view)	{		// still need to call the status check even if the option is		// off, so that the write protection is updated if it changes		// on disk		boolean showDialogSetting = getBooleanProperty(			"autoReloadDialog");		// auto reload changed buffers?		boolean autoReloadSetting = getBooleanProperty(			"autoReload");		// the problem with this is that if we have two edit panes		// looking at the same buffer and the file is reloaded both		// will jump to the same location		View _view = viewsFirst;		while(_view != null)		{			EditPane[] editPanes = _view.getEditPanes();			for(int i = 0; i < editPanes.length; i++)			{				editPanes[i].saveCaretInfo();			}			_view = _view.next;		}		Buffer buffer = buffersFirst;		int[] states = new int[bufferCount];		int i = 0;		boolean show = false;		while(buffer != null)		{			states[i] = buffer.checkFileStatus(view);			switch(states[i])			{			case Buffer.FILE_CHANGED:				if(autoReloadSetting					&& showDialogSetting					&& !buffer.isDirty())				{					buffer.load(view,true);				}				/* fall through */			case Buffer.FILE_DELETED:				show = true;				break;			}			buffer = buffer.next;			i++;		}		if(show && showDialogSetting)			new FilesChangedDialog(view,states,autoReloadSetting);	} //}}}	//}}}	//{{{ View methods	//{{{ getInputHandler() method	/**	 * Returns the current input handler (key binding to action mapping)	 * @see org.gjt.sp.jedit.gui.InputHandler	 */	public static InputHandler getInputHandler()	{		return inputHandler;	} //}}}	/* public static void newViewTest()	{		long time = System.currentTimeMillis();		for(int i = 0; i < 30; i++)		{			Buffer b = newFile(null);			b.insert(0,"x");			new View(b,null,false);		}		System.err.println(System.currentTimeMillis() - time);	} */	//{{{ newView() method	/**	 * Creates a new view.	 * @param view An existing view	 * @since jEdit 3.2pre2	 */	public static View newView(View view)	{		return newView(view,null,false);	} //}}}	//{{{ newView() method	/**	 * Creates a new view of a buffer.	 * @param view An existing view	 * @param buffer The buffer	 */	public static View newView(View view, Buffer buffer)	{		return newView(view,buffer,false);	} //}}}	//{{{ newView() method	/**	 * Creates a new view of a buffer.	 * @param view An existing view	 * @param buffer The buffer	 * @param plainView If true, the view will not have dockable windows or	 * tool bars.	 *	 * @since 4.1pre2	 */	public static View newView(View view, Buffer buffer, boolean plainView)	{		View.ViewConfig config;		if(view != null && (plainView == view.isPlainView()))			config = view.getViewConfig();		else			config = new View.ViewConfig(plainView);		return newView(view,buffer,config);	} //}}}	//{{{ newView() method	/**	 * Creates a new view.	 * @param view An existing view	 * @param buffer A buffer to display, or null	 * @param config Encapsulates the view geometry, split configuration	 * and if the view is a plain view	 * @since jEdit 4.2pre1	 */	public static View newView(View view, Buffer buffer, View.ViewConfig config)	{		PerspectiveManager.setPerspectiveDirty(true);		try		{			if(view != null)			{				view.showWaitCursor();				view.getEditPane().saveCaretInfo();			}			View newView = new View(buffer,config);			addViewToList(newView);			if(!config.plainView)			{				DockableWindowManager wm = newView.getDockableWindowManager();				if(config.top != null					&& config.top.length() != 0)					wm.showDockableWindow(config.top);				if(config.left != null					&& config.left.length() != 0)					wm.showDockableWindow(config.left);				if(config.bottom != null					&& config.bottom.length() != 0)					wm.showDockableWindow(config.bottom);				if(config.right != null					&& config.right.length() != 0)					wm.showDockableWindow(config.right);			}			newView.pack();			if(config.width != 0 && config.height != 0)			{				Rectangle desired = new Rectangle(					config.x,config.y,config.width,					config.height);				if(OperatingSystem.isX11() && Debug.GEOMETRY_WORKAROUND)				{					new GUIUtilities.UnixWorkaround(newView,						"view",desired,config.extState);				}				else				{					newView.setBounds(desired);					GUIUtilities.setExtendedState(newView,						config.extState);				}			}			else				GUIUtilities.centerOnScreen(newView);			EditBus.send(new ViewUpdate(newView,ViewUpdate.CREATED));			newView.setVisible(true);			// show tip of the day			if(newView == viewsFirst)			{				newView.getTextArea().requestFocus();				// Don't show the welcome message if jEdit was started				// with the -nosettings switch				if(settingsDirectory != null && getBooleanProperty("firstTime"))					new HelpViewer();				else if(jEdit.getBooleanProperty("tip.show"))					new TipOfTheDay(newView);

⌨️ 快捷键说明

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