Начало работ по поддержке git

This commit is contained in:
svkalinin 2022-10-17 16:55:22 +03:00
parent b9c1f966b3
commit 04e7dd2560
10 changed files with 220 additions and 19 deletions

View File

@ -27,6 +27,7 @@ opened=
editedFiles=
searchCommand=/usr/bin/grep
searchCommandOptions=-r -n -H
gitCommand=/usr/bin/git
\[GUI\]
locale=$locale
theme=dark

View File

@ -620,7 +620,7 @@ namespace eval Editor {
dict set editors $txt procedureList $procList
dict set editors $txt variableList $varList
}
proc FindFunction {txt findString} {
global nbEditor
puts $findString
@ -795,8 +795,8 @@ namespace eval Editor {
}
wm geom $win +$x+$y
}
proc FindReplaceText {txt findString replaceString regexp} {
proc FindReplaceText {txt findString replaceString regexp} {
global nbEditor
puts [focus]
# set txt [$nbEditor select].frmText.t

View File

@ -100,14 +100,16 @@ namespace eval FileOper {
# puts "close tab $nbItem"
if {$nbItem == ""} {return}
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"}
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"}
}
}
}
$nbEditor forget $nbItem

141
lib/git.tcl Normal file
View File

@ -0,0 +1,141 @@
######################################################
# ProjMan 2
# Distributed under GNU Public License
# Author: Sergey Kalinin svk@nuk-svk.ru
# Copyright (c) "SVK", 2022, https://nuk-svk.ru
######################################################
# Git module
# usage a system git command
#######################################################
namespace eval Git {
variable gitCommand
proc GetConfig {} {
global activeProject
set confOptions {
remote.origin.url
user.user
user.email
init.defaultbranch
branch.master.remote
}
}
proc Status {} {
global cfgVariables activeProject
set cmd exec
lappend cmd $cfgVariables(gitCommand)
lappend cmd "status"
lappend cmd "-s"
lappend cmd "--"
lappend cmd $activeProject
catch $cmd pipe
foreach line [split $pipe "\n"] {
lappend res $line
}
return $res
}
proc Diff {f} {
global cfgVariables activeProject
set cmd exec
lappend cmd $cfgVariables(gitCommand)
lappend cmd "diff"
lappend cmd "--"
lappend cmd [file join $activeProject [string trimleft $f "../"]]
catch $cmd pipe
puts $cmd
# puts $pipe
foreach line [split $pipe "\n"] {
lappend res $line
}
return $res
}
proc Commit {} {
global cfgVariables activeProject
}
proc Pull {} {
global cfgVariables activeProject
}
proc Push {} {
global cfgVariables activeProject
}
proc Merge {} {
global cfgVariables activeProject
}
proc Dialog {} {
global cfgVariables activeProject nbEditor
variable fr
set fr [NB::InsertItem $nbEditor git_browse "git"]
ttk::frame $fr.header
set lblName "lblGit"
set lblText $activeProject
ttk::label $fr.header.$lblName -text $lblText
pack $fr.header.$lblName -side left -expand true -fill x
pack $fr.header -side top -fill x
ttk::frame $fr.body
pack $fr.body -side top -expand true -fill both
set lstFiles [listbox $fr.body.lBox -width 30 -border 2 -yscrollcommand "$fr.body.yscroll set" -border 1]
ttk::scrollbar $fr.body.yscroll -orient vertical -command "$fr.body.lBox yview"
pack $fr.body.lBox -expand true -fill y -side left
pack $fr.body.yscroll -side left -expand false -fill y
set txt $fr.body.t
# set txt $frmText.t
pack [ttk::scrollbar $fr.body.v -command "$fr.body.t yview"] -side right -fill y
ttk::scrollbar $fr.body.h -orient horizontal -command "$fr.body.t xview"
ctext $txt -xscrollcommand "$fr.body.h set" -yscrollcommand "$fr.body.v set" \
-font $cfgVariables(font) -relief flat -wrap none \
-linemapfg $cfgVariables(lineNumberFG) -linemapbg $cfgVariables(lineNumberBG) \
-tabs "[expr {4 * [font measure $cfgVariables(font) 0]}] left" -tabstyle tabular -undo true
pack $txt -fill both -expand 1
pack $fr.body.h -side bottom -fill x
foreach { word } [Git::Status] {
$fr.body.lBox insert end [string trim $word]
}
catch { $fr.body.lBox activate 0 ; $fr.body.lBox selection set 0 0 }
bind $fr.body.lBox <Return> {
set values [$Git::fr.body.lBox get [$Git::fr.body.lBox curselection]]
if [regexp -nocase -line -lineanchor -- {([\w?]+)\s(.+?)} $values m mod fileName] {
$Git::fr.body.t delete 1.0 end
switch $mod {
M {
set i 0
foreach line [Git::Diff $fileName] {
puts $line
if {$i > 3} {
$Git::fr.body.t inser end "$line\n"
}
incr i
}
$Git::fr.body.t highlight 1.0 end
}
"??" {
$Git::fr.body.t inser end [::msgcat::mc "Untraceable file"]
}
D {
$Git::fr.body.t inser end [::msgcat::mc "File was deleted"]
}
}
}
break
}
ctext::addHighlightClassForRegexp $txt paths #19a2a6 {@@.+@@}
ctext::addHighlightClassForRegexp $txt add green {^\+.*$}
ctext::addHighlightClassForRegexp $txt gremove grey {^\-.*$}
$txt highlight 1.0 end
}
}

