Changeset 532

Show
Ignore:
Timestamp:
01/21/10 22:12:36 (3 years ago)
Author:
joerg
Message:
 
Location:
trunk/src/sce
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/sce/codehelper/CodeHelperPane.java

    r407 r532  
    414414    } 
    415415 
     416    // begin... end completion 
     417    if(e.getKeyChar() == '}') { 
     418      String begin = "\\begin"; 
     419 
     420      int index = column-1; 
     421      String rowString = document.getRow(row); 
     422      while(index > 0) { 
     423        char c = rowString.charAt(index); 
     424        if(c == '{') break; 
     425        if(!Character.isLetterOrDigit(c)) return; 
     426        index--; 
     427      } 
     428      String environment = rowString.substring(index+1, column); 
     429 
     430      int beginIndex = index - begin.length(); 
     431      if(beginIndex < 0) return; 
     432      if(rowString.substring(beginIndex, index).equals(begin)) { 
     433        String indentation = spaces.substring(0, beginIndex); 
     434        pane.setFreezeCaret(true); 
     435        document.insert("\n" + indentation + "\\end{" + environment + "}", row, column); 
     436        pane.setFreezeCaret(false); 
     437      } 
     438      e.consume(); 
     439      return; 
     440    } 
     441 
    416442    // tab completion 
    417443    if(e.getKeyCode() == KeyEvent.VK_TAB){ 
  • trunk/src/sce/component/SCEDocument.java

    r527 r532  
    145145   */ 
    146146  public void setText(String text){ 
     147    // treat Windows line breaks 
     148    if(text.indexOf((char) 0x0D) != -1) { 
     149      StringBuilder builder = new StringBuilder(text.length()); 
     150      int lastIndex = 0, index = -1; 
     151      while((index = text.indexOf((char) 0x0D, index+1)) != -1) { 
     152        builder.append(text.substring(lastIndex, index)); 
     153        lastIndex = index + 1; 
     154      } 
     155      builder.append(text.substring(lastIndex)); 
     156      text = builder.toString(); 
     157    } 
     158 
    147159    clear(); 
    148160    boolean editable_ = editable; 
     
    817829   * @param listener the listener 
    818830   */ 
    819   public void removeSCEDocumentListener(SCESelectionListener listener){ 
     831  public void removeSCESelectionListener(SCESelectionListener listener){ 
    820832    selectionListeners.remove(listener); 
    821833  } 
  • trunk/src/sce/component/SCEPaneUI.java

    r510 r532  
    3535          "äöüÄÖÜß" + 
    3636          "1234567890" + 
    37           "^<>|+*~'#,;.:-_!\"§$%&/()=?`´\\{[]} "; 
     37          "^<>|+*~'#,;.:-_!\"§$%&/()=?`´\\{[]}@ "; 
    3838 
    3939  public SCEPaneUI(SCEPane pane){ 
  • trunk/src/sce/component/SCESearch.java

    r528 r532  
    22 
    33import javax.swing.*; 
    4 import javax.swing.text.Document; 
    54import java.awt.*; 
    65import java.awt.event.ActionEvent; 
     
    144143        .addGap(2); 
    145144 
    146     SCEPane pane = editor.getTextPane(); 
    147     pane.addKeyListener(this); 
    148     pane.getDocument().addSCEDocumentListener(this); 
    149     pane.getDocument().addSCESelectionListener(this); 
    150  
    151145    layout.setHorizontalGroup(groupHorizontal); 
    152146    layout.setVerticalGroup(groupVertical); 
     147 
     148    SCEPane pane = editor.getTextPane(); 
     149    SCEDocument document = pane.getDocument(); 
     150    pane.addKeyListener(this); 
     151    document.addSCEDocumentListener(this); 
     152    document.addSCESelectionListener(this); 
    153153 
    154154    updateThread = new UpdateThread(); 
     
    181181  } 
    182182 
    183   public void close() { 
    184     setVisible(false); 
    185     clearHighlights(); 
     183  public void setVisible(boolean visibility) { 
     184    if(visibility) { 
     185      input.setText(""); 
     186    } else { 
     187      clearHighlights(); 
     188    } 
     189    super.setVisible(visibility); 
    186190  } 
    187191 
     
    227231 
    228232  public void actionPerformed(ActionEvent e) { 
    229     if(e.getSource() == buttonClose) close(); 
     233    if(e.getSource() == buttonClose) setVisible(false); 
    230234    if(e.getSource() == caseSensitive) { 
    231235      updateThread.documentChanged(); 
     
    274278  public void keyPressed(KeyEvent e) { 
    275279    if(e.getKeyCode() == KeyEvent.VK_ESCAPE){ 
    276       close(); 
     280      setVisible(false); 
    277281      e.consume(); 
    278282    } 
     
    320324    public synchronized void searchChanged() { 
    321325      searchChanged = true; 
     326      if(!isVisible()) return; 
    322327      notify(); 
    323328    } 
     
    325330    public synchronized void documentChanged() { 
    326331      documentChanged = true; 
     332      if(!isVisible()) return; 
    327333      notify(); 
    328334    } 
     
    441447        } 
    442448        if(!searchChanged && !documentChanged) continue; 
     449        if(!isVisible()) continue; 
    443450 
    444451        // update document information