diff --git a/CHANGELOG b/CHANGELOG index 6a90254..2059159 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -99,3 +99,9 @@ - Alt+e - delete text between cursor and line End - Fix close braces indent +30/08/2022 + - Fix the clicked by the close button on a tab + - Added "View"->"Editors word wrap" menu and procedure + - Added bindings "Ctrl+PgUp" and "Ctrl+PgDown" for next or prior tab selecting + - Added "Close file" dialog + diff --git a/lib/editor.tcl b/lib/editor.tcl index e4caf6d..7f4ff86 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -9,26 +9,23 @@ namespace eval Editor { variable selectionTex + # Set the editor option + proc SetOption {optionName value} { + global cfgVariables nbEditor + # apply changes for opened tabs + foreach node [$nbEditor tabs] { + $node.frmText.t configure -$optionName $value + } + } + + # Comment one string or selected string proc Comment {txt fileType} { global lexers set selIndex [$txt tag ranges sel] set pos [$txt index insert] set lineNum [lindex [split $pos "."] 0] set PosNum [lindex [split $pos "."] 1] - # switch $fileType { - # TCL { - # set symbol "#" - # } - # GO { - # set symbol "//" - # } - # Unknown { - # set symbol "#" - # } - # default { - # set symbol "#" - # } - # } + if [dict exists $lexers $fileType commentSymbol] { set symbol [dict get $lexers $fileType commentSymbol] } else { @@ -57,6 +54,8 @@ namespace eval Editor { $txt tag raise comments } } + + # Uncomment one string selected strings proc Uncomment {txt fileType} { set selIndex [$txt tag ranges sel] set pos [$txt index insert] @@ -456,8 +455,8 @@ namespace eval Editor { # bind $txt "" bind $txt "ImageBase64Encode $txt" - # bind $txt "Editor::InsertTabular $txt" - # bind $txt "Editor::DeleteTabular $txt" + bind $txt "Editor::InsertTabular $txt" + bind $txt "Editor::DeleteTabular $txt" bind $txt "Editor::Comment $txt $fileType" bind $txt "Editor::Uncomment $txt $fileType" @@ -785,13 +784,15 @@ namespace eval Editor { set txt $frmText.t pack $frmText -side top -expand true -fill both - pack [ttk::scrollbar $frmText.s -command "$frmText.t yview"] -side right -fill y - ctext $txt -yscrollcommand "$frmText.s set" -font $cfgVariables(font) \ + pack [ttk::scrollbar $frmText.v -command "$frmText.t yview"] -side right -fill y + ttk::scrollbar $frmText.h -orient horizontal -command "$frmText.t xview" + ctext $txt -xscrollcommand "$frmText.h set" -yscrollcommand "$frmText.v set" \ + -font $cfgVariables(font) -relief flat -wrap $cfgVariables(editorWrap) \ -linemapfg $cfgVariables(lineNumberFG) -linemapbg $cfgVariables(lineNumberBG) \ - -tabs "[expr {4 * [font measure $cfgVariables(font) 0]}] left" -tabstyle tabular -undo true \ - -relief flat + -tabs "[expr {4 * [font measure $cfgVariables(font) 0]}] left" -tabstyle tabular -undo true pack $txt -fill both -expand 1 + pack $frmText.h -side bottom -fill x # puts ">>>>>>> [bindtags $txt]" if {$cfgVariables(lineNumberShow) eq "false"} { $txt configure -linemap 0 diff --git a/lib/files.tcl b/lib/files.tcl index 065a40a..8993981 100644 --- a/lib/files.tcl +++ b/lib/files.tcl @@ -48,6 +48,28 @@ namespace eval FileOper { return $fullPath } + proc CloseFolder {} { + global tree nbEditor + set treeItem [$tree selection] + set parent [$tree parent $treeItem] + while {$parent ne ""} { + set treeItem $parent + set parent [$tree parent $treeItem] + } + if {$parent eq "" && [string match "directory::*" $treeItem] == 1} { + # puts "tree root item: $treeItem" + foreach nbItem [$nbEditor tabs] { + set item [string trimleft [file extension $nbItem] "."] + # puts $item + if [$tree exists "file::$item"] { + $nbEditor select $nbItem + Close + } + } + $tree delete $treeItem + } + } + proc CloseAll {} { global nbEditor modified foreach nbItem [array names modified] { @@ -150,6 +172,7 @@ namespace eval FileOper { return "" } set parent [Tree::InsertItem $tree {} $directory "directory" [file tail $directory]] + $tree selection set $parent # if {[ $tree item $parent -open] eq "false"} { # $tree item $parent -open true # } else { diff --git a/lib/gui.tcl b/lib/gui.tcl index d92f23f..473aa04 100644 --- a/lib/gui.tcl +++ b/lib/gui.tcl @@ -56,7 +56,9 @@ bind . { } bind . {FileOper::Save} bind . {FileOper::Save} -bind . ViewFilesTree +bind . ViewFilesTree + + #ttk::style configure TPanedwindow -background blue #ttk::style configure Sash -sashthickness 5 #ttk::style configure TButton -padding 60 -relief flat -bg black @@ -149,9 +151,12 @@ ttk::style layout TNotebook.Tab { } } } +bind TNotebook "catch {NB::PressTab %W %x %y}\;[bind TNotebook ];break" +# bind <> "NB::PressTab %W %x %y" -bind TNotebook "NB::CloseTab %W %x %y\;[bind TNotebook ]" - +# bind . "NB::NextTab $nbEditor" +bind . "NB::NextTab $nbEditor 1" +bind . "NB::NextTab $nbEditor -1" # ttk::scrollbar $nbEditor.hsb1 -orient horizontal -command [list $frm_tree.work xview] # ttk::scrollbar $fbEditor.vsb1 -orient vertical -command [list $frm_tree.work yview] # set tree [ttk::treeview $frm_tree.tree -show tree \ diff --git a/lib/menu.tcl b/lib/menu.tcl index ddb6bf4..4de1943 100644 --- a/lib/menu.tcl +++ b/lib/menu.tcl @@ -17,14 +17,18 @@ proc GetFileMenu {m} { FileOper::Edit $filePath } } + $m add command -label [::msgcat::mc "Save file"] -command {FileOper::Save}\ + -accelerator "Ctrl+S" + $m add command -label [::msgcat::mc "Close file"] -command {FileOper::Close}\ + -accelerator "Ctrl+w" $m add command -label [::msgcat::mc "Open folder"] -accelerator "Ctrl+K" -command { set folderPath [FileOper::OpenFolderDialog] if {$folderPath != ""} { FileOper::ReadFolder $folderPath } } - $m add command -label [::msgcat::mc "Save file"] -command {FileOper::Save}\ - -accelerator "Ctrl+S" + $m add command -label [::msgcat::mc "Close folder"] -command {FileOper::CloseFolder} + #$m add command -label [::msgcat::mc "Open"] -command {FileDialog $tree open}\ #-font $fontNormal -accelerator "Ctrl+O" -state disable $m add separator @@ -68,8 +72,18 @@ proc GetViewMenu {m} { $m.panelSide add radiobutton -label [::msgcat::mc "Left"] -variable cfgVariables(filesPanelPlace) -value left $m.panelSide add radiobutton -label [::msgcat::mc "Right"] -variable cfgVariables(filesPanelPlace) -value right - + + $m add separator $m add command -label [::msgcat::mc "View line numbers"] -command ViewLineNumbers + + menu $m.editorWrap + $m add cascade -label [::msgcat::mc "Editors word wrapping"] -menu $m.editorWrap + $m.editorWrap add radiobutton -label [::msgcat::mc "None"] -variable cfgVariables(editorWrap) -value none \ + -command "Editor::SetOption wrap $cfgVariables(editorWrap)" + $m.editorWrap add radiobutton -label [::msgcat::mc "Char"] -variable cfgVariables(editorWrap) -value char \ + -command "Editor::SetOption wrap $cfgVariables(editorWrap)" + $m.editorWrap add radiobutton -label [::msgcat::mc "Word"] -variable cfgVariables(editorWrap) -value word \ + -command "Editor::SetOption wrap $cfgVariables(editorWrap)" } proc GetHelpMenu {m} { diff --git a/lib/msgs/ru.msg b/lib/msgs/ru.msg index e811533..6ecf0df 100644 --- a/lib/msgs/ru.msg +++ b/lib/msgs/ru.msg @@ -19,8 +19,11 @@ ::msgcat::mcset ru "Braces foreground" "Цвет скобки" ::msgcat::mcset ru "Cancel" "Отмена" ::msgcat::mcset ru "Can't found file:" "Не найден файл:" +::msgcat::mcset ru "Char" "Символ" ::msgcat::mcset ru "Close" "Закрыть" ::msgcat::mcset ru "Close all" "Закрыть все" +::msgcat::mcset ru "Close file" "Закрыть файл" +::msgcat::mcset ru "Close folder" "Закрыть папку" ::msgcat::mcset ru "Close Project Manager?" "Выйти из программы?" ::msgcat::mcset ru "Comments" "Коментарии" ::msgcat::mcset ru "Comment selected" "Закоментировать" @@ -113,6 +116,7 @@ ::msgcat::mcset ru "New project" "Новый проект" ::msgcat::mcset ru "Not implemented yet" "Данная функция пока не реализована" ::msgcat::mcset ru "Not found active project" "Не определен активный проект" +::msgcat::mcset ru "None" "Нет" ::msgcat::mcset ru "No" "Нет" ::msgcat::mcset ru "Open" "Открыть" ::msgcat::mcset ru "Open file" "Открыть файл" @@ -193,6 +197,7 @@ ::msgcat::mcset ru "View line numbers" "Показывать номера строк" ::msgcat::mcset ru "Warning" "Внимание" ::msgcat::mcset ru "Was replacement" "Было заменено" -::msgcat::mcset ru "Word wrapping" "Перенос слов" +::msgcat::mcset ru "Word" "Слово" +::msgcat::mcset ru "Editors word wrapping" "Перенос слов в редакторе" ::msgcat::mcset ru "Work dir" "Рабочий каталог" ::msgcat::mcset ru "Yes" "Да" diff --git a/lib/notebook.tcl b/lib/notebook.tcl index 32175c6..8d0c7c9 100644 --- a/lib/notebook.tcl +++ b/lib/notebook.tcl @@ -24,13 +24,31 @@ namespace eval NB { } } } - puts "NB item - $fm" + # puts "NB item - $fm" return $fm } - proc CloseTab {w x y} { + proc PressTab {w x y} { + $w select [$w identify tab $x $y] if {[$w identify $x $y] == "close_button"} { FileOper::Close + } else { + set txt [$w select].frmText.t + focus -force $txt.t } } + + proc NextTab {w step} { + set i [expr [$w index end] - 1] + set nbItemIndex [$w index [$w select]] + if {$nbItemIndex eq 0 && $step eq "-1"} { + $w select $i + } elseif {$nbItemIndex eq $i && $step eq "1"} { + $w select 0 + } else { + $w select [expr $nbItemIndex + $step] + } + set txt [$w select].frmText.t + focus -force $txt.t + } } diff --git a/projman.tcl b/projman.tcl index ac01f81..9f2f875 100755 --- a/projman.tcl +++ b/projman.tcl @@ -10,7 +10,7 @@ exec wish "$0" -- "$@" ###################################################### # Version: 2.0.0 # Release: alpha -# Build: 26082022165531 +# Build: 30082022164258 ###################################################### # определим текущую версию, релиз и т.д.