Scid  4.6.5
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 <Alt-F4> { ::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  #TODO: to be checked
115  bind $w <F6> ::book::open
116  bind $w <F12> ::CorrespondenceChess::CCWindow
117  bind $w <Control-F12> {::CorrespondenceChess::OpenCorrespondenceDB; ::CorrespondenceChess::ReadInbox}
118  bind $w <Alt-F12> {::CorrespondenceChess::OpenCorrespondenceDB; ::CorrespondenceChess::FetchGames}
119  bind $w <Control-equal> ::tb::Open
120  bind $w <Control-d> ::windows::switcher::Open
121  bind $w <Control-e> "::makeCommentWin toggle"
122  bind $w <Control-i> ::windows::stats::Open
123  bind $w <Control-l> ::windows::gamelist::Open
124  bind $w <Control-m> ::maint::OpenClose
125  bind $w <Control-p> ::pgn::OpenClose
126  bind $w <Control-t> ::tree::make
127  bind $w <Control-E> ::windows::eco::OpenClose
128  bind $w <Control-K> ::ptrack::make
129  bind $w <Control-O> ::optable::makeReportWin
130  bind $w <Control-P> ::plist::toggle
131  bind $w <Control-T> ::tourney::toggle
132  bind $w <Control-X> crosstabWin
133 
134 
135  #TODO: to be improved
136  bind $w <F2> "::makeAnalysisWin 1 0"
137  bind $w <F3> "::makeAnalysisWin 2 0"
138  bind $w <F4> { if {[winfo exists .analysisWin1]} { .analysisWin1.b1.bStartStop invoke } }
139  bind $w <F5> { if {[winfo exists .analysisWin2]} { .analysisWin2.b1.bStartStop invoke } }
140  bind $w <Control-A> makeAnalysisWin
141  bind $w <Control-Shift-2> "makeAnalysisWin 2"
142  bind $w <Control-a> {sc_var create; updateBoard -pgn}
143 
144 
145  #TODO: are these shortcuts useful?
146  bind $w <Control-B> ::search::board
147  bind $w <Control-H> ::search::header
148  bind $w <Control-M> ::search::material
149  bind $w <Control-KeyPress-U> ::search:::usefile
150 
151  bind $w <Control-C> ::copyFEN
152  bind $w <Control-V> ::pasteFEN
153  bind $w <Control-E> ::tools::email
154  bind $w <Control-I> importPgnGame
155  bind $w <Control-D> {sc_move ply [sc_eco game ply]; updateBoard}
156  bind $w <Control-G> tools::graphs::filter::Open
157  bind $w <Control-J> tools::graphs::absfilter::Open
158  bind $w <Control-u> ::game::GotoMoveNumber
159  bind $w <Control-Y> findNovelty
160  bind $w <F1> {helpWindow Contents}
161  bind $w <Control-N> nameEditor
162 
163  bind $w <Control-slash> ::file::finder::Open
164  bind $w <Control-Shift-Up> {::game::LoadNextPrev first}
165  bind $w <Control-Shift-Down> {::game::LoadNextPrev last}
166  bind $w <Control-Up> {::game::LoadNextPrev previous}
167  bind $w <Control-Down> {::game::LoadNextPrev next}
168  bind $w <Control-question> ::game::LoadRandom
169 }
170 
171 proc excludeTextWidget {w} {
172  if { [regexp ".*(Entry|Text|Combobox)" [winfo class $w]] } {
173  if {! [info exists ::keyboardShortcutsExcept($w)]} {
174  return "continue"
175  }
176  }
177 }