[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Tue May 20 15:33:01 UTC 2008


kawas
Tue May 20 11:33:00 EDT 2008
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory dev.open-bio.org:/tmp/cvs-serv7153/src/main/org/biomoby/service/dashboard

Modified Files:
	PerlMoSeSPanel.java PerlMoSeSSyntaxDocument.java 
Log Message:
added code that moves the cursor around when certain characters are inserted. the way i did it is less than ideal and should be changed once a better method is found.
moby-live/Java/src/main/org/biomoby/service/dashboard PerlMoSeSPanel.java,1.2,1.3 PerlMoSeSSyntaxDocument.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSPanel.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSPanel.java	2008/05/18 12:43:09	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSPanel.java	2008/05/20 15:33:00	1.3
@@ -128,7 +128,7 @@
     private Icon zoomInIcon, zoomInIconDis;
     private Icon zoomOutIcon, zoomOutIconDis;
     
-    private JTextPane editorTextPane;
+    private static JTextPane editorTextPane;
     
     private JComboBox fonts;
     
@@ -533,6 +533,10 @@
 	return p;
     }
 
+    protected static void moveCursor(int pos) {
+	if (editorTextPane != null && editorTextPane.isEnabled() && pos >= 0 && pos < editorTextPane.getText().length())
+	    editorTextPane.setCaretPosition(pos);
+    }
     private JComponent getFontChooser() {
 	JLabel label = new JLabel("Font:");
 	JPanel panel = new JPanel(new FlowLayout());

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSSyntaxDocument.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSSyntaxDocument.java	2008/05/15 18:58:47	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSSyntaxDocument.java	2008/05/20 15:33:00	1.2
@@ -14,6 +14,7 @@
 import javax.swing.text.SimpleAttributeSet;
 import javax.swing.text.StyleConstants;
 
+
 /**
  * This class implements the functionality needed to create
  * a Stylized view of perl scripts in the Perl MoSeS editor
@@ -152,12 +153,18 @@
     @Override
     public void insertString(int offset, String str, AttributeSet a)
 	    throws BadLocationException {
+	boolean replaced = false;
 	if (str.equals("{") || str.equals("[") || str.equals("(")) {
 	    str = addMatchingToken(offset, str);
+	    replaced = true;
 	}
 	
 	super.insertString(offset, str, a);
 	processChangedLines(offset, str.length());
+	if (replaced) {
+	    // FIXME bad hack to move the cursor ...
+	    PerlMoSeSPanel.moveCursor(offset+str.length() - 2);
+	}
     }
 
     @Override
@@ -344,6 +351,7 @@
     /*
      * Parse the line for tokens to highlight
      */
+    boolean inQuote = false;
     private void checkForTokens(String content, int startOffset, int endOffset) {
 	while (startOffset <= endOffset) {
 	    // skip the delimiters to find the start of a new token
@@ -393,8 +401,7 @@
 	else
 	    endOfQuote = index;
 
-	doc.setCharacterAttributes(startOffset, endOfQuote - startOffset + 1,
-		quote, false);
+	doc.setCharacterAttributes(startOffset, endOfQuote - startOffset + 1, quote, false);
 
 	return endOfQuote + 1;
     }
@@ -590,6 +597,6 @@
 
 	if (token.equals("{"))
 	    return token + "\n" + whiteSpace.toString() + "    \n" + whiteSpace.toString() + token_map.get(token);
-	return token + whiteSpace.toString() + " " + whiteSpace.toString() + token_map.get(token);
+	return token + "  " + token_map.get(token);
     }
 }




More information about the MOBY-guts mailing list