Исправлен флаг модификации при открытии файла, исправлена 'Отмена' до пустого файла. Внес исправления на основе изменений https://github.com/wandrien/projman

This commit is contained in:
svk
2026-01-21 12:24:08 +03:00
parent 96dd7a1b4b
commit 4f01a1fbd7
3 changed files with 20 additions and 5 deletions

View File

@@ -799,7 +799,7 @@ namespace eval Editor {
bind $txt <Insert> {OverWrite}
bind $txt <ButtonRelease-1> "Editor::SearchBrackets $txt"
bind $txt <Button-1><ButtonRelease-1> "Editor::SelectionHighlight $txt"
bind $txt <<Modified>> "SetModifiedFlag $w $nb"
bind $txt <<Modified>> "SetModifiedFlag $w $nb auto"
bind $txt <Control-u> "Editor::SearchBrackets %W"
bind $txt <Control-Cyrillic_ghe> "Editor::SearchBrackets %W"
bind $txt <Control-J> "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
}

View File

@@ -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
}

View File

@@ -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<"