2022-07-21 10:56:46 +03:00
|
|
|
######################################################
|
|
|
|
# ProjMan 2
|
|
|
|
# Distributed under GNU Public License
|
|
|
|
# Author: Sergey Kalinin svk@nuk-svk.ru
|
|
|
|
# Copyright (c) "", 2022, https://nuk-svk.ru
|
|
|
|
######################################################
|
|
|
|
# Working with files module
|
|
|
|
######################################################
|
|
|
|
|
|
|
|
|
|
|
|
namespace eval FileOper {
|
|
|
|
variable types
|
|
|
|
|
|
|
|
set ::types {
|
|
|
|
{"All files" *}
|
2022-11-10 14:53:58 +03:00
|
|
|
}
|
|
|
|
|
2022-11-10 15:36:34 +03:00
|
|
|
proc GetFileMimeType {fileFullPath {opt ""}} {
|
2022-11-10 14:53:58 +03:00
|
|
|
global cfgVariables
|
|
|
|
# Проверям наличие программы в системе, если есть то добавляем опции
|
|
|
|
# если нет то используем тиклевый пакет
|
|
|
|
if [file exists $cfgVariables(fileTypeCommand)] {
|
|
|
|
set cmd exec
|
|
|
|
lappend cmd $cfgVariables(fileTypeCommand)
|
|
|
|
foreach _ [split $cfgVariables(fileTypeCommandOptions) " "] {
|
|
|
|
lappend cmd $_
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
set cmd [list eval ::fileutil::magic::filetype]
|
|
|
|
}
|
|
|
|
|
|
|
|
# lappend cmd $activeProject
|
|
|
|
lappend cmd $fileFullPath
|
|
|
|
catch $cmd pipe
|
2022-11-10 15:36:34 +03:00
|
|
|
# puts $pipe
|
2022-11-14 09:27:15 +03:00
|
|
|
if [regexp -nocase -- {(\w+)/([\w\-_\.]+); charset=([[:alnum:]-]+)} $pipe m fType fExt fCharset] {
|
2022-11-10 14:53:58 +03:00
|
|
|
puts "$fType $fExt $fCharset"
|
|
|
|
}
|
|
|
|
switch $opt {
|
|
|
|
"charset" {
|
|
|
|
if [info exists fCharset] {
|
|
|
|
return $fCharset
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch $fType {
|
|
|
|
"application" {
|
|
|
|
if {$fExt ne "json"} {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"text" {
|
|
|
|
return text
|
|
|
|
}
|
|
|
|
"image" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
default {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
## GETTING FILE ATTRIBUTES ##
|
|
|
|
proc GetFileAttr {file {opt ""}} {
|
|
|
|
global tcl_platform
|
|
|
|
set fileAttribute ""
|
|
|
|
# get file modify time
|
|
|
|
switch $opt {
|
|
|
|
attr {
|
|
|
|
if {$tcl_platform(platform) == "windows"} {
|
|
|
|
set unixTime [file mtime $file]
|
|
|
|
set modifyTime [clock format $unixTime -format "%d/%m/%Y, %H:%M"]
|
|
|
|
} elseif {$tcl_platform(platform) == "mac"} {
|
|
|
|
|
|
|
|
} elseif {$tcl_platform(platform) == "unix"} {
|
|
|
|
set unixTime [file mtime $file]
|
|
|
|
set modifyTime [clock format $unixTime -format "%d/%m/%Y, %H:%M"]
|
|
|
|
}
|
|
|
|
return $modifyTime
|
|
|
|
}
|
|
|
|
size {
|
|
|
|
# get file size
|
|
|
|
set size [file size $file]
|
|
|
|
if {$size < 1024} {
|
|
|
|
set fileSize "$size b"
|
|
|
|
}
|
|
|
|
if {$size >= 1024} {
|
|
|
|
set s [expr ($size.0) / 1024]
|
|
|
|
set dot [string first "\." $s]
|
|
|
|
set int [string range $s 0 [expr $dot - 1]]
|
|
|
|
set dec [string range $s [expr $dot + 1] [expr $dot + 2]]
|
|
|
|
set fileSize "$int.$dec Kb"
|
|
|
|
}
|
|
|
|
if {$size >= 1048576} {
|
|
|
|
set s [expr ($size.0) / 1048576]
|
|
|
|
set dot [string first "\." $s]
|
|
|
|
set int [string range $s 0 [expr $dot - 1]]
|
|
|
|
set dec [string range $s [expr $dot + 1] [expr $dot + 2]]
|
|
|
|
set fileSize "$int.$dec Mb"
|
|
|
|
}
|
|
|
|
return $fileSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
|
|
|
proc OpenDialog {} {
|
2022-09-14 16:31:50 +03:00
|
|
|
global env project activeProject
|
|
|
|
if [info exists activeProject] {
|
|
|
|
set dir $activeProject
|
|
|
|
} else {
|
|
|
|
set dir $env(HOME)
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
set fullPath [tk_getOpenFile -initialdir $dir -filetypes $::types -parent .]
|
|
|
|
set file [string range $fullPath [expr [string last "/" $fullPath]+1] end]
|
|
|
|
regsub -all "." $file "_" node
|
|
|
|
set dir [file dirname $fullPath]
|
|
|
|
set file [file tail $fullPath]
|
|
|
|
set name [file rootname $file]
|
|
|
|
set ext [string range [file extension $file] 1 end]
|
|
|
|
if {$fullPath != ""} {
|
2022-09-14 16:31:50 +03:00
|
|
|
# puts $fullPath
|
2022-07-21 10:56:46 +03:00
|
|
|
return $fullPath
|
|
|
|
} else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
proc OpenFolderDialog {} {
|
2022-09-14 16:31:50 +03:00
|
|
|
global env activeProject
|
2022-07-21 10:56:46 +03:00
|
|
|
#global tree node types dot env noteBook fontNormal fontBold fileList noteBook projDir activeProject imgDir editor rootDir
|
|
|
|
# set dir $projDir
|
2022-09-14 16:31:50 +03:00
|
|
|
if [info exists activeProject] {
|
|
|
|
set dir $activeProject
|
|
|
|
} else {
|
|
|
|
set dir $env(HOME)
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
set fullPath [tk_chooseDirectory -initialdir $dir -parent .]
|
2022-11-24 13:28:11 +03:00
|
|
|
# set file [string range $fullPath [expr [string last "/" $fullPath]+1] end]
|
|
|
|
# regsub -all "." $file "_" node
|
|
|
|
# set dir [file dirname $fullPath]
|
|
|
|
# # EditFile .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles $node $fullPath
|
|
|
|
# # puts $fullPath
|
|
|
|
# if ![info exists activeProject] {
|
|
|
|
# set activeProject $fullPath
|
|
|
|
# }
|
|
|
|
# .frmStatus.lblGitLogo configure -image git_logo_20x20
|
|
|
|
# .frmStatus.lblGit configure -text "[::msgcat::mc "Branch"]: [Git::Branches current]"
|
2022-07-21 10:56:46 +03:00
|
|
|
return $fullPath
|
|
|
|
}
|
2022-11-25 08:07:55 +03:00
|
|
|
|
2022-08-30 16:44:28 +03:00
|
|
|
proc CloseFolder {} {
|
2022-09-16 16:25:44 +03:00
|
|
|
global tree nbEditor activeProject
|
2022-09-16 16:36:26 +03:00
|
|
|
|
2022-08-30 16:44:28 +03:00
|
|
|
set treeItem [$tree selection]
|
|
|
|
set parent [$tree parent $treeItem]
|
|
|
|
while {$parent ne ""} {
|
|
|
|
set treeItem $parent
|
|
|
|
set parent [$tree parent $treeItem]
|
|
|
|
}
|
2022-11-25 08:07:55 +03:00
|
|
|
set upper [Tree::GetUpperItem $tree $treeItem]
|
2022-08-30 16:44:28 +03:00
|
|
|
if {$parent eq "" && [string match "directory::*" $treeItem] == 1} {
|
|
|
|
# puts "tree root item: $treeItem"
|
2022-11-25 08:07:55 +03:00
|
|
|
set proj [string trimleft $upper "directory::"]
|
2022-08-30 16:44:28 +03:00
|
|
|
foreach nbItem [$nbEditor tabs] {
|
|
|
|
set item [string trimleft [file extension $nbItem] "."]
|
2022-11-25 08:07:55 +03:00
|
|
|
# puts "$upper $item"
|
|
|
|
if [string match "$proj*" $item] {
|
|
|
|
if [$tree exists "file::$item"] {
|
|
|
|
$nbEditor select $nbItem
|
|
|
|
Close
|
|
|
|
}
|
2022-08-30 16:44:28 +03:00
|
|
|
}
|
|
|
|
}
|
2022-11-22 16:29:26 +03:00
|
|
|
set nextProj [$tree next $treeItem]
|
|
|
|
# puts $nextProj
|
|
|
|
set prevProj [$tree prev $treeItem]
|
|
|
|
# puts $prevProj
|
|
|
|
if {$nextProj ne ""} {
|
2022-11-24 13:28:11 +03:00
|
|
|
SetActiveProject [$tree item $nextProj -values]
|
2022-11-25 08:07:55 +03:00
|
|
|
# puts $activeProject
|
2022-11-22 16:29:26 +03:00
|
|
|
} elseif {$prevProj ne ""} {
|
2022-11-24 13:28:11 +03:00
|
|
|
SetActiveProject [$tree item $prevProj -values]
|
2022-11-25 08:07:55 +03:00
|
|
|
# puts $activeProject
|
2022-11-22 16:29:26 +03:00
|
|
|
} else {
|
|
|
|
unset activeProject
|
|
|
|
.frmStatus.lblGitLogo configure -image pixel
|
|
|
|
.frmStatus.lblGit configure -text ""
|
|
|
|
}
|
2022-08-30 16:44:28 +03:00
|
|
|
$tree delete $treeItem
|
2022-11-22 16:29:26 +03:00
|
|
|
unset nextProj
|
|
|
|
unset prevProj
|
2022-08-30 16:44:28 +03:00
|
|
|
}
|
2022-11-22 16:29:26 +03:00
|
|
|
|
2022-08-30 16:44:28 +03:00
|
|
|
}
|
|
|
|
|
2022-07-21 16:01:28 +03:00
|
|
|
proc CloseAll {} {
|
|
|
|
global nbEditor modified
|
2022-12-01 12:37:13 +03:00
|
|
|
foreach nb2Item [.frmWork.nbEditor2 tabs] {
|
|
|
|
.frmWork.nbEditor2 forget $nb2Item
|
|
|
|
}
|
|
|
|
if {[lsearch -exact [.frmWork.panelNB panes] .frmWork.nbEditor2] != -1} {
|
|
|
|
.frmWork.panelNB forget .frmWork.nbEditor2
|
|
|
|
}
|
2022-07-21 16:01:28 +03:00
|
|
|
foreach nbItem [array names modified] {
|
2022-12-01 12:37:13 +03:00
|
|
|
if {[info exists modified($nbItem)] == 1 && $modified($nbItem) eq "true"} {
|
|
|
|
catch {$nbEditor select $nbItem}
|
2022-09-14 16:31:50 +03:00
|
|
|
# puts "close tab $nbItem"
|
2022-07-21 16:01:28 +03:00
|
|
|
if {[Close] eq "cancel"} {return "cancel"}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
proc Close {} {
|
2022-12-07 16:00:04 +03:00
|
|
|
global nbEditor modified tree editors
|
2022-07-21 10:56:46 +03:00
|
|
|
set nbItem [$nbEditor select]
|
2022-09-14 16:31:50 +03:00
|
|
|
# puts "close tab $nbItem"
|
2022-08-24 15:04:19 +03:00
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
if {$nbItem == ""} {return}
|
2022-10-17 16:55:22 +03:00
|
|
|
if [info exists modified($nbItem)] {
|
|
|
|
if {$modified($nbItem) eq "true"} {
|
|
|
|
set answer [tk_messageBox -message [::msgcat::mc "File was modifyed"] \
|
|
|
|
-icon question -type yesnocancel \
|
|
|
|
-detail [::msgcat::mc "Do you want to save it?"]]
|
|
|
|
switch $answer {
|
|
|
|
yes Save
|
|
|
|
no {}
|
|
|
|
cancel {return "cancel"}
|
|
|
|
}
|
2022-07-21 16:01:28 +03:00
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
}
|
|
|
|
$nbEditor forget $nbItem
|
|
|
|
destroy $nbItem
|
|
|
|
set treeItem "file::[string range $nbItem [expr [string last "." $nbItem] +1] end ]"
|
2022-07-27 16:55:04 +03:00
|
|
|
if [$tree exists $treeItem] {
|
2022-08-24 15:04:19 +03:00
|
|
|
# delete all functions from tree item
|
|
|
|
set children [$tree children $treeItem]
|
|
|
|
if {$children ne ""} {
|
|
|
|
foreach i $children {
|
|
|
|
$tree delete $i
|
|
|
|
}
|
|
|
|
}
|
2022-07-27 16:55:04 +03:00
|
|
|
if {[$tree parent $treeItem] eq ""} {
|
|
|
|
$tree delete $treeItem
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
}
|
2022-11-23 12:50:07 +03:00
|
|
|
if [info exists modified($nbItem)] {
|
|
|
|
unset modified($nbItem)
|
|
|
|
}
|
2022-12-07 16:00:04 +03:00
|
|
|
# puts $nbItem
|
|
|
|
set editors [dict remove $editors $nbItem.frmText.t]
|
2022-10-19 09:05:55 +03:00
|
|
|
.frmStatus.lblPosition configure -text ""
|
2022-11-11 12:59:24 +03:00
|
|
|
.frmStatus.lblEncoding configure -text ""
|
|
|
|
.frmStatus.lblSize configure -text ""
|
2022-11-23 12:50:07 +03:00
|
|
|
NB::NextTab $nbEditor 0
|
2022-07-21 10:56:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
proc Save {} {
|
2022-09-14 16:31:50 +03:00
|
|
|
global nbEditor tree env activeProject
|
|
|
|
|
|
|
|
if [info exists activeProject] {
|
|
|
|
set dir $activeProject
|
|
|
|
} else {
|
|
|
|
set dir $env(HOME)
|
|
|
|
}
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
set nbEditorItem [$nbEditor select]
|
|
|
|
puts "Saved editor text: $nbEditorItem"
|
|
|
|
if [string match "*untitled*" $nbEditorItem] {
|
2022-09-14 16:31:50 +03:00
|
|
|
set filePath [tk_getSaveFile -initialdir $dir -filetypes $::types -parent .]
|
2022-07-21 10:56:46 +03:00
|
|
|
if {$filePath eq ""} {
|
|
|
|
return
|
|
|
|
}
|
2022-07-27 16:55:04 +03:00
|
|
|
# set fileName [string range $filePath [expr [string last "/" $filePath]+1] end]
|
|
|
|
set fileName [file tail $filePath]
|
|
|
|
$nbEditor tab $nbEditorItem -text $fileName
|
2022-07-25 16:04:25 +03:00
|
|
|
# set treeitem [Tree::InsertItem $tree {} $filePath "file" $fileName]
|
2022-07-27 16:55:04 +03:00
|
|
|
set lblName "lbl[string range $nbEditorItem [expr [string last "." $nbEditorItem] +1] end]"
|
2022-09-14 16:31:50 +03:00
|
|
|
$nbEditorItem.header.$lblName configure -text $filePath
|
2022-07-21 10:56:46 +03:00
|
|
|
} else {
|
|
|
|
set treeItem "file::[string range $nbEditorItem [expr [string last "." $nbEditorItem] +1] end ]"
|
|
|
|
set filePath [Tree::GetItemID $tree $treeItem]
|
|
|
|
}
|
|
|
|
set editedText [$nbEditorItem.frmText.t get 0.0 end]
|
|
|
|
set f [open $filePath "w+"]
|
|
|
|
puts -nonewline $f $editedText
|
|
|
|
puts "$f was saved"
|
|
|
|
close $f
|
2022-12-01 12:37:13 +03:00
|
|
|
ResetModifiedFlag $nbEditorItem $nbEditor
|
2022-07-21 10:56:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
proc SaveAll {} {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
proc Delete {} {
|
|
|
|
set node [$tree selection get]
|
|
|
|
set fullPath [$tree itemcget $node -data]
|
|
|
|
set dir [file dirname $fullPath]
|
|
|
|
set file [file tail $fullPath]
|
|
|
|
set answer [tk_messageBox -message "[::msgcat::mc "Delete file"] \"$file\"?"\
|
|
|
|
-type yesno -icon question -default yes]
|
|
|
|
case $answer {
|
|
|
|
yes {
|
|
|
|
FileDialog $tree close
|
|
|
|
file delete -force "$fullPath"
|
|
|
|
$tree delete $node
|
|
|
|
$tree configure -redraw 1
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-02 17:01:53 +03:00
|
|
|
proc ReadFolder {directory {parent ""}} {
|
2022-09-14 16:31:50 +03:00
|
|
|
global tree dir lexers project
|
2022-08-12 15:23:20 +03:00
|
|
|
puts "Read the folder $directory"
|
2022-07-21 10:56:46 +03:00
|
|
|
set rList ""
|
2022-08-12 15:23:20 +03:00
|
|
|
if {[catch {cd $directory}] != 0} {
|
2022-07-21 10:56:46 +03:00
|
|
|
return ""
|
|
|
|
}
|
2022-09-02 17:01:53 +03:00
|
|
|
set parent [Tree::InsertItem $tree $parent $directory "directory" [file tail $directory]]
|
2022-08-30 16:44:28 +03:00
|
|
|
$tree selection set $parent
|
2022-11-18 13:03:48 +03:00
|
|
|
foreach i [$tree children $parent] {
|
|
|
|
$tree delete $i
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
# if {[ $tree item $parent -open] eq "false"} {
|
|
|
|
# $tree item $parent -open true
|
|
|
|
# } else {
|
|
|
|
# $tree item $parent -open false
|
|
|
|
# }
|
2022-09-02 17:01:53 +03:00
|
|
|
# Проверяем наличие списка каталогов для спецобработки
|
|
|
|
# и если есть читаем в список (ножно для ansible)
|
|
|
|
if {[dict exists $lexers ALL varDirectory] == 1} {
|
|
|
|
foreach i [split [dict get $lexers ALL varDirectory] " "] {
|
|
|
|
# puts "-------- $i"
|
|
|
|
lappend dirListForCheck [string trim $i]
|
|
|
|
}
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
# Getting an files and directorues lists
|
|
|
|
foreach file [glob -nocomplain *] {
|
2022-08-12 15:23:20 +03:00
|
|
|
lappend rList [list [file join $directory $file]]
|
2022-07-21 10:56:46 +03:00
|
|
|
if [file isdirectory $file] {
|
|
|
|
lappend lstDir $file
|
|
|
|
} else {
|
|
|
|
lappend lstFiles $file
|
|
|
|
}
|
|
|
|
}
|
2022-09-01 16:54:34 +03:00
|
|
|
foreach file [glob -nocomplain .?*] {
|
|
|
|
if {$file ne ".."} {
|
|
|
|
lappend rList [list [file join $directory $file]]
|
|
|
|
if [file isdirectory $file] {
|
|
|
|
lappend lstDir $file
|
|
|
|
} else {
|
|
|
|
lappend lstFiles $file
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
# Sort lists and insert into tree
|
|
|
|
if {[info exists lstDir] && [llength $lstDir] > 0} {
|
|
|
|
foreach f [lsort $lstDir] {
|
2022-09-21 14:38:31 +03:00
|
|
|
set i [Tree::InsertItem $tree $parent [file join $directory $f] "directory" $f]
|
|
|
|
# puts "Tree insert item: $i $f]"
|
|
|
|
ReadFolder [file join $directory $f] $i
|
|
|
|
unset i
|
2022-07-21 10:56:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if {[info exists lstFiles] && [llength $lstFiles] > 0} {
|
|
|
|
foreach f [lsort $lstFiles] {
|
2022-09-21 14:38:31 +03:00
|
|
|
Tree::InsertItem $tree $parent [file join $directory $f] "file" $f
|
|
|
|
# puts "Tree insert item: "
|
2022-07-21 10:56:46 +03:00
|
|
|
}
|
|
|
|
}
|
2022-08-12 15:23:20 +03:00
|
|
|
# Чтение структуры файлов в каталоге
|
|
|
|
# пока криво работает
|
|
|
|
# Accept $dir(lib) $directory
|
2022-07-21 10:56:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
proc ReadFile {fileFullPath itemName} {
|
|
|
|
set txt $itemName.frmText.t
|
|
|
|
if ![string match "*untitled*" $itemName] {
|
|
|
|
set file [open "$fileFullPath" r]
|
2022-08-24 15:04:19 +03:00
|
|
|
$txt insert end [chan read -nonewline $file]
|
2022-07-21 10:56:46 +03:00
|
|
|
close $file
|
|
|
|
}
|
|
|
|
# Delete emty last line
|
|
|
|
if {[$txt get {end-1 line} end] eq "\n" || [$txt get {end-1 line} end] eq "\r\n"} {
|
|
|
|
$txt delete {end-1 line} end
|
|
|
|
puts ">[$txt get {end-1 line} end]<"
|
|
|
|
}
|
2022-08-24 15:04:19 +03:00
|
|
|
$txt see 1.0
|
2022-07-21 10:56:46 +03:00
|
|
|
}
|
|
|
|
|
2022-12-01 12:37:13 +03:00
|
|
|
proc Edit {fileFullPath {nbEditor .frmWork.nbEditor}} {
|
|
|
|
global tree
|
2022-09-19 15:00:05 +03:00
|
|
|
if {[file exists $fileFullPath] == 0} {
|
|
|
|
return false
|
2022-11-10 14:53:58 +03:00
|
|
|
} else {
|
|
|
|
# puts [::fileutil::magic::filetype $fileFullPath]
|
2022-11-10 15:36:34 +03:00
|
|
|
set fileType [FileOper::GetFileMimeType $fileFullPath]
|
2022-11-10 14:53:58 +03:00
|
|
|
}
|
|
|
|
switch $fileType {
|
|
|
|
"text" {
|
|
|
|
# return text
|
|
|
|
}
|
|
|
|
"image" {
|
|
|
|
# return image
|
|
|
|
}
|
|
|
|
false {
|
|
|
|
return
|
|
|
|
}
|
2022-09-19 15:00:05 +03:00
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
set filePath [file dirname $fileFullPath]
|
|
|
|
set fileName [file tail $fileFullPath]
|
|
|
|
regsub -all {\.|/|\\|\s} $fileFullPath "_" itemName
|
|
|
|
set itemName "$nbEditor.$itemName"
|
2022-08-01 16:24:42 +03:00
|
|
|
set treeItemName [Tree::InsertItem $tree {} $fileFullPath "file" $fileName]
|
2022-11-23 11:14:03 +03:00
|
|
|
|
|
|
|
# переместим указатель на нужный файл в дереве
|
|
|
|
Tree::SelectItem $treeItemName
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
if {[winfo exists $itemName] == 0} {
|
|
|
|
NB::InsertItem $nbEditor $fileFullPath "file"
|
|
|
|
Editor::Editor $fileFullPath $nbEditor $itemName
|
|
|
|
ReadFile $fileFullPath $itemName
|
|
|
|
$itemName.frmText.t highlight 1.0 end
|
2022-12-01 12:37:13 +03:00
|
|
|
ResetModifiedFlag $itemName $nbEditor
|
2022-08-24 15:04:19 +03:00
|
|
|
$itemName.frmText.t see 1.1
|
2022-07-21 10:56:46 +03:00
|
|
|
}
|
|
|
|
$nbEditor select $itemName
|
2022-08-01 16:24:42 +03:00
|
|
|
Editor::ReadStructure $itemName.frmText.t $treeItemName
|
2022-09-08 17:01:18 +03:00
|
|
|
GetVariablesFromFile $fileFullPath
|
2022-09-22 16:42:48 +03:00
|
|
|
$itemName.frmText.t.t mark set insert 1.0
|
|
|
|
$itemName.frmText.t.t see 1.0
|
2022-08-24 15:04:19 +03:00
|
|
|
focus -force $itemName.frmText.t.t
|
2022-11-10 14:53:58 +03:00
|
|
|
.frmStatus.lblSize configure -text [GetFileAttr $fileFullPath "size"]
|
2022-11-10 15:36:34 +03:00
|
|
|
.frmStatus.lblEncoding configure -text [GetFileMimeType $fileFullPath "charset"]
|
2022-07-21 10:56:46 +03:00
|
|
|
return $itemName
|
|
|
|
}
|
2022-09-22 16:42:48 +03:00
|
|
|
|
|
|
|
proc FindInFiles {} {
|
|
|
|
global nbEditor activeProject
|
|
|
|
set res ""
|
|
|
|
set txt ""
|
|
|
|
set str ""
|
|
|
|
set nbEditorItem [$nbEditor select]
|
|
|
|
if {$nbEditorItem ne ""} {
|
2022-09-23 12:33:22 +03:00
|
|
|
set txt $nbEditorItem.frmText.t
|
|
|
|
# set txt [focus]
|
2022-09-22 16:42:48 +03:00
|
|
|
set selIndex [$txt tag ranges sel]
|
|
|
|
if {$selIndex ne ""} {
|
|
|
|
set selBegin [lindex [$txt tag ranges sel] 0]
|
|
|
|
set selEnd [lindex [$txt tag ranges sel] 1]
|
|
|
|
set str [$txt get $selBegin $selEnd]
|
|
|
|
puts $str
|
|
|
|
set res [SearchStringInFolder $str]
|
|
|
|
}
|
|
|
|
}
|
2022-11-23 12:50:07 +03:00
|
|
|
if [FindInFilesDialog $txt $res] {
|
|
|
|
.find.entryFind delete 0 end
|
|
|
|
.find.entryFind insert end $str
|
|
|
|
}
|
2022-09-22 16:42:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
proc ReplaceInFiles {} {
|
|
|
|
global nbEditor
|
|
|
|
return
|
|
|
|
# set selIndex [$txt tag ranges sel]
|
|
|
|
# set selBegin [lindex [$txt tag ranges sel] 0]
|
|
|
|
# set selEnd [lindex [$txt tag ranges sel] 1]
|
|
|
|
# puts [$txt get [$txt tag ranges sel]]
|
|
|
|
# }
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
}
|