Bracket Matching could be much better
Posted: Fri May 09, 2003 3:09 pm
TextPad has two operations that work with brackets: MatchBracket, and MatchBracketExtend. Neither work the way they should.
The way MatchBracket currently works is that it searches forward for the next occurrence of a Bracket. But this does not reflect what a user is typically trying to do when they are matching brackets. The current text selection, or editing point, is typically inside the bracketed text. What MatchBracket should do is search backwards to find the bracket that applies to the current selection.
(Of course, if the current selection is a bracket, then MatchBracket should search forwards for the closing bracket of the pair. TextPad does this now so that's not the issue. It's the initial bracket search that's the issue.)
If TextPad searched backwards for brackets then it would be easier to expand to wider bracketing. Currently the only way to expand (find brackets that enclose brackets) is to do this from end brackets. You have to seach forwards from the end bracket, and then MatchBracket to the beginning bracket. Backwards searching would let users also expand from the start bracket.
OK so what about MatchBracketExtend? It's broken. What it seems to do is select all text between the current editing point (or start of selection), and the next bracket. This really not likely what a user needs. I suggest that MatchBracketExtend should select all the text enclosed by the "closest" brackets. That is, it should select the text between what two "fixed" MatchBracket commands in sequence would find (assuming a bracket wasn't currently selected): the previous start bracket, and its matching end. This is the minimum it should do.
Furthermore it would be very useful if MatchBracketExtend would expand the selection to the next outer bracket pairs if the current selection were already bracketed. In this way you could quickly click somewhere in nested text, do several MatchBracketExtend operations, and know the selection was "matched-up" bracket-wise. It would make indenting, cut/paste, search/replace, etc. much easier for nested text.
The way MatchBracket currently works is that it searches forward for the next occurrence of a Bracket. But this does not reflect what a user is typically trying to do when they are matching brackets. The current text selection, or editing point, is typically inside the bracketed text. What MatchBracket should do is search backwards to find the bracket that applies to the current selection.
(Of course, if the current selection is a bracket, then MatchBracket should search forwards for the closing bracket of the pair. TextPad does this now so that's not the issue. It's the initial bracket search that's the issue.)
If TextPad searched backwards for brackets then it would be easier to expand to wider bracketing. Currently the only way to expand (find brackets that enclose brackets) is to do this from end brackets. You have to seach forwards from the end bracket, and then MatchBracket to the beginning bracket. Backwards searching would let users also expand from the start bracket.
OK so what about MatchBracketExtend? It's broken. What it seems to do is select all text between the current editing point (or start of selection), and the next bracket. This really not likely what a user needs. I suggest that MatchBracketExtend should select all the text enclosed by the "closest" brackets. That is, it should select the text between what two "fixed" MatchBracket commands in sequence would find (assuming a bracket wasn't currently selected): the previous start bracket, and its matching end. This is the minimum it should do.
Furthermore it would be very useful if MatchBracketExtend would expand the selection to the next outer bracket pairs if the current selection were already bracketed. In this way you could quickly click somewhere in nested text, do several MatchBracketExtend operations, and know the selection was "matched-up" bracket-wise. It would make indenting, cut/paste, search/replace, etc. much easier for nested text.