Добавлен интерфейс работы с Git
This commit is contained in:
parent
e5e0ad299f
commit
400b41aa1e
|
@ -55,7 +55,8 @@ namespace eval FileOper {
|
|||
if ![info exists activeProject] {
|
||||
set activeProject $fullPath
|
||||
}
|
||||
|
||||
.frmStatus.lblGitLogo configure -image git_logo_20x20
|
||||
.frmStatus.lblGit configure -text "[::msgcat::mc "Branch"]: [Git::Branches current]"
|
||||
return $fullPath
|
||||
}
|
||||
|
||||
|
@ -81,6 +82,8 @@ namespace eval FileOper {
|
|||
$tree delete $treeItem
|
||||
}
|
||||
set activeProject ""
|
||||
.frmStatus.lblGitLogo configure -image pixel
|
||||
.frmStatus.lblGit configure -text ""
|
||||
}
|
||||
|
||||
proc CloseAll {} {
|
||||
|
@ -128,6 +131,7 @@ namespace eval FileOper {
|
|||
}
|
||||
}
|
||||
unset modified($nbItem)
|
||||
.frmStatus.lblPosition configure -text ""
|
||||
}
|
||||
|
||||
proc Save {} {
|
||||
|
|
213
lib/git.tcl
213
lib/git.tcl
|
@ -23,6 +23,39 @@ namespace eval Git {
|
|||
}
|
||||
}
|
||||
|
||||
proc Branches {opt} {
|
||||
global cfgVariables activeProject
|
||||
set cmd exec
|
||||
set d [pwd]
|
||||
if {$activeProject ne ""} {
|
||||
cd $activeProject
|
||||
}
|
||||
lappend cmd $cfgVariables(gitCommand)
|
||||
lappend cmd "branch"
|
||||
# lappend cmd "-s"
|
||||
# lappend cmd "--"
|
||||
# lappend cmd $activeProject
|
||||
switch $opt {
|
||||
current {
|
||||
lappend cmd "--show-current"
|
||||
}
|
||||
list {
|
||||
lappend cmd "-l"
|
||||
}
|
||||
}
|
||||
catch $cmd pipe
|
||||
if [regexp -nocase -- {^fatal:} $pipe match] {
|
||||
return
|
||||
}
|
||||
foreach line [split $pipe "\n"] {
|
||||
lappend res $line
|
||||
}
|
||||
cd $d
|
||||
if [info exists res] {
|
||||
return $res
|
||||
}
|
||||
}
|
||||
|
||||
proc Status {} {
|
||||
global cfgVariables activeProject
|
||||
set cmd exec
|
||||
|
@ -32,6 +65,9 @@ namespace eval Git {
|
|||
lappend cmd "--"
|
||||
lappend cmd $activeProject
|
||||
catch $cmd pipe
|
||||
if [regexp -nocase -- {^fatal:} $pipe match] {
|
||||
return
|
||||
}
|
||||
foreach line [split $pipe "\n"] {
|
||||
lappend res $line
|
||||
}
|
||||
|
@ -49,15 +85,45 @@ namespace eval Git {
|
|||
lappend cmd [file join $activeProject [string trimleft $f "../"]]
|
||||
catch $cmd pipe
|
||||
puts $cmd
|
||||
# puts $pipe
|
||||
if [regexp -nocase -- {^fatal:} $pipe match] {
|
||||
return
|
||||
}
|
||||
foreach line [split $pipe "\n"] {
|
||||
lappend res $line
|
||||
}
|
||||
return $res
|
||||
}
|
||||
|
||||
proc Commit {} {
|
||||
proc Commit {w} {
|
||||
global cfgVariables activeProject
|
||||
set txt [string trim [$w get 0.0 end]]
|
||||
puts $txt
|
||||
set cmd exec
|
||||
append cmd " $cfgVariables(gitCommand)"
|
||||
append cmd " commit"
|
||||
append cmd " -m"
|
||||
append cmd " \"$txt\""
|
||||
append cmd " --"
|
||||
append cmd " $activeProject"
|
||||
if {$txt eq ""} {
|
||||
set answer [tk_messageBox -message [::msgcat::mc "Empty commit description"] \
|
||||
-icon info -type ok \
|
||||
-detail [::msgcat::mc "You must enter a commit description"]]
|
||||
switch $answer {
|
||||
ok {return "cancel"}
|
||||
}
|
||||
} else {
|
||||
puts $cmd
|
||||
catch $cmd pipe
|
||||
puts $pipe
|
||||
if [regexp -nocase -- {^fatal:} $pipe match] {
|
||||
return
|
||||
}
|
||||
foreach line [split $pipe "\n"] {
|
||||
lappend res $line
|
||||
}
|
||||
return $res
|
||||
}
|
||||
}
|
||||
|
||||
proc Pull {} {
|
||||
|
@ -72,69 +138,142 @@ namespace eval Git {
|
|||
global cfgVariables activeProject
|
||||
}
|
||||
|
||||
proc ListBoxPress {w} {
|
||||
set fileName [$w.body.lBox get [$w.body.lBox curselection]]
|
||||
# puts $values
|
||||
$w.body.t delete 1.0 end
|
||||
set i 0
|
||||
foreach line [Git::Diff $fileName] {
|
||||
puts $line
|
||||
if {$i > 3} {
|
||||
$w.body.t inser end "$line\n"
|
||||
}
|
||||
incr i
|
||||
}
|
||||
$w.body.t highlight 1.0 end
|
||||
}
|
||||
proc CommitAdd {w} {
|
||||
global activeProject cfgVariables
|
||||
set fileName [$w.body.lBox get [$w.body.lBox curselection]]
|
||||
# puts $values
|
||||
set cmd exec
|
||||
lappend cmd $cfgVariables(gitCommand)
|
||||
lappend cmd "add"
|
||||
lappend cmd [file join $activeProject $fileName]
|
||||
catch $cmd pipe
|
||||
puts $cmd
|
||||
$w.body.lCommit insert end $fileName
|
||||
$w.body.lBox delete [$w.body.lBox curselection]
|
||||
}
|
||||
proc Key {k fr} {
|
||||
# puts [Editor::Key $k]
|
||||
switch $k {
|
||||
Up {
|
||||
Git::ListBoxPress $fr
|
||||
}
|
||||
Down {
|
||||
Git::ListBoxPress $fr
|
||||
}
|
||||
}
|
||||
}
|
||||
proc Dialog {} {
|
||||
global cfgVariables activeProject nbEditor
|
||||
variable fr
|
||||
if [winfo exists $nbEditor.git_browse] {
|
||||
$nbEditor select $nbEditor.git_browse
|
||||
return
|
||||
}
|
||||
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
|
||||
set lblText "$activeProject | [::msgcat::mc "Branch"]: [Git::Branches current]"
|
||||
ttk::label $fr.header.$lblName -text $lblText -justify right
|
||||
pack $fr.header.$lblName -side right -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]
|
||||
set lstFiles [listbox $fr.body.lBox -width 30 -border 0 -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
|
||||
# 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
|
||||
# pack [ttk::scrollbar $fr.body.v -command "$fr.body.t yview"] -side right -fill y
|
||||
ttk::scrollbar $fr.body.v -command "$fr.body.t yview"
|
||||
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) \
|
||||
-font $cfgVariables(font) -relief flat -wrap none -linemap 0 \
|
||||
-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
|
||||
ttk::button $fr.body.bAdd -image forward_20x20 -command "Git::CommitAdd $fr"
|
||||
ttk::button $fr.body.bRemove -state disable -image backward_20x20
|
||||
ttk::button $fr.body.bCommit -image done_20x20 -compound left -text "[::msgcat::mc "Commit changes"]" \
|
||||
-command "Git::Commit $fr.body.tCommit"
|
||||
ttk::button $fr.body.bDone -image doneall_20x20 -compound left -text "[::msgcat::mc "Push changes"]" \
|
||||
-command Git::Push
|
||||
|
||||
set lstFilesCommit [listbox $fr.body.lCommit -width 30 -border 0 -yscrollcommand "$fr.body.yscroll2 set" -border 1]
|
||||
ttk::scrollbar $fr.body.yscroll2 -orient vertical -command "$fr.body.lCommit yview"
|
||||
|
||||
ttk::label $fr.body.lblCommitText -text "[::msgcat::mc "Commit description"]"
|
||||
ttk::scrollbar $fr.body.vCommit -command "$fr.body.tCommit yview"
|
||||
ttk::scrollbar $fr.body.hCommit -orient horizontal -command "$fr.body.tCommit xview"
|
||||
ctext $fr.body.tCommit -xscrollcommand "$fr.body.hCommit set" -yscrollcommand "$fr.body.vCommit set" \
|
||||
-font $cfgVariables(font) -relief flat -wrap none -linemap 0 \
|
||||
-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
|
||||
grid $lstFiles -column 0 -row 0 -sticky nsew -columnspan 3 -rowspan 2
|
||||
grid $fr.body.yscroll -column 3 -row 0 -sticky nsw -rowspan 2
|
||||
grid $txt -column 4 -row 0 -sticky nsew -columnspan 2
|
||||
grid $fr.body.v -column 5 -row 0 -sticky nsew
|
||||
grid $fr.body.h -column 4 -row 1 -columnspan 3 -sticky nsew
|
||||
grid rowconfigure $fr.body $fr.body.t -weight 1
|
||||
grid columnconfigure $fr.body $fr.body.t -weight 1
|
||||
|
||||
grid $fr.body.bAdd -column 0 -row 3 -sticky nsew
|
||||
grid $fr.body.bRemove -column 1 -row 3 -sticky nsew
|
||||
grid $fr.body.lCommit -column 0 -row 4 -columnspan 3 -rowspan 3 -sticky nsew
|
||||
grid $fr.body.lblCommitText -column 4 -row 3 -sticky nsew -columnspan 2
|
||||
grid $fr.body.tCommit -column 4 -row 4 -sticky nsew -columnspan 2
|
||||
grid $fr.body.vCommit -column 6 -row 4 -sticky nsew
|
||||
grid $fr.body.hCommit -column 4 -row 5 -columnspan 3 -sticky nsew
|
||||
grid $fr.body.bCommit -column 4 -row 6 -sticky nsew
|
||||
grid $fr.body.bDone -column 5 -row 6 -sticky nsew
|
||||
|
||||
foreach { word } [Git::Status] {
|
||||
$fr.body.lBox insert end [string trim $word]
|
||||
puts $word
|
||||
if [regexp -nocase -- {([\w\s])([\s\w?]+)\s../(.+?)} $word match v1 v2 fileName] {
|
||||
# puts "$v1 $v2 $fileName"
|
||||
# $fr.body.t delete 1.0 end
|
||||
if {$v1 ne " "} {
|
||||
$fr.body.lCommit insert end $fileName
|
||||
}
|
||||
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"]
|
||||
if {$v2 ne " "} {
|
||||
$fr.body.lBox insert end $fileName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
catch { $fr.body.lBox activate 0 ; $fr.body.lBox selection set 0 0 }
|
||||
|
||||
bind $fr.body.lBox <Return> "Git::CommitAdd $fr"
|
||||
bind $fr.body.lBox <Double-Button-1> "Git::CommitAdd $fr"
|
||||
bind $fr.body.lBox <Button-1><ButtonRelease-1> "Git::ListBoxPress $fr"
|
||||
bind $fr.body.lBox <KeyRelease> "Git::Key %K $fr"
|
||||
|
||||
focus -force $fr.body.lBox
|
||||
catch {
|
||||
$fr.body.lBox activate 0
|
||||
$fr.body.lBox selection set 0 0
|
||||
Git::ListBoxPress $fr
|
||||
}
|
||||
|
||||
ctext::addHighlightClassForRegexp $txt paths #19a2a6 {@@.+@@}
|
||||
ctext::addHighlightClassForRegexp $txt add green {^\+.*$}
|
||||
ctext::addHighlightClassForRegexp $txt gremove grey {^\-.*$}
|
||||
|
|
|
@ -79,6 +79,8 @@ pack .frmStatus -side top -padx 1 -fill x
|
|||
# pack .panel -expand true -fill both
|
||||
# pack propagate .panel false
|
||||
#pack [label .frmMenu.lbl -text "ddd"]
|
||||
pack [ttk::label .frmStatus.lblGitLogo -justify left] -side left
|
||||
pack [ttk::label .frmStatus.lblGit] -side left
|
||||
pack [ttk::label .frmStatus.lblPosition -justify right] -side right
|
||||
|
||||
ttk::menubutton .frmMenu.mnuFile -text [::msgcat::mc "File"] -menu .frmMenu.mnuFile.m
|
||||
|
|
|
@ -1118,3 +1118,21 @@ CvR6vdeJRCIF4L0+3WzTLCKL2VIulx8bbHsmHA5/0309+5OwI2bZMq8FQbgUjUbvLcuijQVYlr1+
|
|||
Wrb8lcAc62bROjj2kSeTyUZZtA5OZJEgCH673X5O07QjSZI+ZLPZ1Kps2eiPptfb+plv6ZMfLouL
|
||||
fwO/AYhqCBpNK/77AAAAAElFTkSuQmCC
|
||||
}
|
||||
image create photo git_logo_20x20 -data {
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9
|
||||
kT1Iw0AcxV9TRS0VETuIdAhYnSyIijhqFYpQodQKrTqYXPoFTRqSFBdHwbXg4Mdi1cHFWVcHV0EQ
|
||||
/ABxdHJSdJES/5cUWsR4cNyPd/ced+8AoV5mqtkxDqiaZaTiMTGTXRW7XhFAP3oQxrDETH0umUzA
|
||||
c3zdw8fXuyjP8j735+hVciYDfCLxLNMNi3iDeHrT0jnvE4dYUVKIz4nHDLog8SPXZZffOBccFnhm
|
||||
yEin5olDxGKhjeU2ZkVDJZ4ijiiqRvlCxmWF8xZntVxlzXvyFwZz2soy12mGEccilpCECBlVlFCG
|
||||
hSitGikmUrQf8/APOf4kuWRylcDIsYAKVEiOH/wPfndr5icn3KRgDOh8se2PEaBrF2jUbPv72LYb
|
||||
J4D/GbjSWv5KHZj5JL3W0iJHQN82cHHd0uQ94HIHGHzSJUNyJD9NIZ8H3s/om7LAwC0QWHN7a+7j
|
||||
9AFIU1eJG+DgEBgtUPa6x7u723v790yzvx9mlnKiL4DMEQAAAAZiS0dEAAAAAAAA+UO7fwAAAAlw
|
||||
SFlzAAAN1wAADdcBQiibeAAAAAd0SU1FB+YKEgcxNF7PMAgAAAFqSURBVDjLhZM9SwNBEIaf2TMx
|
||||
WipXxFbQqFGJ4A9III1RLIQDf4eNWPkPBGsrC4VDK1GbGC0sRDSN5svC0g9SixDdWwtP7kjuzHY7
|
||||
M+8zs7w7Qtw5rqfR3jnwBZ0lnIV2VJlEik/uhvlM3QOZ34B5hK9CFERFdv4cmkBkL9QnC4kKbtX+
|
||||
f4LjehptLsHYeKqI0jmQFWA1bpIAcNgcw9IVMJN+pIGTnQbAfawDU1EQFSMGGOeolvP7xD5HYsR+
|
||||
rezimRtEGuAVQTaBkfAkCuv7LFIcQEbBlLG8Q+ozNob9YJLkqQI69D+jaDXPtniIvIfiCQWdEshD
|
||||
f4Yc4NauwGz49xZ6oPTrglu1YfACzGxIoIFl0G1Q10AqlGthSZ616dfAxl7IM0523LfxFljsFvd+
|
||||
pG6IsIPHB8KWb3kTSxX+xNG74FZtSJaBua7ME3ogz3rmpf8y9UCkhbYK3eJ4QAA5AZMAVcKZeYsq
|
||||
+wEJrowfIBN3bgAAAABJRU5ErkJggg==
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
::msgcat::mcset ru "Archive file mask" "Маска архива"
|
||||
::msgcat::mcset ru "Author" "Автор"
|
||||
::msgcat::mcset ru "Braces" "Скобки"
|
||||
::msgcat::mcset ru "Branch" "Ветка"
|
||||
::msgcat::mcset ru "Quad braces" "Квадратные скобки"
|
||||
::msgcat::mcset ru "Braces background" "Фон скобки"
|
||||
::msgcat::mcset ru "Braces foreground" "Цвет скобки"
|
||||
|
@ -29,6 +30,9 @@
|
|||
::msgcat::mcset ru "Comment selected" "Закоментировать"
|
||||
::msgcat::mcset ru "Uncomment selected" "Раскоментировать"
|
||||
::msgcat::mcset ru "Column" "Столбец"
|
||||
::msgcat::mcset ru "Commit" "Коммита"
|
||||
::msgcat::mcset ru "Commit description" "Описание коммита"
|
||||
::msgcat::mcset ru "Commit changes" "Зафиксировать изменения"
|
||||
::msgcat::mcset ru "Company" "Компания"
|
||||
::msgcat::mcset ru "Compiler" "Компилятор"
|
||||
::msgcat::mcset ru "Compile" "Компиляция"
|
||||
|
@ -150,6 +154,8 @@
|
|||
::msgcat::mcset ru "Project file" "Файл проекта"
|
||||
::msgcat::mcset ru "Project dir" "Каталог проекта"
|
||||
::msgcat::mcset ru "Project type" "Тип проекта"
|
||||
::msgcat::mcset ru "Push changes" "Протолкнуть изменения"
|
||||
::msgcat::mcset ru "Pull changes" "Вытянуть изменения"
|
||||
::msgcat::mcset ru "Quit without saving?" "Выйти без сохранения?"
|
||||
::msgcat::mcset ru "Question" "Вопрос"
|
||||
::msgcat::mcset ru "Quote string" "Строка в кавычках"
|
||||
|
|
|
@ -24,6 +24,9 @@ namespace eval NB {
|
|||
}
|
||||
}
|
||||
git {
|
||||
if [winfo exists $nb.$item] {
|
||||
return $nb.$item
|
||||
}
|
||||
set fm [ttk::frame $nb.$item]
|
||||
pack $fm -side top -expand true -fill both
|
||||
$nb add $fm -text Git;# -image close_12x12 -compound right
|
||||
|
@ -44,9 +47,11 @@ namespace eval NB {
|
|||
FileOper::Close
|
||||
} else {
|
||||
set txt [$w select].frmText.t
|
||||
if [winfo exists $txt] {
|
||||
focus -force $txt.t
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc NextTab {w step} {
|
||||
set i [expr [$w index end] - 1]
|
||||
|
|
|
@ -10,7 +10,7 @@ exec wish "$0" -- "$@"
|
|||
######################################################
|
||||
# Version: 2.0.0
|
||||
# Release: alpha
|
||||
# Build: 17102022170001
|
||||
# Build: 18102022150316
|
||||
######################################################
|
||||
|
||||
# определим текущую версию, релиз и т.д.
|
||||
|
@ -118,6 +118,8 @@ if [info exists opened] {
|
|||
}
|
||||
if [file isdirectory $path] {
|
||||
set activeProject $path
|
||||
.frmStatus.lblGitLogo configure -image git_logo_20x20
|
||||
.frmStatus.lblGit configure -text "[::msgcat::mc "Branch"]: [Git::Branches current]"
|
||||
FileOper::ReadFolder $path
|
||||
ReadFilesFromDirectory $path $path
|
||||
} elseif [file exists $path] {
|
||||
|
@ -128,6 +130,8 @@ if [info exists opened] {
|
|||
if {$cfgVariables(opened) ne ""} {
|
||||
# puts "<$cfgVariables(opened)"
|
||||
set activeProject $cfgVariables(opened)
|
||||
.frmStatus.lblGitLogo configure -image git_logo_20x20
|
||||
.frmStatus.lblGit configure -text "[::msgcat::mc "Branch"]: [Git::Branches current]"
|
||||
FileOper::ReadFolder $cfgVariables(opened)
|
||||
ReadFilesFromDirectory $cfgVariables(opened) $cfgVariables(opened)
|
||||
if {$cfgVariables(editedFiles) ne ""} {
|
||||
|
@ -138,4 +142,3 @@ if [info exists opened] {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user