diff --git a/lib/editor.tcl b/lib/editor.tcl index 2588002..10572a1 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -799,7 +799,7 @@ namespace eval Editor { bind $txt {OverWrite} bind $txt "Editor::SearchBrackets $txt" bind $txt "Editor::SelectionHighlight $txt" - bind $txt <> "SetModifiedFlag $w $nb" + bind $txt <> "SetModifiedFlag $w $nb auto" bind $txt "Editor::SearchBrackets %W" bind $txt "Editor::SearchBrackets %W" bind $txt "catch {Editor::GoToFunction $txt}" @@ -965,7 +965,7 @@ namespace eval Editor { set nbEditorItem [NB::InsertItem $nbEditor $fileFullPath "file"] # puts "$nbEditorItem, $nbEditor" Editor $fileFullPath $nbEditor $nbEditorItem - SetModifiedFlag $nbEditorItem $nbEditor + SetModifiedFlag $nbEditorItem $nbEditor force focus -force $nbEditorItem.frmText.t.t } diff --git a/lib/files.tcl b/lib/files.tcl index b3c2996..42de62b 100644 --- a/lib/files.tcl +++ b/lib/files.tcl @@ -489,7 +489,7 @@ namespace eval FileOper { set txt $itemName.frmText.t if ![string match "*untitled*" $itemName] { set file [open "$fileFullPath" r] - $txt insert end [chan read -nonewline $file] + $txt insert end [chan read -nonewline $file] close $file } # Delete emty last line @@ -497,6 +497,11 @@ namespace eval FileOper { $txt delete {end-1 line} end # puts ">[$txt get {end-1 line} end]<" } + # ------------ + # Thanks https://github.com/wandrien/ + # https://github.com/wandrien/projman/commit/7d5539ac2031fbdcb0f4a97465ff19d0c348cf33 + $txt edit reset + # ----------- $txt see 1.0 } diff --git a/lib/procedure.tcl b/lib/procedure.tcl index 954a42a..2493408 100644 --- a/lib/procedure.tcl +++ b/lib/procedure.tcl @@ -195,9 +195,19 @@ proc ResetModifiedFlag {w nbEditor} { # puts "ResetModifiedFlag: $lbl" $nbEditor tab $w -text $lbl } -proc SetModifiedFlag {w nbEditor} { +proc SetModifiedFlag {w nbEditor flag} { global modified - #$w.frmText.t edit modified false + # ------------ + # Thanks https://github.com/wandrien/ + # https://github.com/wandrien/projman/commit/04e5c892ae06d3e013472d292cd4435804184f6b + if {$flag eq "force"} { + $w.frmText.t edit modified true + } else { + if {![$w.frmText.t edit modified]} { + return + } + } + # --------- set modified($w) "true" set lbl [$nbEditor tab $w -text] # puts "SetModifiedFlag: $w; $modified($w); >$lbl<"