TextView.st
changeset 651 1e7153e21b36
parent 649 097c69ce9599
child 668 729295eb37fc
equal deleted inserted replaced
650:563ea7f99aa8 651:1e7153e21b36
  1512 	self showMatch:pattern atLine:line col:col
  1512 	self showMatch:pattern atLine:line col:col
  1513     ] ifAbsent:aBlock
  1513     ] ifAbsent:aBlock
  1514 !
  1514 !
  1515 
  1515 
  1516 searchForMatchingParenthesisFromLine:startLine col:startCol
  1516 searchForMatchingParenthesisFromLine:startLine col:startCol
  1517 		     ifFound:foundBlock 
  1517                      ifFound:foundBlock 
  1518 		  ifNotFound:notFoundBlock
  1518                   ifNotFound:notFoundBlock
  1519 		     onError:failBlock
  1519                      onError:failBlock
  1520 
  1520 
  1521     "search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. 
  1521     "search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. 
  1522      Search for the corresponding character is done forward if its an opening,
  1522      Search for the corresponding character is done forward if its an opening,
  1523      backwards if its a closing parenthesis.
  1523      backwards if its a closing parenthesis.
  1524      Performs foundBlock with line/col as argument if found, notFoundBlock if not.
  1524      Performs foundBlock with line/col as argument if found, notFoundBlock if not.
  1525      If there is a nesting error, performs failBlock."
  1525      If there is a nesting error, performs failBlock."
  1526 
  1526 
  1527     ^ self
  1527     ^ self
  1528 	searchForMatchingParenthesisFromLine:startLine col:startCol
  1528         searchForMatchingParenthesisFromLine:startLine col:startCol
  1529 		     ifFound:foundBlock 
  1529                      ifFound:foundBlock 
  1530 		  ifNotFound:notFoundBlock
  1530                   ifNotFound:notFoundBlock
  1531 		     onError:failBlock
  1531                      onError:failBlock
  1532 		    ignoring:#( $' $" )
  1532                     ignoring:#( $' $" '$[' '$]' '${' '$)' )
  1533 
  1533 
  1534     "Modified: 18.11.1995 / 16:28:23 / cg"
  1534     "Modified: 18.5.1996 / 11:05:57 / cg"
  1535 !
  1535 !
  1536 
  1536 
  1537 searchForMatchingParenthesisFromLine:startLine col:startCol
  1537 searchForMatchingParenthesisFromLine:startLine col:startCol
  1538                      ifFound:foundBlock 
  1538                      ifFound:foundBlock 
  1539                   ifNotFound:notFoundBlock
  1539                   ifNotFound:notFoundBlock
  1544      backwards if its a closing parenthesis.
  1544      backwards if its a closing parenthesis.
  1545      Performs foundBlock with line/col as argument if found, notFoundBlock if not.
  1545      Performs foundBlock with line/col as argument if found, notFoundBlock if not.
  1546      If there is a nesting error, performs failBlock."
  1546      If there is a nesting error, performs failBlock."
  1547 
  1547 
  1548     |i direction lineString line col parChar charSet  closingChar 
  1548     |i direction lineString line col parChar charSet  closingChar 
  1549      ignoring delta endCol cc incSet decSet nesting maxLine|
  1549      ignoring delta endCol cc incSet decSet nesting maxLine ign skip|
  1550 
  1550 
  1551     charSet := #( $( $) $[ $] ${ $} " $< $> " ).
  1551     charSet := #( $( $) $[ $] ${ $} " $< $> " ).
  1552 
  1552 
  1553     parChar := self characterAtLine:startLine col:startCol.
  1553     parChar := self characterAtLine:startLine col:startCol.
  1554     i := charSet indexOf:parChar.
  1554     i := charSet indexOf:parChar.
  1581             direction == #fwd ifTrue:[
  1581             direction == #fwd ifTrue:[
  1582                 endCol := lineString size.
  1582                 endCol := lineString size.
  1583             ] ifFalse:[
  1583             ] ifFalse:[
  1584                 endCol := 1
  1584                 endCol := 1
  1585             ].
  1585             ].
       
  1586 
  1586             col to:endCol by:delta do:[:runCol |
  1587             col to:endCol by:delta do:[:runCol |
  1587                 cc := lineString at:runCol.
  1588                 cc := lineString at:runCol.
  1588 
  1589 
  1589                 (ignoreSet includes:cc) ifTrue:[
  1590                 ign := skip := false.
  1590                     ignoring := ignoring not
  1591                 ignoreSet do:[:ignore |
  1591                 ].
  1592                     ignore == cc ifTrue:[
  1592                 ignoring ifFalse:[
  1593                         ign := true
  1593                     (incSet includes:cc) ifTrue:[
       
  1594                         nesting := nesting + 1
       
  1595                     ] ifFalse:[
  1594                     ] ifFalse:[
  1596                         (decSet includes:cc) ifTrue:[
  1595                         ignore isString ifTrue:[
  1597                             nesting := nesting - 1
  1596                             cc == (ignore at:2) ifTrue:[
       
  1597                                 runCol > 1 ifTrue:[
       
  1598                                     (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
       
  1599                                         skip := true
       
  1600                                     ]
       
  1601                                 ]
       
  1602                             ] ifFalse:[
       
  1603                                 cc == (ignore at:1) ifTrue:[
       
  1604                                     runCol < lineString size ifTrue:[
       
  1605                                         (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
       
  1606                                             skip := true
       
  1607                                         ]
       
  1608                                     ]
       
  1609                                 ]
       
  1610                             ]
  1598                         ]
  1611                         ]
  1599                     ]
  1612                     ]
  1600                 ].
  1613                 ].
       
  1614 
       
  1615                 ign ifTrue:[
       
  1616                     ignoring := ignoring not
       
  1617                 ].
       
  1618 
       
  1619                 ignoring ifFalse:[
       
  1620                     skip ifFalse:[
       
  1621                         (incSet includes:cc) ifTrue:[
       
  1622                             nesting := nesting + 1
       
  1623                         ] ifFalse:[
       
  1624                             (decSet includes:cc) ifTrue:[
       
  1625                                 nesting := nesting - 1
       
  1626                             ]
       
  1627                         ]
       
  1628                     ]
       
  1629                 ].
       
  1630 
  1601                 nesting == 0 ifTrue:[
  1631                 nesting == 0 ifTrue:[
  1602                     "check if legal"
  1632                     "check if legal"
  1603 
  1633 
  1604                     cc == closingChar ifFalse:[
  1634                     skip ifFalse:[
  1605                         ^ failBlock value
  1635                         cc == closingChar ifFalse:[
  1606                     ].
  1636                             ^ failBlock value
  1607                     ^ foundBlock value:line value:runCol.
  1637                         ].
       
  1638                         ^ foundBlock value:line value:runCol.
       
  1639                     ]
  1608                 ]
  1640                 ]
  1609             ].
  1641             ].
  1610         ].
  1642         ].
  1611         line := line + delta.
  1643         line := line + delta.
  1612         (line < 1 or:[line > maxLine]) ifTrue:[
  1644         (line < 1 or:[line > maxLine]) ifTrue:[
  1617             col := 1
  1649             col := 1
  1618         ] ifFalse:[
  1650         ] ifFalse:[
  1619             col := lineString size
  1651             col := lineString size
  1620         ]
  1652         ]
  1621     ].
  1653     ].
  1622 
       
  1623     ^ notFoundBlock value
  1654     ^ notFoundBlock value
  1624 
  1655 
  1625     "Modified: 6.3.1996 / 14:58:29 / cg"
  1656     "Modified: 18.5.1996 / 11:38:35 / cg"
  1626 !
  1657 !
  1627 
  1658 
  1628 searchFwd
  1659 searchFwd
  1629     "search forward for pattern or selection"
  1660     "search forward for pattern or selection"
  1630 
  1661 
  2152 ! !
  2183 ! !
  2153 
  2184 
  2154 !TextView class methodsFor:'documentation'!
  2185 !TextView class methodsFor:'documentation'!
  2155 
  2186 
  2156 version
  2187 version
  2157     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.51 1996-05-17 06:58:30 cg Exp $'
  2188     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.52 1996-05-18 09:39:53 cg Exp $'
  2158 ! !
  2189 ! !