2007-05-08 03:35:48 +00:00
|
|
|
# git-gui options editor
|
|
|
|
# Copyright (C) 2006, 2007 Shawn Pearce
|
|
|
|
|
2008-09-17 21:07:32 +00:00
|
|
|
proc config_check_encodings {} {
|
|
|
|
global repo_config_new global_config_new
|
|
|
|
|
|
|
|
set enc $global_config_new(gui.encoding)
|
|
|
|
if {$enc eq {}} {
|
|
|
|
set global_config_new(gui.encoding) [encoding system]
|
|
|
|
} elseif {[tcl_encoding $enc] eq {}} {
|
|
|
|
error_popup [mc "Invalid global encoding '%s'" $enc]
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
set enc $repo_config_new(gui.encoding)
|
|
|
|
if {$enc eq {}} {
|
|
|
|
set repo_config_new(gui.encoding) [encoding system]
|
|
|
|
} elseif {[tcl_encoding $enc] eq {}} {
|
|
|
|
error_popup [mc "Invalid repo encoding '%s'" $enc]
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2007-05-08 03:35:48 +00:00
|
|
|
proc save_config {} {
|
|
|
|
global default_config font_descs
|
2008-11-16 18:46:47 +00:00
|
|
|
global repo_config global_config system_config
|
2007-05-08 03:35:48 +00:00
|
|
|
global repo_config_new global_config_new
|
git-gui: Automatically spell check commit messages as the user types
Many user friendly tools like word processors, email editors and web
browsers allow users to spell check the message they are writing
as they type it, making it easy to identify a common misspelling
of a word and correct it on the fly.
We now open a bi-directional pipe to Aspell and feed the message
text the user is editing off to the program about once every 300
milliseconds. This is frequent enough that the user sees the results
almost immediately, but is not so frequent as to cause significant
additional load on the system. If the user has modified the message
text during the last 300 milliseconds we delay until the next period,
ensuring that we avoid flooding the Aspell process with a lot of
text while the user is actively typing their message.
We wait to send the current message buffer to Aspell until the user
is at a word boundary, thus ensuring that we are not likely to ask
for misspelled word detection on a word that the user is actively
typing, as most words are misspelled when only partially typed,
even if the user has thus far typed it correctly.
Misspelled words are highlighted in red and are given an underline,
causing the word to stand out from the others in the buffer. This is
a very common user interface idiom for displaying misspelled words,
but differs from one platform to the next in slight variations.
For example the Mac OS X system prefers using a dashed red underline,
leaving the word in the original text color. Unfortunately the
control that Tk gives us over text display is not powerful enough
to handle such formatting so we have to work with the least common
denominator.
The top suggestions for a misspelling are saved in an array and
offered to the user when they right-click (or on the Mac ctrl-click)
a misspelled word. Selecting an entry from this menu will replace
the misspelling with the correction shown. Replacement is integrated
with the undo/redo stack so undoing a replacement will restore the
misspelled original text.
If Aspell could not be started during git-gui launch we silently eat
the error and run without spell checking support. This way users
who do not have Aspell in their $PATH can continue to use git-gui,
although they will not get the advanced spelling functionality.
If Aspell started successfully the version line and language are
shown in git-gui's about box, below the Tcl/Tk versions. This way
the user can verify the Aspell function has been activated.
If Aspell crashes while we are running we inform the user with an
error dialog and then disable Aspell entirely for the rest of this
git-gui session. This prevents us from fork-bombing the system
with Aspell instances that always crash when presented with the
current message text, should there be a bug in either Aspell or in
git-gui's output to it.
We escape all input lines with ^, as recommended by the Aspell manual
page, as this allows Aspell to properly ignore any input line that is
otherwise looking like a command (e.g. ! to enable terse output). By
using this escape however we need to correct all word offsets by -1 as
Aspell is apparently considering the ^ escape to be part of the line's
character count, but our Tk text widget obviously does not.
Available dictionaries are offered in the Options dialog, allowing
the user to select the language they want to spellcheck commit
messages with for the current repository, as well as the global
user setting that all repositories inherit.
Special thanks to Adam Flott for suggesting connecting git-gui
to Aspell for the purpose of spell checking the commit message,
and to Wincent Colaiuta for the idea to wait for a word boundary
before passing the message over for checking.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-02-07 07:35:25 +00:00
|
|
|
global ui_comm_spell
|
2007-05-08 03:35:48 +00:00
|
|
|
|
|
|
|
foreach option $font_descs {
|
|
|
|
set name [lindex $option 0]
|
|
|
|
set font [lindex $option 1]
|
|
|
|
font configure $font \
|
|
|
|
-family $global_config_new(gui.$font^^family) \
|
|
|
|
-size $global_config_new(gui.$font^^size)
|
|
|
|
font configure ${font}bold \
|
|
|
|
-family $global_config_new(gui.$font^^family) \
|
|
|
|
-size $global_config_new(gui.$font^^size)
|
2007-06-02 21:15:56 +00:00
|
|
|
font configure ${font}italic \
|
|
|
|
-family $global_config_new(gui.$font^^family) \
|
|
|
|
-size $global_config_new(gui.$font^^size)
|
2007-05-08 03:35:48 +00:00
|
|
|
set global_config_new(gui.$name) [font configure $font]
|
|
|
|
unset global_config_new(gui.$font^^family)
|
|
|
|
unset global_config_new(gui.$font^^size)
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach name [array names default_config] {
|
|
|
|
set value $global_config_new($name)
|
|
|
|
if {$value ne $global_config($name)} {
|
2008-11-16 18:46:47 +00:00
|
|
|
if {$value eq $system_config($name)} {
|
2007-05-08 03:35:48 +00:00
|
|
|
catch {git config --global --unset $name}
|
|
|
|
} else {
|
|
|
|
regsub -all "\[{}\]" $value {"} value
|
|
|
|
git config --global $name $value
|
|
|
|
}
|
|
|
|
set global_config($name) $value
|
|
|
|
if {$value eq $repo_config($name)} {
|
|
|
|
catch {git config --unset $name}
|
|
|
|
set repo_config($name) $value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach name [array names default_config] {
|
|
|
|
set value $repo_config_new($name)
|
|
|
|
if {$value ne $repo_config($name)} {
|
|
|
|
if {$value eq $global_config($name)} {
|
|
|
|
catch {git config --unset $name}
|
|
|
|
} else {
|
|
|
|
regsub -all "\[{}\]" $value {"} value
|
|
|
|
git config $name $value
|
|
|
|
}
|
|
|
|
set repo_config($name) $value
|
|
|
|
}
|
|
|
|
}
|
git-gui: Automatically spell check commit messages as the user types
Many user friendly tools like word processors, email editors and web
browsers allow users to spell check the message they are writing
as they type it, making it easy to identify a common misspelling
of a word and correct it on the fly.
We now open a bi-directional pipe to Aspell and feed the message
text the user is editing off to the program about once every 300
milliseconds. This is frequent enough that the user sees the results
almost immediately, but is not so frequent as to cause significant
additional load on the system. If the user has modified the message
text during the last 300 milliseconds we delay until the next period,
ensuring that we avoid flooding the Aspell process with a lot of
text while the user is actively typing their message.
We wait to send the current message buffer to Aspell until the user
is at a word boundary, thus ensuring that we are not likely to ask
for misspelled word detection on a word that the user is actively
typing, as most words are misspelled when only partially typed,
even if the user has thus far typed it correctly.
Misspelled words are highlighted in red and are given an underline,
causing the word to stand out from the others in the buffer. This is
a very common user interface idiom for displaying misspelled words,
but differs from one platform to the next in slight variations.
For example the Mac OS X system prefers using a dashed red underline,
leaving the word in the original text color. Unfortunately the
control that Tk gives us over text display is not powerful enough
to handle such formatting so we have to work with the least common
denominator.
The top suggestions for a misspelling are saved in an array and
offered to the user when they right-click (or on the Mac ctrl-click)
a misspelled word. Selecting an entry from this menu will replace
the misspelling with the correction shown. Replacement is integrated
with the undo/redo stack so undoing a replacement will restore the
misspelled original text.
If Aspell could not be started during git-gui launch we silently eat
the error and run without spell checking support. This way users
who do not have Aspell in their $PATH can continue to use git-gui,
although they will not get the advanced spelling functionality.
If Aspell started successfully the version line and language are
shown in git-gui's about box, below the Tcl/Tk versions. This way
the user can verify the Aspell function has been activated.
If Aspell crashes while we are running we inform the user with an
error dialog and then disable Aspell entirely for the rest of this
git-gui session. This prevents us from fork-bombing the system
with Aspell instances that always crash when presented with the
current message text, should there be a bug in either Aspell or in
git-gui's output to it.
We escape all input lines with ^, as recommended by the Aspell manual
page, as this allows Aspell to properly ignore any input line that is
otherwise looking like a command (e.g. ! to enable terse output). By
using this escape however we need to correct all word offsets by -1 as
Aspell is apparently considering the ^ escape to be part of the line's
character count, but our Tk text widget obviously does not.
Available dictionaries are offered in the Options dialog, allowing
the user to select the language they want to spellcheck commit
messages with for the current repository, as well as the global
user setting that all repositories inherit.
Special thanks to Adam Flott for suggesting connecting git-gui
to Aspell for the purpose of spell checking the commit message,
and to Wincent Colaiuta for the idea to wait for a word boundary
before passing the message over for checking.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-02-07 07:35:25 +00:00
|
|
|
|
|
|
|
if {[info exists repo_config(gui.spellingdictionary)]} {
|
|
|
|
set value $repo_config(gui.spellingdictionary)
|
|
|
|
if {$value eq {none}} {
|
|
|
|
if {[info exists ui_comm_spell]} {
|
|
|
|
$ui_comm_spell stop
|
|
|
|
}
|
|
|
|
} elseif {[info exists ui_comm_spell]} {
|
|
|
|
$ui_comm_spell lang $value
|
|
|
|
}
|
|
|
|
}
|
2007-05-08 03:35:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proc do_options {} {
|
|
|
|
global repo_config global_config font_descs
|
|
|
|
global repo_config_new global_config_new
|
2010-01-26 00:05:31 +00:00
|
|
|
global ui_comm_spell use_ttk NS
|
2007-05-08 03:35:48 +00:00
|
|
|
|
|
|
|
array unset repo_config_new
|
|
|
|
array unset global_config_new
|
|
|
|
foreach name [array names repo_config] {
|
|
|
|
set repo_config_new($name) $repo_config($name)
|
|
|
|
}
|
|
|
|
load_config 1
|
|
|
|
foreach name [array names repo_config] {
|
|
|
|
switch -- $name {
|
|
|
|
gui.diffcontext {continue}
|
|
|
|
}
|
|
|
|
set repo_config_new($name) $repo_config($name)
|
|
|
|
}
|
|
|
|
foreach name [array names global_config] {
|
|
|
|
set global_config_new($name) $global_config($name)
|
|
|
|
}
|
|
|
|
|
|
|
|
set w .options_editor
|
2010-01-26 00:05:31 +00:00
|
|
|
Dialog $w
|
|
|
|
wm withdraw $w
|
|
|
|
wm transient $w [winfo parent $w]
|
2007-05-08 03:35:48 +00:00
|
|
|
wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
|
|
|
|
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::frame $w.buttons
|
|
|
|
${NS}::button $w.buttons.restore -text [mc "Restore Defaults"] \
|
2007-05-08 03:35:48 +00:00
|
|
|
-default normal \
|
|
|
|
-command do_restore_defaults
|
|
|
|
pack $w.buttons.restore -side left
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::button $w.buttons.save -text [mc Save] \
|
2007-05-08 03:35:48 +00:00
|
|
|
-default active \
|
|
|
|
-command [list do_save_config $w]
|
|
|
|
pack $w.buttons.save -side right
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::button $w.buttons.cancel -text [mc "Cancel"] \
|
2007-05-08 03:35:48 +00:00
|
|
|
-default normal \
|
|
|
|
-command [list destroy $w]
|
|
|
|
pack $w.buttons.cancel -side right -padx 5
|
|
|
|
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
|
|
|
|
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::labelframe $w.repo -text [mc "%s Repository" [reponame]]
|
|
|
|
${NS}::labelframe $w.global -text [mc "Global (All Repositories)"]
|
2007-05-08 03:35:48 +00:00
|
|
|
pack $w.repo -side left -fill both -expand 1 -pady 5 -padx 5
|
|
|
|
pack $w.global -side right -fill both -expand 1 -pady 5 -padx 5
|
|
|
|
|
|
|
|
set optid 0
|
|
|
|
foreach option {
|
2007-07-21 12:21:34 +00:00
|
|
|
{t user.name {mc "User Name"}}
|
|
|
|
{t user.email {mc "Email Address"}}
|
|
|
|
|
|
|
|
{b merge.summary {mc "Summarize Merge Commits"}}
|
|
|
|
{i-1..5 merge.verbosity {mc "Merge Verbosity"}}
|
|
|
|
{b merge.diffstat {mc "Show Diffstat After Merge"}}
|
2008-08-30 20:56:51 +00:00
|
|
|
{t merge.tool {mc "Use Merge Tool"}}
|
2007-07-21 12:21:34 +00:00
|
|
|
|
|
|
|
{b gui.trustmtime {mc "Trust File Modification Timestamps"}}
|
|
|
|
{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
|
|
|
|
{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
|
2010-07-30 08:11:02 +00:00
|
|
|
{b gui.textconv {mc "Use Textconv For Diffs and Blames"}}
|
2008-07-16 20:43:48 +00:00
|
|
|
{b gui.fastcopyblame {mc "Blame Copy Only On Changed Files"}}
|
2013-08-27 10:11:15 +00:00
|
|
|
{i-0..100 gui.maxrecentrepo {mc "Maximum Length of Recent Repositories List"}}
|
2008-07-16 20:43:48 +00:00
|
|
|
{i-20..200 gui.copyblamethreshold {mc "Minimum Letters To Blame Copy On"}}
|
2008-08-23 08:30:00 +00:00
|
|
|
{i-0..300 gui.blamehistoryctx {mc "Blame History Context Radius (days)"}}
|
2008-08-30 16:45:27 +00:00
|
|
|
{i-1..99 gui.diffcontext {mc "Number of Diff Context Lines"}}
|
2011-01-21 10:59:45 +00:00
|
|
|
{t gui.diffopts {mc "Additional Diff Parameters"}}
|
2008-03-06 19:38:40 +00:00
|
|
|
{i-0..99 gui.commitmsgwidth {mc "Commit Message Text Width"}}
|
2007-07-21 12:21:34 +00:00
|
|
|
{t gui.newbranchtemplate {mc "New Branch Name Template"}}
|
2008-09-17 21:07:33 +00:00
|
|
|
{c gui.encoding {mc "Default File Contents Encoding"}}
|
2011-10-22 19:39:39 +00:00
|
|
|
{b gui.warndetachedcommit {mc "Warn before committing to a detached head"}}
|
2011-10-14 19:25:21 +00:00
|
|
|
{s gui.stageuntracked {mc "Staging of untracked files"} {list "yes" "no" "ask"}}
|
git-gui: Add gui.displayuntracked option
When git is used to track only a subset of a directory, or
there is no sure way to divide files to ignore from files to track,
git user have to live with large number of untracked files. These files
present in file list, and should always be scrolled through
to handle real changes. Situation can become even worse, then number
of the untracked files grows above the maxfilesdisplayed limit. In the
case, even staged can be hidden by git-gui.
This change introduces new configuration variable gui.displayuntracked,
which, when set to false, instructs git-gui not to show untracked files
in files list. They can be staged from commandline or other tools (like
IDE of file manager), then they become visible. Default value of the
option is true, which is compatible with current behavior.
Signed-off-by: Max Kirillov <max@max630.net>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2013-08-21 03:29:13 +00:00
|
|
|
{b gui.displayuntracked {mc "Show untracked files"}}
|
2012-02-12 15:55:17 +00:00
|
|
|
{i-1..99 gui.tabsize {mc "Tab spacing"}}
|
2007-05-08 03:35:48 +00:00
|
|
|
} {
|
|
|
|
set type [lindex $option 0]
|
|
|
|
set name [lindex $option 1]
|
2007-07-21 12:21:34 +00:00
|
|
|
set text [eval [lindex $option 2]]
|
2007-05-08 03:35:48 +00:00
|
|
|
incr optid
|
|
|
|
foreach f {repo global} {
|
|
|
|
switch -glob -- $type {
|
|
|
|
b {
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::checkbutton $w.$f.$optid -text $text \
|
2007-05-08 03:35:48 +00:00
|
|
|
-variable ${f}_config_new($name) \
|
|
|
|
-onvalue true \
|
|
|
|
-offvalue false
|
|
|
|
pack $w.$f.$optid -side top -anchor w
|
|
|
|
}
|
|
|
|
i-* {
|
|
|
|
regexp -- {-(\d+)\.\.(\d+)$} $type _junk min max
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::frame $w.$f.$optid
|
2016-05-08 10:52:55 +00:00
|
|
|
${NS}::label $w.$f.$optid.l -text [mc "%s:" $text]
|
2007-05-08 03:35:48 +00:00
|
|
|
pack $w.$f.$optid.l -side left -anchor w -fill x
|
2010-01-26 00:05:31 +00:00
|
|
|
tspinbox $w.$f.$optid.v \
|
2007-05-08 03:35:48 +00:00
|
|
|
-textvariable ${f}_config_new($name) \
|
|
|
|
-from $min \
|
|
|
|
-to $max \
|
|
|
|
-increment 1 \
|
|
|
|
-width [expr {1 + [string length $max]}]
|
|
|
|
bind $w.$f.$optid.v <FocusIn> {%W selection range 0 end}
|
|
|
|
pack $w.$f.$optid.v -side right -anchor e -padx 5
|
|
|
|
pack $w.$f.$optid -side top -anchor w -fill x
|
|
|
|
}
|
2008-09-17 21:07:33 +00:00
|
|
|
c -
|
2007-05-08 03:35:48 +00:00
|
|
|
t {
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::frame $w.$f.$optid
|
2016-05-08 10:52:55 +00:00
|
|
|
${NS}::label $w.$f.$optid.l -text [mc "%s:" $text]
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::entry $w.$f.$optid.v \
|
2007-05-08 03:35:48 +00:00
|
|
|
-width 20 \
|
|
|
|
-textvariable ${f}_config_new($name)
|
|
|
|
pack $w.$f.$optid.l -side left -anchor w
|
|
|
|
pack $w.$f.$optid.v -side left -anchor w \
|
|
|
|
-fill x -expand 1 \
|
|
|
|
-padx 5
|
2008-09-17 21:07:33 +00:00
|
|
|
if {$type eq {c}} {
|
|
|
|
menu $w.$f.$optid.m
|
|
|
|
build_encoding_menu $w.$f.$optid.m \
|
|
|
|
[list set ${f}_config_new($name)] 1
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::button $w.$f.$optid.b \
|
2008-09-17 21:07:33 +00:00
|
|
|
-text [mc "Change"] \
|
|
|
|
-command [list popup_btn_menu \
|
|
|
|
$w.$f.$optid.m $w.$f.$optid.b]
|
|
|
|
pack $w.$f.$optid.b -side left -anchor w
|
|
|
|
}
|
2007-05-08 03:35:48 +00:00
|
|
|
pack $w.$f.$optid -side top -anchor w -fill x
|
|
|
|
}
|
2011-10-14 19:25:21 +00:00
|
|
|
s {
|
|
|
|
set opts [eval [lindex $option 3]]
|
|
|
|
${NS}::frame $w.$f.$optid
|
2016-05-08 10:52:55 +00:00
|
|
|
${NS}::label $w.$f.$optid.l -text [mc "%s:" $text]
|
2011-10-14 19:25:21 +00:00
|
|
|
if {$use_ttk} {
|
|
|
|
ttk::combobox $w.$f.$optid.v \
|
|
|
|
-textvariable ${f}_config_new($name) \
|
|
|
|
-values $opts -state readonly
|
|
|
|
} else {
|
|
|
|
eval tk_optionMenu $w.$f.$optid.v \
|
|
|
|
${f}_config_new($name) \
|
|
|
|
$opts
|
|
|
|
}
|
|
|
|
pack $w.$f.$optid.l -side left -anchor w -fill x
|
|
|
|
pack $w.$f.$optid.v -side right -anchor e -padx 5
|
|
|
|
pack $w.$f.$optid -side top -anchor w -fill x
|
|
|
|
}
|
2007-05-08 03:35:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
git-gui: Automatically spell check commit messages as the user types
Many user friendly tools like word processors, email editors and web
browsers allow users to spell check the message they are writing
as they type it, making it easy to identify a common misspelling
of a word and correct it on the fly.
We now open a bi-directional pipe to Aspell and feed the message
text the user is editing off to the program about once every 300
milliseconds. This is frequent enough that the user sees the results
almost immediately, but is not so frequent as to cause significant
additional load on the system. If the user has modified the message
text during the last 300 milliseconds we delay until the next period,
ensuring that we avoid flooding the Aspell process with a lot of
text while the user is actively typing their message.
We wait to send the current message buffer to Aspell until the user
is at a word boundary, thus ensuring that we are not likely to ask
for misspelled word detection on a word that the user is actively
typing, as most words are misspelled when only partially typed,
even if the user has thus far typed it correctly.
Misspelled words are highlighted in red and are given an underline,
causing the word to stand out from the others in the buffer. This is
a very common user interface idiom for displaying misspelled words,
but differs from one platform to the next in slight variations.
For example the Mac OS X system prefers using a dashed red underline,
leaving the word in the original text color. Unfortunately the
control that Tk gives us over text display is not powerful enough
to handle such formatting so we have to work with the least common
denominator.
The top suggestions for a misspelling are saved in an array and
offered to the user when they right-click (or on the Mac ctrl-click)
a misspelled word. Selecting an entry from this menu will replace
the misspelling with the correction shown. Replacement is integrated
with the undo/redo stack so undoing a replacement will restore the
misspelled original text.
If Aspell could not be started during git-gui launch we silently eat
the error and run without spell checking support. This way users
who do not have Aspell in their $PATH can continue to use git-gui,
although they will not get the advanced spelling functionality.
If Aspell started successfully the version line and language are
shown in git-gui's about box, below the Tcl/Tk versions. This way
the user can verify the Aspell function has been activated.
If Aspell crashes while we are running we inform the user with an
error dialog and then disable Aspell entirely for the rest of this
git-gui session. This prevents us from fork-bombing the system
with Aspell instances that always crash when presented with the
current message text, should there be a bug in either Aspell or in
git-gui's output to it.
We escape all input lines with ^, as recommended by the Aspell manual
page, as this allows Aspell to properly ignore any input line that is
otherwise looking like a command (e.g. ! to enable terse output). By
using this escape however we need to correct all word offsets by -1 as
Aspell is apparently considering the ^ escape to be part of the line's
character count, but our Tk text widget obviously does not.
Available dictionaries are offered in the Options dialog, allowing
the user to select the language they want to spellcheck commit
messages with for the current repository, as well as the global
user setting that all repositories inherit.
Special thanks to Adam Flott for suggesting connecting git-gui
to Aspell for the purpose of spell checking the commit message,
and to Wincent Colaiuta for the idea to wait for a word boundary
before passing the message over for checking.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-02-07 07:35:25 +00:00
|
|
|
set all_dicts [linsert \
|
|
|
|
[spellcheck::available_langs] \
|
|
|
|
0 \
|
|
|
|
none]
|
|
|
|
incr optid
|
|
|
|
foreach f {repo global} {
|
|
|
|
if {![info exists ${f}_config_new(gui.spellingdictionary)]} {
|
|
|
|
if {[info exists ui_comm_spell]} {
|
|
|
|
set value [$ui_comm_spell lang]
|
|
|
|
} else {
|
|
|
|
set value none
|
|
|
|
}
|
|
|
|
set ${f}_config_new(gui.spellingdictionary) $value
|
|
|
|
}
|
|
|
|
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::frame $w.$f.$optid
|
|
|
|
${NS}::label $w.$f.$optid.l -text [mc "Spelling Dictionary:"]
|
|
|
|
if {$use_ttk} {
|
|
|
|
ttk::combobox $w.$f.$optid.v \
|
|
|
|
-textvariable ${f}_config_new(gui.spellingdictionary) \
|
|
|
|
-values $all_dicts -state readonly
|
|
|
|
} else {
|
|
|
|
eval tk_optionMenu $w.$f.$optid.v \
|
|
|
|
${f}_config_new(gui.spellingdictionary) \
|
|
|
|
$all_dicts
|
|
|
|
}
|
git-gui: Automatically spell check commit messages as the user types
Many user friendly tools like word processors, email editors and web
browsers allow users to spell check the message they are writing
as they type it, making it easy to identify a common misspelling
of a word and correct it on the fly.
We now open a bi-directional pipe to Aspell and feed the message
text the user is editing off to the program about once every 300
milliseconds. This is frequent enough that the user sees the results
almost immediately, but is not so frequent as to cause significant
additional load on the system. If the user has modified the message
text during the last 300 milliseconds we delay until the next period,
ensuring that we avoid flooding the Aspell process with a lot of
text while the user is actively typing their message.
We wait to send the current message buffer to Aspell until the user
is at a word boundary, thus ensuring that we are not likely to ask
for misspelled word detection on a word that the user is actively
typing, as most words are misspelled when only partially typed,
even if the user has thus far typed it correctly.
Misspelled words are highlighted in red and are given an underline,
causing the word to stand out from the others in the buffer. This is
a very common user interface idiom for displaying misspelled words,
but differs from one platform to the next in slight variations.
For example the Mac OS X system prefers using a dashed red underline,
leaving the word in the original text color. Unfortunately the
control that Tk gives us over text display is not powerful enough
to handle such formatting so we have to work with the least common
denominator.
The top suggestions for a misspelling are saved in an array and
offered to the user when they right-click (or on the Mac ctrl-click)
a misspelled word. Selecting an entry from this menu will replace
the misspelling with the correction shown. Replacement is integrated
with the undo/redo stack so undoing a replacement will restore the
misspelled original text.
If Aspell could not be started during git-gui launch we silently eat
the error and run without spell checking support. This way users
who do not have Aspell in their $PATH can continue to use git-gui,
although they will not get the advanced spelling functionality.
If Aspell started successfully the version line and language are
shown in git-gui's about box, below the Tcl/Tk versions. This way
the user can verify the Aspell function has been activated.
If Aspell crashes while we are running we inform the user with an
error dialog and then disable Aspell entirely for the rest of this
git-gui session. This prevents us from fork-bombing the system
with Aspell instances that always crash when presented with the
current message text, should there be a bug in either Aspell or in
git-gui's output to it.
We escape all input lines with ^, as recommended by the Aspell manual
page, as this allows Aspell to properly ignore any input line that is
otherwise looking like a command (e.g. ! to enable terse output). By
using this escape however we need to correct all word offsets by -1 as
Aspell is apparently considering the ^ escape to be part of the line's
character count, but our Tk text widget obviously does not.
Available dictionaries are offered in the Options dialog, allowing
the user to select the language they want to spellcheck commit
messages with for the current repository, as well as the global
user setting that all repositories inherit.
Special thanks to Adam Flott for suggesting connecting git-gui
to Aspell for the purpose of spell checking the commit message,
and to Wincent Colaiuta for the idea to wait for a word boundary
before passing the message over for checking.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-02-07 07:35:25 +00:00
|
|
|
pack $w.$f.$optid.l -side left -anchor w -fill x
|
2008-02-14 06:07:39 +00:00
|
|
|
pack $w.$f.$optid.v -side right -anchor e -padx 5
|
git-gui: Automatically spell check commit messages as the user types
Many user friendly tools like word processors, email editors and web
browsers allow users to spell check the message they are writing
as they type it, making it easy to identify a common misspelling
of a word and correct it on the fly.
We now open a bi-directional pipe to Aspell and feed the message
text the user is editing off to the program about once every 300
milliseconds. This is frequent enough that the user sees the results
almost immediately, but is not so frequent as to cause significant
additional load on the system. If the user has modified the message
text during the last 300 milliseconds we delay until the next period,
ensuring that we avoid flooding the Aspell process with a lot of
text while the user is actively typing their message.
We wait to send the current message buffer to Aspell until the user
is at a word boundary, thus ensuring that we are not likely to ask
for misspelled word detection on a word that the user is actively
typing, as most words are misspelled when only partially typed,
even if the user has thus far typed it correctly.
Misspelled words are highlighted in red and are given an underline,
causing the word to stand out from the others in the buffer. This is
a very common user interface idiom for displaying misspelled words,
but differs from one platform to the next in slight variations.
For example the Mac OS X system prefers using a dashed red underline,
leaving the word in the original text color. Unfortunately the
control that Tk gives us over text display is not powerful enough
to handle such formatting so we have to work with the least common
denominator.
The top suggestions for a misspelling are saved in an array and
offered to the user when they right-click (or on the Mac ctrl-click)
a misspelled word. Selecting an entry from this menu will replace
the misspelling with the correction shown. Replacement is integrated
with the undo/redo stack so undoing a replacement will restore the
misspelled original text.
If Aspell could not be started during git-gui launch we silently eat
the error and run without spell checking support. This way users
who do not have Aspell in their $PATH can continue to use git-gui,
although they will not get the advanced spelling functionality.
If Aspell started successfully the version line and language are
shown in git-gui's about box, below the Tcl/Tk versions. This way
the user can verify the Aspell function has been activated.
If Aspell crashes while we are running we inform the user with an
error dialog and then disable Aspell entirely for the rest of this
git-gui session. This prevents us from fork-bombing the system
with Aspell instances that always crash when presented with the
current message text, should there be a bug in either Aspell or in
git-gui's output to it.
We escape all input lines with ^, as recommended by the Aspell manual
page, as this allows Aspell to properly ignore any input line that is
otherwise looking like a command (e.g. ! to enable terse output). By
using this escape however we need to correct all word offsets by -1 as
Aspell is apparently considering the ^ escape to be part of the line's
character count, but our Tk text widget obviously does not.
Available dictionaries are offered in the Options dialog, allowing
the user to select the language they want to spellcheck commit
messages with for the current repository, as well as the global
user setting that all repositories inherit.
Special thanks to Adam Flott for suggesting connecting git-gui
to Aspell for the purpose of spell checking the commit message,
and to Wincent Colaiuta for the idea to wait for a word boundary
before passing the message over for checking.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-02-07 07:35:25 +00:00
|
|
|
pack $w.$f.$optid -side top -anchor w -fill x
|
|
|
|
}
|
|
|
|
unset all_dicts
|
|
|
|
|
2007-05-08 03:35:48 +00:00
|
|
|
set all_fonts [lsort [font families]]
|
|
|
|
foreach option $font_descs {
|
|
|
|
set name [lindex $option 0]
|
|
|
|
set font [lindex $option 1]
|
2007-07-21 12:21:34 +00:00
|
|
|
set text [eval [lindex $option 2]]
|
2007-05-08 03:35:48 +00:00
|
|
|
|
|
|
|
set global_config_new(gui.$font^^family) \
|
|
|
|
[font configure $font -family]
|
|
|
|
set global_config_new(gui.$font^^size) \
|
|
|
|
[font configure $font -size]
|
|
|
|
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::frame $w.global.$name
|
2016-05-08 10:52:55 +00:00
|
|
|
${NS}::label $w.global.$name.l -text [mc "%s:" $text]
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::button $w.global.$name.b \
|
2007-09-13 23:07:46 +00:00
|
|
|
-text [mc "Change Font"] \
|
|
|
|
-command [list \
|
2010-01-26 00:05:31 +00:00
|
|
|
tchoosefont \
|
2007-09-13 23:07:46 +00:00
|
|
|
$w \
|
|
|
|
[mc "Choose %s" $text] \
|
|
|
|
global_config_new(gui.$font^^family) \
|
|
|
|
global_config_new(gui.$font^^size) \
|
|
|
|
]
|
2010-01-26 00:05:31 +00:00
|
|
|
${NS}::label $w.global.$name.f -textvariable global_config_new(gui.$font^^family)
|
|
|
|
${NS}::label $w.global.$name.s -textvariable global_config_new(gui.$font^^size)
|
|
|
|
${NS}::label $w.global.$name.pt -text [mc "pt."]
|
2007-09-13 23:07:46 +00:00
|
|
|
pack $w.global.$name.l -side left -anchor w
|
|
|
|
pack $w.global.$name.b -side right -anchor e
|
|
|
|
pack $w.global.$name.pt -side right -anchor w
|
|
|
|
pack $w.global.$name.s -side right -anchor w
|
|
|
|
pack $w.global.$name.f -side right -anchor w
|
2007-05-08 03:35:48 +00:00
|
|
|
pack $w.global.$name -side top -anchor w -fill x
|
|
|
|
}
|
|
|
|
|
|
|
|
bind $w <Visibility> "grab $w; focus $w.buttons.save"
|
|
|
|
bind $w <Key-Escape> "destroy $w"
|
|
|
|
bind $w <Key-Return> [list do_save_config $w]
|
2007-10-08 05:39:08 +00:00
|
|
|
|
|
|
|
if {[is_MacOSX]} {
|
|
|
|
set t [mc "Preferences"]
|
|
|
|
} else {
|
|
|
|
set t [mc "Options"]
|
|
|
|
}
|
|
|
|
wm title $w "[appname] ([reponame]): $t"
|
2010-01-26 00:05:31 +00:00
|
|
|
wm deiconify $w
|
2007-05-08 03:35:48 +00:00
|
|
|
tkwait window $w
|
|
|
|
}
|
|
|
|
|
|
|
|
proc do_restore_defaults {} {
|
2008-11-16 18:46:47 +00:00
|
|
|
global font_descs default_config repo_config system_config
|
2007-05-08 03:35:48 +00:00
|
|
|
global repo_config_new global_config_new
|
|
|
|
|
|
|
|
foreach name [array names default_config] {
|
2008-11-16 18:46:47 +00:00
|
|
|
set repo_config_new($name) $system_config($name)
|
|
|
|
set global_config_new($name) $system_config($name)
|
2007-05-08 03:35:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach option $font_descs {
|
|
|
|
set name [lindex $option 0]
|
2008-11-16 18:46:47 +00:00
|
|
|
set repo_config(gui.$name) $system_config(gui.$name)
|
2007-05-08 03:35:48 +00:00
|
|
|
}
|
|
|
|
apply_config
|
|
|
|
|
|
|
|
foreach option $font_descs {
|
|
|
|
set name [lindex $option 0]
|
|
|
|
set font [lindex $option 1]
|
|
|
|
set global_config_new(gui.$font^^family) \
|
|
|
|
[font configure $font -family]
|
|
|
|
set global_config_new(gui.$font^^size) \
|
|
|
|
[font configure $font -size]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
proc do_save_config {w} {
|
2008-09-17 21:07:32 +00:00
|
|
|
if {![config_check_encodings]} return
|
2007-05-08 03:35:48 +00:00
|
|
|
if {[catch {save_config} err]} {
|
2007-09-14 05:50:09 +00:00
|
|
|
error_popup [strcat [mc "Failed to completely save options:"] "\n\n$err"]
|
2007-05-08 03:35:48 +00:00
|
|
|
}
|
|
|
|
reshow_diff
|
|
|
|
destroy $w
|
|
|
|
}
|