📄 makeworkspace.bsh
字号:
/** Open a new workspace (shell) in the GUI.*/import javax.swing.*;import bsh.Interpreter;import bsh.BshClassManager;import bsh.util.JConsole;import bsh.util.NameCompletionTable;makeWorkspace( String name ) { if ( bsh.system.desktop == void ) { print("No desktop..."); return; } console = new JConsole(); name="Bsh Workspace: "+name; interpreter = new Interpreter( console ); // provide name completion for console, name source is global namespace // move this into JConsole? nct = new NameCompletionTable(); nct.add( interpreter.getNameSpace() ); try { bcm = BshClassManager.getClassManager(); if ( bcm != null ) { classNamesSource = bcm.getClassPath(); nct.add( classNamesSource ); } } catch ( ClassPathException e ) { error("classpath exception in name compl:"+e); } console.setNameCompletion( nct ); // end setup name completion // for convenience and backwards compatability interpreter.set( "bsh.desktop", bsh.system.desktop ); frame = bsh.system.desktop.makeInternalFrame( name ); frame.setDefaultCloseOperation( frame.DO_NOTHING_ON_CLOSE ); internalFrameClosing( e ) { close(); } frame.addInternalFrameListener(this); actionPerformed( e ) { com = e.getActionCommand(); if ( com.equals("Workspace Editor") ) workspaceEditor( interpreter, name ); else if ( com.equals("Capture System in/out/err") ) captureSysIO(); else if ( com.equals("Close") ) { close(); } } /* Notes: Careful not to print anything before returning sys io... console is now gone. */ close() { frame.dispose(); if ( haveSysIO ) returnSysIO(); } menubar = new JMenuBar(); menu=new JMenu("File"); mi=new JMenuItem("Workspace Editor"); mi.addActionListener(this); menu.add(mi); mi=new JMenuItem("Capture System in/out/err"); mi.addActionListener(this); menu.add(mi); mi=new JMenuItem("Close"); mi.addActionListener(this); menu.add(mi); menubar.add(menu); menu = bsh.system.desktop.makeFontMenu( console ); menubar.add(menu); frame.setMenuBar(menubar); frame.getContentPane().add("Center", console); //frame.pack(); thread = new Thread( interpreter ); thread.start(); frame.setBounds(5,5,600,300); // cascade windows? //off=bsh.system.desktop.windowCount*10; //frame.setLocation( off, off ); //frame.validate(); bsh.system.desktop.addInternalFrame( frame ); frame.toFront(); frame.setSelected(true); haveSysIO=false; sysIn = System.in; sysOut = System.out; sysErr = System.err; captureSysIO() { super.haveSysIO = true; System.setIn( console.getInputStream() ); System.setOut( console.getOut() ); System.setErr( console.getErr() ); } returnSysIO() { super.haveSysIO = false; System.setIn( sysIn ); System.setOut( sysOut ); System.setErr( sysErr ); } return interpreter;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -