Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
SHA1 Hash: | 799e26e2ccc05360588a15154f2a645e3a30605e |
---|---|
Date: | 2011-04-19 01:26:51 |
User: | btheado |
Comment: | Fixed bug where insertion of text into a multi-line node would cause the cursor to jump to a different line |
Tags And Properties
- branch=master inherited from [9501cd780c]
- sym-master inherited from [9501cd780c]
Changes
[hide diffs]Changes to lib/outlinewidget/treedisplay.tcl
@@ -257,11 +257,22 @@ # to the tree is tagged with "modified" proc markModifiedText {tree win idx args} { # Remove the underscore from the window name set win [string range [namespace tail $win] 1 end] if {[isIdxInNodeText $win $idx]} { - $win tag add modified "$idx linestart" "$idx lineend" + # This commented out line contributed to a bug where the insertion + # cursor would jump backwards by at least one line whenever text + # was typed into the second or later line in a multi-line node (i.e. a + # node with linefeed embedded). The intention is to mark the whole + # node as modified, but it uses a bad assumption that a node does not + # span across multiple lines. Bug reported by Robert Abitbol + #$win tag add modified "$idx linestart" "$idx lineend" + + # Here is better code which adds the 'modified' tag to the entire node + set node [listitem::itemAtIdx $win $idx] + $win tag add modified [listitem::index $win $node.first] \ + [listitem::index $win $node.last] after idle [namespace code [list saveChangedTextToTree $win $tree]] } } proc watchForModifiedText {win tree} { replaceCallback $win before insert "[namespace current]::markModifiedText $tree" @@ -430,33 +441,35 @@ set margin2 [expr $margin1 + [font measure [option get $win bulletFont Text] "[option get $win indentString Text] "]] $win tag configure item:$node -lmargin1 $margin1 $win tag configure item:$node -lmargin2 $margin2 } - # Returns the node the given index is on and the number of characters # within that node's text the index is offset. It also returns # a boolean indicating whether or not the given index is currently -# visible +# visible. proc getCursorInfo {win index} { - set node [listitem::itemAtIdx $win $index] - if {[string length $node] > 0} { - scan [$win index $index] %d.%d line insertChar - scan [$win index [getNodeTextStartIdx $win $node]] %d.%d line startChar - set offset [expr $insertChar - $startChar] - } else { + set node [listitem::itemAtIdx $win $index] + if {[string length $node] > 0} { + scan [$win index $index] %d.%d insertLine insertChar + scan [$win index "[getNodeTextStartIdx $win $node] linestart"] %d.%d startLine startChar + set offset [list \ + [expr $insertLine - $startLine] \ + [expr $insertChar - $startChar]] + } else { set offset "" - } - set isCursorVisible [expr [llength [$win bbox $index]] > 0] - return [list $node $offset $isCursorVisible] + } + set isCursorVisible [expr [llength [$win bbox $index]] > 0] + return [list $node $offset $isCursorVisible] } proc restoreInsertionCursor {win cursorInfo} { set node [lindex $cursorInfo 0] - set offset [lindex $cursorInfo 1] + set lineOffset [lindex $cursorInfo 1 0] + set charOffset [lindex $cursorInfo 1 1] set wasCursorVisible [lindex $cursorInfo 2] if {[listitem::exists $win $node]} { - $win mark set insert [getNodeTextStartIdx $win $node]+${offset}c + $win mark set insert "[getNodeTextStartIdx $win $node] linestart +${lineOffset}l+${charOffset}c" } if {$wasCursorVisible} { $win see insert } }