Добавлено отображение структуры исходника в дереве (функции (go) и процедуры (tcl))
This commit is contained in:
parent
0e8be7bbfd
commit
ccff397b69
|
@ -42,3 +42,10 @@
|
||||||
27/07/2022
|
27/07/2022
|
||||||
- Fixed comment/uncomment procedure (last line in selected text)
|
- Fixed comment/uncomment procedure (last line in selected text)
|
||||||
- Fixed error with save new (untitled) file
|
- Fixed error with save new (untitled) file
|
||||||
|
|
||||||
|
01/08/2022
|
||||||
|
- Added inserting base64 encoded image
|
||||||
|
- Added read the file structure and inserting into tree
|
||||||
|
- Added GUI font, and GUI foreground color setting
|
||||||
|
- Added tcl and go files images
|
||||||
|
- Added image for file type (extention)
|
||||||
|
|
|
@ -351,6 +351,7 @@ namespace eval Editor {
|
||||||
#bind $txt <Shift-Button-5> "%W xview scroll 2 units"
|
#bind $txt <Shift-Button-5> "%W xview scroll 2 units"
|
||||||
bind $txt <<Modified>> "SetModifiedFlag $w"
|
bind $txt <<Modified>> "SetModifiedFlag $w"
|
||||||
bind $txt <<Selection>> "Editor::SelectionGet $txt"
|
bind $txt <<Selection>> "Editor::SelectionGet $txt"
|
||||||
|
bind $txt <Control-i> ImageBase64Encode
|
||||||
}
|
}
|
||||||
|
|
||||||
proc QuotSelection {txt symbol} {
|
proc QuotSelection {txt symbol} {
|
||||||
|
@ -403,6 +404,39 @@ namespace eval Editor {
|
||||||
Editor $fileFullPath $nbEditor $nbEditorItem
|
Editor $fileFullPath $nbEditor $nbEditorItem
|
||||||
SetModifiedFlag $nbEditorItem
|
SetModifiedFlag $nbEditorItem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc ReadStructure {txt treeItemName} {
|
||||||
|
global tree nbEditor
|
||||||
|
for {set lineNumber 0} {$lineNumber <= [$txt count -lines 0.0 end]} {incr lineNumber} {
|
||||||
|
set line [$txt get $lineNumber.0 $lineNumber.end]
|
||||||
|
# TCL procedure
|
||||||
|
if {[regexp -nocase -all -- {^\s*?(proc) (::|)(\w+)(::|)(\w+)\s*?(\{|\()(.*)(\}|\)) \{} $line match v1 v2 v3 v4 v5 v6 params v8]} {
|
||||||
|
set procName "$v2$v3$v4$v5"
|
||||||
|
# lappend procList($activeProject) [list $procName [string trim $params]]
|
||||||
|
puts "$treeItemName proc $procName $params"
|
||||||
|
# tree parent item type text
|
||||||
|
puts [Tree::InsertItem $tree $treeItemName $procName "func" "$procName ($params)"]
|
||||||
|
}
|
||||||
|
# GO function
|
||||||
|
if {[regexp -nocase -all -- {^\s*?func\s*?\((\w+\s*?\*\w+)\)\s*?(\w+)\((.*?)\)\s*?\((.*?)\)} $line match v1 funcName params returns]} {
|
||||||
|
# set procName "$v2$v3$v4$v5"
|
||||||
|
# lappend procList($activeProject) [list $procName [string trim $params]]
|
||||||
|
if {$v1 ne ""} {
|
||||||
|
set linkName [lindex [split $v1 " "] 1]
|
||||||
|
set funcName "\($linkName\).$funcName"
|
||||||
|
}
|
||||||
|
puts "$treeItemName proc $funcName $params"
|
||||||
|
# tree parent item type text
|
||||||
|
puts [Tree::InsertItem $tree $treeItemName $funcName "func" "$funcName ($params)"]
|
||||||
|
}
|
||||||
|
if {[regexp -nocase -all -- {^\s*?func\s*?(\w+)\((.*?)\) (\(\w+\)|\w+|)\s*?\{} $line match funcName params returns]} {
|
||||||
|
puts "$treeItemName proc $funcName $params"
|
||||||
|
# tree parent item type text
|
||||||
|
puts [Tree::InsertItem $tree $treeItemName $funcName "func" "$funcName ($params)"]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
proc Editor {fileFullPath nb itemName} {
|
proc Editor {fileFullPath nb itemName} {
|
||||||
global cfgVariables
|
global cfgVariables
|
||||||
|
@ -411,6 +445,7 @@ namespace eval Editor {
|
||||||
set lblText $fileFullPath
|
set lblText $fileFullPath
|
||||||
} else {
|
} else {
|
||||||
set lblText ""
|
set lblText ""
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set lblName "lbl[string range $itemName [expr [string last "." $itemName] +1] end]"
|
set lblName "lbl[string range $itemName [expr [string last "." $itemName] +1] end]"
|
||||||
|
|
|
@ -189,7 +189,7 @@ namespace eval FileOper {
|
||||||
set fileName [file tail $fileFullPath]
|
set fileName [file tail $fileFullPath]
|
||||||
regsub -all {\.|/|\\|\s} $fileFullPath "_" itemName
|
regsub -all {\.|/|\\|\s} $fileFullPath "_" itemName
|
||||||
set itemName "$nbEditor.$itemName"
|
set itemName "$nbEditor.$itemName"
|
||||||
puts [Tree::InsertItem $tree {} $fileFullPath "file" $fileName]
|
set treeItemName [Tree::InsertItem $tree {} $fileFullPath "file" $fileName]
|
||||||
if {[winfo exists $itemName] == 0} {
|
if {[winfo exists $itemName] == 0} {
|
||||||
NB::InsertItem $nbEditor $fileFullPath "file"
|
NB::InsertItem $nbEditor $fileFullPath "file"
|
||||||
Editor::Editor $fileFullPath $nbEditor $itemName
|
Editor::Editor $fileFullPath $nbEditor $itemName
|
||||||
|
@ -198,6 +198,7 @@ namespace eval FileOper {
|
||||||
ResetModifiedFlag $itemName
|
ResetModifiedFlag $itemName
|
||||||
}
|
}
|
||||||
$nbEditor select $itemName
|
$nbEditor select $itemName
|
||||||
|
Editor::ReadStructure $itemName.frmText.t $treeItemName
|
||||||
focus -force $itemName.frmText.t
|
focus -force $itemName.frmText.t
|
||||||
|
|
||||||
return $itemName
|
return $itemName
|
||||||
|
|
|
@ -160,4 +160,8 @@ if {$cfgVariables(toolBarShow) eq "true"} {
|
||||||
.frmBody.panel add $frmTree -weight 0
|
.frmBody.panel add $frmTree -weight 0
|
||||||
}
|
}
|
||||||
.frmBody.panel add $frm_work -weight 1
|
.frmBody.panel add $frm_work -weight 1
|
||||||
# #
|
|
||||||
|
ttk::style configure . \
|
||||||
|
-foreground $::cfgVariables(guiFG) \
|
||||||
|
-font $::cfgVariables(guiFont)
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,9 @@ proc GetEditMenu {m} {
|
||||||
-accelerator "Ctrl+Shift+F"
|
-accelerator "Ctrl+Shift+F"
|
||||||
$m add command -label [::msgcat::mc "Replace in files"] -command File::Replace\
|
$m add command -label [::msgcat::mc "Replace in files"] -command File::Replace\
|
||||||
-accelerator "Ctrl+Shift+RV"
|
-accelerator "Ctrl+Shift+RV"
|
||||||
|
$m add separator
|
||||||
|
$m add command -label [::msgcat::mc "Insert image"] -accelerator "Ctrl+I"\
|
||||||
|
-command ImageBase64Encode
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,4 +64,3 @@ proc GetViewMenu {m} {
|
||||||
$m add command -label [::msgcat::mc "View files tree"] -command ViewFilesTree
|
$m add command -label [::msgcat::mc "View files tree"] -command ViewFilesTree
|
||||||
$m add command -label [::msgcat::mc "View line numbers"] -command ViewLineNumbers
|
$m add command -label [::msgcat::mc "View line numbers"] -command ViewLineNumbers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,3 +73,34 @@ proc SetModifiedFlag {w} {
|
||||||
}
|
}
|
||||||
$nbEditor tab $w -text $lbl
|
$nbEditor tab $w -text $lbl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc ImageBase64Encode {} {
|
||||||
|
global env nbEditor
|
||||||
|
set types {
|
||||||
|
{"PNG" {.png}}
|
||||||
|
{"GIF" {.gif}}
|
||||||
|
{"JPEG" {.jpg}}
|
||||||
|
{"BMP" {.bmp}}
|
||||||
|
{"All files" *}
|
||||||
|
}
|
||||||
|
set txt "[$nbEditor select].frmText.t"
|
||||||
|
set img [tk_getOpenFile -initialdir $env(HOME) -filetypes $types -parent .]
|
||||||
|
if {$img ne ""} {
|
||||||
|
set f [open $img]
|
||||||
|
fconfigure $f -translation binary
|
||||||
|
set data [base64::encode [read $f]]
|
||||||
|
close $f
|
||||||
|
# base name on root name of the image file
|
||||||
|
set name [file root [file tail $img]]
|
||||||
|
$txt insert insert "image create photo $name -data {\n$data\n}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
proc FindImage {ext} {
|
||||||
|
foreach img [image names] {
|
||||||
|
if [regexp -nocase -all -- "^($ext)(_)" $img match v1 v2] {
|
||||||
|
puts "\nFindinig images: $img \n"
|
||||||
|
return $img
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
22
lib/tree.tcl
22
lib/tree.tcl
|
@ -19,21 +19,33 @@ namespace eval Tree {
|
||||||
switch $type {
|
switch $type {
|
||||||
file {
|
file {
|
||||||
regsub -all {\.|/|\\|\s} $item "_" subNode
|
regsub -all {\.|/|\\|\s} $item "_" subNode
|
||||||
puts $subNode
|
puts "Inserted tree node: $subNode"
|
||||||
set image imgFile
|
set fileExt [string trimleft [file extension $text] "."]
|
||||||
|
set findImg [::FindImage $fileExt]
|
||||||
|
puts "Extention $fileExt, find image: $findImg"
|
||||||
|
if {$fileExt ne "" && $findImg ne ""} {
|
||||||
|
set image $findImg
|
||||||
|
} else {
|
||||||
|
set image imgFile
|
||||||
|
}
|
||||||
}
|
}
|
||||||
directory {
|
directory {
|
||||||
regsub -all {\.|/|\\|\s} $item "_" subNode
|
regsub -all {\.|/|\\|\s} $item "_" subNode
|
||||||
puts $subNode
|
puts $subNode
|
||||||
set image folder
|
set image folder
|
||||||
}
|
}
|
||||||
|
func {
|
||||||
|
regsub -all {:} $item "_" subNode
|
||||||
|
puts $subNode
|
||||||
|
set image proc_10x10
|
||||||
|
}
|
||||||
}
|
}
|
||||||
append id $type "::" $subNode
|
append id $type "::" $subNode
|
||||||
puts $id
|
puts "Tree ID: $id, tree item: $item"
|
||||||
if ![$tree exists $id] {
|
if ![$tree exists $id] {
|
||||||
$tree insert $parent end -id "$id" -text $text -values "$item" -image $image
|
$tree insert $parent end -id "$id" -text " $text" -values "$item" -image $image
|
||||||
}
|
}
|
||||||
return "$id"
|
return "$id"
|
||||||
}
|
}
|
||||||
proc DoublePressItem {tree} {
|
proc DoublePressItem {tree} {
|
||||||
set id [$tree selection]
|
set id [$tree selection]
|
||||||
|
|
|
@ -35,9 +35,11 @@ if { $::argc > 0 } {
|
||||||
}
|
}
|
||||||
puts $opened
|
puts $opened
|
||||||
}
|
}
|
||||||
|
|
||||||
package require msgcat
|
package require msgcat
|
||||||
package require inifile
|
package require inifile
|
||||||
package require ctext
|
package require ctext
|
||||||
|
package require base64
|
||||||
|
|
||||||
# Устанавливаем текущий каталог
|
# Устанавливаем текущий каталог
|
||||||
set dir(root) [pwd]
|
set dir(root) [pwd]
|
||||||
|
|
|
@ -11,7 +11,7 @@ package require Tk
|
||||||
namespace eval ttk::theme::dark {
|
namespace eval ttk::theme::dark {
|
||||||
variable version 0.0.1
|
variable version 0.0.1
|
||||||
variable dir [file dirname [info script]]
|
variable dir [file dirname [info script]]
|
||||||
|
global cfgVariables
|
||||||
package provide ttk::theme::dark $version
|
package provide ttk::theme::dark $version
|
||||||
|
|
||||||
# NB: These colors must be in sync with the ones in black.rdb
|
# NB: These colors must be in sync with the ones in black.rdb
|
||||||
|
@ -46,7 +46,7 @@ namespace eval ttk::theme::dark {
|
||||||
-selectbackground $colors(-selectbg) \
|
-selectbackground $colors(-selectbg) \
|
||||||
-selectforeground $colors(-selectfg) \
|
-selectforeground $colors(-selectfg) \
|
||||||
-selectborderwidth 0 \
|
-selectborderwidth 0 \
|
||||||
-font "{Droid Sans Mono} 10"
|
-font "{Droid Sans Mono} 9"
|
||||||
|
|
||||||
ttk::style map "." \
|
ttk::style map "." \
|
||||||
-background [list disabled $colors(-frame) \
|
-background [list disabled $colors(-frame) \
|
||||||
|
@ -121,46 +121,3 @@ namespace eval ttk::theme::dark {
|
||||||
# option add *Entry.Background $colors(-frame) interactive
|
# option add *Entry.Background $colors(-frame) interactive
|
||||||
# option add *Entry.Foreground $colors(-foreground) interactive
|
# option add *Entry.Foreground $colors(-foreground) interactive
|
||||||
}
|
}
|
||||||
|
|
||||||
# A few tricks for Tablelist.
|
|
||||||
|
|
||||||
namespace eval ::tablelist:: {
|
|
||||||
proc blackTheme {} {
|
|
||||||
variable themeDefaults
|
|
||||||
|
|
||||||
array set colors [array get ttk::theme::dark::colors]
|
|
||||||
|
|
||||||
array set themeDefaults [list \
|
|
||||||
-background "#000000" \
|
|
||||||
-foreground "#ffffff" \
|
|
||||||
-disabledforeground $colors(-disabledfg) \
|
|
||||||
-stripebackground "#191919" \
|
|
||||||
-selectbackground "#4a6984" \
|
|
||||||
-selectforeground "#8b8b00" \
|
|
||||||
-selectborderwidth 0 \
|
|
||||||
-font TkTextFont \
|
|
||||||
-labelbackground $colors(-frame) \
|
|
||||||
-labeldisabledBg "#dcdad5" \
|
|
||||||
-labelactiveBg "#eeebe7" \
|
|
||||||
-labelpressedBg "#eeebe7" \
|
|
||||||
-labelforeground #ffffff \
|
|
||||||
-labeldisabledFg "#999999" \
|
|
||||||
-labelactiveFg #ffffff \
|
|
||||||
-labelpressedFg #ffffff \
|
|
||||||
-labelfont TkDefaultFont \
|
|
||||||
-labelborderwidth 2 \
|
|
||||||
-labelpady 1 \
|
|
||||||
-arrowcolor "" \
|
|
||||||
-arrowstyle sunken10x9 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user