Scid  4.7.0
keyboard.tcl
Go to the documentation of this file.
1 #
2 # Copyright (C) 2014 Fulvio Benini
3 #
4 # This file is part of Scid (Shane's Chess Information Database).
5 # Scid is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation.
8 
9 
10 # CUSTOMIZATION:
11 # By editing this file you can customize the keyboard shortcuts,
12 # in order to best suit your preferences.
13 # It is not necessary to recompile scid after changing this file.
14 
15 proc keyboardShortcuts {w} {
16  # Go back one move
17  bind $w <Left> {
18  eval [excludeTextWidget %W]
19  ::move::Back;
20  break
21  }
22 
23  # Go forward one move
24  bind $w <Right> {
25  eval [excludeTextWidget %W]
26  ::move::Forward
27  break
28  }
29 
30  bind $w <Up> {
31  eval [excludeTextWidget %W]
32  ::move::Back 10
33  break
34  }
35 
36  bind $w <Down> {
37  eval [excludeTextWidget %W]
38  ::move::Forward 10
39  break
40  }
41 
42  # Exit Variation/Go to game start
43  bind $w <Home> {
44  eval [excludeTextWidget %W]
45  if {[::move::ExitVar] != 0} { break }
46  ::move::Start
47  break
48  }
49 
50  # Go to game end
51  bind $w <End> {
52  eval [excludeTextWidget %W]
53  ::move::End
54  break
55  }
56 
57  # Close Scid
58  # bind $w <Control-q> { ::file::Exit }
59 
60  # Open a database
61  bind $w <Control-o> { ::file::Open }
62 
63  # Close the current database
64  # TODO: is better to use control-w to close the focused window?
65  bind $w <Control-w> { ::file::Close }
66 
67  # Undo
68  bind $w <Control-z> { undoFeature undo }
69 
70  # Redo
71  bind $w <Control-y> { undoFeature redo }
72 
73  # New game
74  bind $w <Control-n> { ::game::Clear }
75 
76  # Save current game
77  bind $w <Control-s> { ::gameReplace }
78 
79  # Save current game as new
80  bind $w <Control-S> { ::gameAdd }
81 
82  # Toggle fullscreen
83  bind $w <F11> { wm attributes . -fullscreen [expr ![wm attributes . -fullscreen]] }
84 
85  # Rotate the chess board
86  bind $w <period> {
87  eval [excludeTextWidget %W]
88  toggleRotateBoard
89  break
90  }
91 
92  # Open "Setup Board" dialog
93  bind $w <s> {
94  eval [excludeTextWidget %W]
95  ::setupBoard
96  break
97  }
98 
99 
100  # Open the enter/create variation dialog
101  # TODO: <v> is not intuitive: <space> or <up> <down> may be better
102  bind $w <KeyPress-v> {
103  eval [excludeTextWidget %W]
104  ::showVars
105  break
106  }
107 
108  # Change current database
109  set totalBaseSlots [sc_info limit bases]
110  for {set i 1} { $i <= $totalBaseSlots} {incr i} {
111  bind $w <Control-Key-$i> "::file::SwitchToBase $i"
112  }
113 
114  # Open the help window
115  bind $w <F1> { helpWindowPertinent %W }
116 
117  # Toggle the active window between docked/undocked
118  bind $w <F9> { ::win::toggleDocked %W }
119 
120  #TODO: to be checked
121  bind $w <F6> ::book::open
122  bind $w <F12> ::CorrespondenceChess::CCWindow
123  bind $w <Control-F12> {::CorrespondenceChess::OpenCorrespondenceDB; ::CorrespondenceChess::ReadInbox}
124  bind $w <Alt-F12> {::CorrespondenceChess::OpenCorrespondenceDB; ::CorrespondenceChess::FetchGames}
125  bind $w <Control-equal> ::tb::Open
126  bind $w <Control-d> ::windows::switcher::Open
127  bind $w <Control-e> "::makeCommentWin toggle"
128  bind $w <Control-i> ::windows::stats::Open
129  bind $w <Control-l> ::windows::gamelist::Open
130  bind $w <Control-m> ::maint::OpenClose
131  bind $w <Control-p> ::pgn::OpenClose
132  bind $w <Control-t> ::tree::make
133  bind $w <Control-E> ::windows::eco::OpenClose
134  bind $w <Control-K> ::ptrack::make
135  bind $w <Control-O> ::optable::makeReportWin
136  bind $w <Control-P> ::plist::toggle
137  bind $w <Control-T> ::tourney::toggle
138  bind $w <Control-X> ::crosstab::Open
139 
140 
141  #TODO: to be improved
142  bind $w <F2> "::makeAnalysisWin 1 0"
143  bind $w <F3> "::makeAnalysisWin 2 0"
144  bind $w <F4> { if {[winfo exists .analysisWin1]} { .analysisWin1.b1.bStartStop invoke } }
145  bind $w <F5> { if {[winfo exists .analysisWin2]} { .analysisWin2.b1.bStartStop invoke } }
146  bind $w <Control-A> makeAnalysisWin
147  bind $w <Control-Shift-2> "makeAnalysisWin 2"
148  bind $w <Control-a> {sc_var create; updateBoard -pgn}
149 
150 
151  #TODO: are these shortcuts useful?
152  bind $w <Control-B> ::search::board
153  bind $w <Control-H> ::search::header
154  bind $w <Control-M> ::search::material
155  bind $w <Control-KeyPress-U> ::search:::usefile
156 
157  bind $w <Control-C> ::copyFEN
158  bind $w <Control-V> ::pasteFEN
159  bind $w <Control-E> ::tools::email
160  bind $w <Control-I> importPgnGame
161  bind $w <Control-D> {sc_move ply [sc_eco game ply]; updateBoard}
162  bind $w <Control-G> tools::graphs::filter::Open
163  bind $w <Control-J> tools::graphs::absfilter::Open
164  bind $w <Control-u> ::game::GotoMoveNumber
165  bind $w <Control-Y> findNovelty
166  bind $w <Control-N> nameEditor
167 
168  bind $w <Control-slash> ::file::finder::Open
169  bind $w <Control-Shift-Up> {::game::LoadNextPrev first}
170  bind $w <Control-Shift-Down> {::game::LoadNextPrev last}
171  bind $w <Control-Up> {::game::LoadNextPrev previous}
172  bind $w <Control-Down> {::game::LoadNextPrev next}
173  bind $w <Control-question> ::game::LoadRandom
174 }
175 
176 proc excludeTextWidget {w} {
177  if { [regexp ".*(Entry|Text|Combobox)" [winfo class $w]] } {
178  # HACK: enable binding for .pgnWin
179  # TODO: replace this using the new %M (available since Tk 8.6.4)
180  if {$w ne ".pgnWin.text"} {
181  return "continue"
182  }
183  }
184 }