View File

@ -104,9 +104,11 @@ pack propagate .frmBody.panel false
pack .frmBody.frmTool -side left -fill y
pack .frmBody.panel -side left -fill both -expand true
ttk::button $frmTool.btn_tree -command ViewFilesTree -image tree_24x24
ttk::button $frmTool.btn_tree -command ViewFilesTree -image tree_24x24
ttk::button $frmTool.btn_search -command FileOper::FindInFiles -image search_24x24
ttk::button $frmTool.btn_git -command Git::Dialog -image git_24x24
pack $frmTool.btn_tree -side top -padx 1 -pady 1
pack $frmTool.btn_tree $frmTool.btn_search $frmTool.btn_git -side top -padx 1 -pady 1
# #label $frmTool.lbl_logo -image tcl
# pack $frmTool.btn_quit -side bottom -padx 5 -pady 5
# #pack $frmTool.lbl_logo -side bottom -padx 5 -pady 5
@ -122,8 +124,6 @@ set tree [ttk::treeview $frmTree.tree -show tree \
ttk::scrollbar $frmTree.h -orient horizontal -command [list $frmTree.tree xview]
ttk::scrollbar $frmTree.v -orient vertical -command [list $frmTree.tree yview]
bind $tree <Double-ButtonPress-1> {Tree::DoublePressItem $tree}
bind $tree <ButtonRelease-1> {Tree::PressItem $tree; break}

View File

@ -1069,3 +1069,52 @@ image create photo split_vertical_11x11 -data {
ZWQgd2l0aCBHSU1QV4EOFwAAAEdJREFUGNNjnDl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Cn03kB4OMi37rqkqTT6cuBQOCu1Wq9QAhxLeP1+/03yWRyD8DXlRdt
Dv14VkLTtCNVVeV2u/08k8k8BfAZwGSRt/INKKWzbrfbaDabzyqVyiEAzfB4BuAHgBEACcAvsz1W
CvR6vdeJRCIF4L0+3WzTLCKL2VIulx8bbHsmHA5/0309+5OwI2bZMq8FQbgUjUbvLcuijQVYlr1+
Wrb8lcAc62bROjj2kSeTyUZZtA5OZJEgCH673X5O07QjSZI+ZLPZ1Kps2eiPptfb+plv6ZMfLouL
fwO/AYhqCBpNK/77AAAAAElFTkSuQmCC
}

View File

@ -72,6 +72,7 @@
::msgcat::mcset ru "File" "Файл"
::msgcat::mcset ru "Files" "Файлах"
::msgcat::mcset ru "File already exists. Overwrite?" "Файл уже существует. Переписать?"
::msgcat::mcset ru "File was deleted" "Файл был удалён"
::msgcat::mcset ru "File was modifyed. Close?" "Файл был изменен. Закрыть?"
::msgcat::mcset ru "File was modifyed" "Файл был изменен"
::msgcat::mcset ru "File modify" "Файл изменен"
@ -191,6 +192,7 @@
::msgcat::mcset ru "Toolbar" "Панель инструментов"
::msgcat::mcset ru "Undo" "Отменить"
::msgcat::mcset ru "Update" "Обновить"
::msgcat::mcset ru "Untraceable file" "Неотслеживаемый файл"
::msgcat::mcset ru "Variables" "Переменные"
::msgcat::mcset ru "Version" "Версия"
::msgcat::mcset ru "View" "Вид"

View File

@ -23,6 +23,12 @@ namespace eval NB {
$nb select $fm
}
}
git {
set fm [ttk::frame $nb.$item]
pack $fm -side top -expand true -fill both
$nb add $fm -text Git;# -image close_12x12 -compound right
$nb select $fm
}
}
# puts "NB item - $fm"
return $fm

View File

@ -168,6 +168,7 @@ proc GetVariableFilePath {txt} {
return [list $vName $vPath $vValue]
}
}
proc FindVariablesDialog {txt args} {
global editors lexers cfgVariables
# variable txt
@ -253,7 +254,7 @@ proc FindVariablesDialog {txt args} {
if {$path ne ""} {
destroy .findVariables
FileOper::Edit $path
Editor::FindFunction "$varName"
Editor::FindFunction $t "$varName"
}
# $txt tag remove sel 1.0 end
# focus $Editor::txt.t
@ -268,7 +269,7 @@ proc FindVariablesDialog {txt args} {
if {$path ne ""} {
destroy .findVariables
FileOper::Edit $path
Editor::FindFunction "$varName"
Editor::FindFunction $t "$varName"
}
break
}
@ -513,4 +514,3 @@ proc FindInFilesDialog {txt {args ""}} {
}
# $win.lBox focus I001
}

View File

@ -10,7 +10,7 @@ exec wish "$0" -- "$@"
######################################################
# Version: 2.0.0
# Release: alpha
# Build: 23092022123657
# Build: 17102022165430
######################################################
# определим текущую версию, релиз и т.д.