src/Tools/jEdit/src/jedit/TheoryView.scala
changeset 34364 8df6519599ef
parent 34318 c13e168a8ae6
child 34372 d6d536e5d7e6
equal deleted inserted replaced
34363:0fec381fb51e 34364:8df6519599ef
   201   override def contentRemoved(buffer : JEditBuffer, startLine : Int, 
   201   override def contentRemoved(buffer : JEditBuffer, startLine : Int, 
   202                               offset : Int, numLines : Int, length : Int) { }
   202                               offset : Int, numLines : Int, length : Int) { }
   203 
   203 
   204   override def preContentInserted(buffer : JEditBuffer, startLine : Int,
   204   override def preContentInserted(buffer : JEditBuffer, startLine : Int,
   205 			offset : Int, numLines : Int, length : Int) {
   205 			offset : Int, numLines : Int, length : Int) {
   206     if (col == null) 
   206     //simple xsymbol detection: entering whitespace after '>' checks for xsymbol
       
   207     if(offset - 1 > 0 && buffer.getText(offset - 1, 2).equals("> ")){
       
   208       val MAX_XSYMB_LENGTH = 20
       
   209       var beginning = offset - 2
       
   210       var length = 2
       
   211       System.err.println("found end of xsymbol")
       
   212       while(length < MAX_XSYMB_LENGTH && beginning > 0 && !buffer.getText(beginning, 1).equals("\\")){
       
   213         beginning -= 1
       
   214         length += 1
       
   215       }
       
   216       if(beginning >= 0 && buffer.getText(beginning, 2).equals("\\<")){
       
   217         val candidate = buffer.getText(beginning, length)
       
   218         val decoded = VFS.converter.decode(candidate)
       
   219         System.err.println("found potential xsymbol: " + candidate
       
   220                            + " decoded: " + decoded)
       
   221         buffer.remove(beginning, length)
       
   222         buffer.insert(beginning, decoded)
       
   223         
       
   224       } else {
       
   225         System.err.println ("could not find beginning")
       
   226       }
       
   227     }
       
   228     if (col == null)
   207       col = new Changed(offset, length, 0)
   229       col = new Changed(offset, length, 0)
   208     else if (col.start <= offset && offset <= col.start + col.added) 
   230     else if (col.start <= offset && offset <= col.start + col.added) 
   209       col = new Changed(col.start, col.added + length, col.removed)
   231       col = new Changed(col.start, col.added + length, col.removed)
   210     else { 
   232     else { 
   211       commit()
   233       commit()