ide/src/wombat/gui/text/SchemeTextArea.java
public void format() {
    	int lines = 0;
    	String text = getText();
    	for (int i = 0; i < text.length(); i++)
    		if (text.charAt(i) == '\n')
    			lines++;
    	final int totalLines = lines;
    	
    	final JFrame frame = new JFrame();
    	frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    	frame.setLocationByPlatform(true);
    	frame.setLayout(new BorderLayout());
    	
    	final JProgressBar progress = new JProgressBar(0, 100);
    	progress.setValue(0);
    	progress.setSize(100, 20);
    	progress.setString("Formatting code...");
    	progress.setStringPainted(true);
    	
    	frame.add(progress);
    	frame.pack();
    	frame.setVisible(true);
    	
    	MainFrame.Singleton().setRunning(true);
    	
    	SwingWorker<Object, Integer> task = new SwingWorker<Object, Integer>() {
    		@Override
    		protected Object doInBackground() throws Exception {
    			code.setCaretPosition(0);
    	        tab();
    	    	
    	        int next = 1;
    	        int eof = getText().indexOf("#!eof");
    	        if (eof == -1) eof = getText().length();
    	        
    	        String text = null;
    	        int line = 0;
    	        while (next < eof) {
    	        	setProgress((line++) * 100 / totalLines);
    	        	
    	        	text = getText();
    	        	for (; next > 0 && next < eof && text.charAt(next) != '\n'; next++) {
    	        		// wheee!
    	        	}
    	        	next += 2;
    	        	
    	            if (next > 0 && next < eof) {
    	                try {
    	                    code.setCaretPosition(next);
    	                    next += tab();
    	                    try { Thread.sleep(10); } catch(InterruptedException ex) {}
    	                } catch (IllegalArgumentException iae) {
    	                    iae.printStackTrace();
    	                }
    	            } 
    	        }
    	        
    	        return null;
    		}
    		
    		@Override
    		protected void done() {
    			super.done();
    			
    			frame.setVisible(false);
    			MainFrame.Singleton().setRunning(false);
    		}
    	};
    	task.addPropertyChangeListener(new PropertyChangeListener() {
			
			@Override
			public void propertyChange(PropertyChangeEvent evt) {
				if ("progress".equals(evt.getPropertyName())) {
					progress.setValue((Integer) evt.getNewValue());
				}
			}
		});
    	task.execute();
    }
/**
     * Format the document by fixing indentation to scheme standards.
     */
Format the document by fixing indentation to scheme standards.
Format the document by fixing indentation to scheme standards .
public void format() {
    	int lines = 0;
    	String text = getText();
    	for (int i = 0; i < text.length(); i++)
    		if (text.charAt(i) == '\n')
    			lines++;
    	final int totalLines = lines;
    	final JFrame frame = new JFrame();
    	frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    	frame.setLocationByPlatform(true);
    	frame.setLayout(new BorderLayout());
    	final JProgressBar progress = new JProgressBar(0, 100);
    	progress.setValue(0);
    	progress.setSize(100, 20);
    	progress.setString("Formatting code...");
    	progress.setStringPainted(true);
    	frame.add(progress);
    	frame.pack();
    	frame.setVisible(true);
    	MainFrame.Singleton().setRunning(true);
    	SwingWorker<Object, Integer> task = new SwingWorker<Object, Integer>() {
    		@Override
    		protected Object doInBackground() throws Exception {
    			code.setCaretPosition(0);
    	        tab();
    	        int next = 1;
    	        int eof = getText().indexOf("#!eof");
    	        if (eof == -1) eof = getText().length();
    	        String text = null;
    	        int line = 0;
    	        while (next < eof) {
    	        	setProgress((line++) * 100 / totalLines);
    	        	text = getText();
    	        	for (; next > 0 && next < eof && text.charAt(next) != '\n'; next++) {
    	        	}
    	        	next += 2;
    	            if (next > 0 && next < eof) {
    	                try {
    	                    code.setCaretPosition(next);
    	                    next += tab();
    	                    try { Thread.sleep(10); } catch(InterruptedException ex) {}
    	                } catch (IllegalArgumentException iae) {
    	                    iae.printStackTrace();
    	                }
    	            } 
    	        }
    	        return null;
    		}
    		@Override
    		protected void done() {
    			super.done();
    			frame.setVisible(false);
    			MainFrame.Singleton().setRunning(false);
    		}
    	};
    	task.addPropertyChangeListener(new PropertyChangeListener() {
			@Override
			public void propertyChange(PropertyChangeEvent evt) {
				if ("progress".equals(evt.getPropertyName())) {
					progress.setValue((Integer) evt.getNewValue());
				}
			}
		});
    	task.execute();
    }
public void format ( ) { int lines = 0 ; String text = getText ( ) ; for ( int i = 0 ; i < text . length ( ) ; i ++ ) if ( text . charAt ( i ) == '\n' ) lines ++ ; final int totalLines = lines ; final JFrame frame = new JFrame ( ) ; frame . setDefaultCloseOperation ( JFrame . DISPOSE_ON_CLOSE ) ; frame . setLocationByPlatform ( true ) ; frame . setLayout ( new BorderLayout ( ) ) ; final JProgressBar progress = new JProgressBar ( 0 , 100 ) ; progress . setValue ( 0 ) ; progress . setSize ( 100 , 20 ) ; progress . setString ( "Formatting code..." ) ; progress . setStringPainted ( true ) ; frame . add ( progress ) ; frame . pack ( ) ; frame . setVisible ( true ) ; MainFrame . Singleton ( ) . setRunning ( true ) ; SwingWorker < Object , Integer > task = new SwingWorker < Object , Integer > ( ) { @ Override protected Object doInBackground ( ) throws Exception { code . setCaretPosition ( 0 ) ; tab ( ) ; int next = 1 ; int eof = getText ( ) . indexOf ( "#!eof" ) ; if ( eof == - 1 ) eof = getText ( ) . length ( ) ; String text = null ; int line = 0 ; while ( next < eof ) { setProgress ( ( line ++ ) * 100 / totalLines ) ; text = getText ( ) ; for ( ; next > 0 && next < eof && text . charAt ( next ) != '\n' ; next ++ ) { } next += 2 ; if ( next > 0 && next < eof ) { try { code . setCaretPosition ( next ) ; next += tab ( ) ; try { Thread . sleep ( 10 ) ; } catch ( InterruptedException ex ) { } } catch ( IllegalArgumentException iae ) { iae . printStackTrace ( ) ; } } } return null ; } @ Override protected void done ( ) { super . done ( ) ; frame . setVisible ( false ) ; MainFrame . Singleton ( ) . setRunning ( false ) ; } } ; task . addPropertyChangeListener ( new PropertyChangeListener ( ) { @ Override public void propertyChange ( PropertyChangeEvent evt ) { if ( "progress" . equals ( evt . getPropertyName ( ) ) ) { progress . setValue ( ( Integer ) evt . getNewValue ( ) ) ; } } } ) ; task . execute ( ) ; }
Format the document by fixing indentation to scheme standards.
Format the document by fixing indentation to scheme standards .
// wheee!