| 1 |
## -*- cperl -*- |
| 2 |
## |
| 3 |
## This file is part of Athena, copyright (c) 2001-2006 Bruce Ravel |
| 4 |
## |
| 5 |
## This section of the code contains subroutines associated with |
| 6 |
## key bindings |
| 7 |
|
| 8 |
sub set_key_data { |
| 9 |
%key_data = (File => |
| 10 |
{ |
| 11 |
a001 => |
| 12 |
["Open file", sub{read_file(0)}, "any", 'Ctrl-o'], |
| 13 |
a004 => |
| 14 |
["Open many files", sub{read_file(1)}, "any", 'Alt-o'], |
| 15 |
a008 => |
| 16 |
["Open most recent file", sub{read_file(0, $mru{mru}{1})}, "any"], |
| 17 |
a011 => |
| 18 |
["Open second most recent file", sub{read_file(0, $mru{mru}{2})}, "any"], |
| 19 |
a014 => |
| 20 |
["Open third most recent file", sub{read_file(0, $mru{mru}{3})}, "any"], |
| 21 |
a018 => |
| 22 |
["Open fourth most recent file", sub{read_file(0, $mru{mru}{4})}, "any"], |
| 23 |
a021 => |
| 24 |
["Open URL", \&fetch_url, "any"], |
| 25 |
a024 => |
| 26 |
["Save entire project", sub{&save_project('all quick')}, "any", 'Ctrl-s'], |
| 27 |
a028 => |
| 28 |
["Save entire project as", sub{&save_project('all')}, "any"], |
| 29 |
a031 => |
| 30 |
["Save marked groups as a project" , sub{&save_project('marked')}, "any"], |
| 31 |
a033 => |
| 32 |
['Prompt for save space', sub{&dispatch_space('save')}, "any"], |
| 33 |
a034 => |
| 34 |
['Save mu(E)', sub{save_chi('e')}, "any"], |
| 35 |
a038 => |
| 36 |
['Save norm(E)', sub{save_chi('n')}, "any"], |
| 37 |
a041 => |
| 38 |
['Save deriv(E)', sub{save_chi('d')}, "any"], |
| 39 |
a044 => |
| 40 |
['Save chi(k)', sub{save_chi('k')}, "any"], |
| 41 |
a048 => |
| 42 |
['Save chi(R)', sub{save_chi('R')}, "any"], |
| 43 |
a051 => |
| 44 |
['Save chi(q)', sub{save_chi('q')}, "any"], |
| 45 |
a054 => |
| 46 |
["Save marked groups as mu(E)", sub{save_marked('e')}, "any"], |
| 47 |
a058 => |
| 48 |
["Save marked groups as norm(E)", sub{save_marked('n')}, "any"], |
| 49 |
a061 => |
| 50 |
["Save marked groups as deriv(E)", sub{save_marked('d')}, "any"], |
| 51 |
a064 => |
| 52 |
["Save marked groups as chi(k)", sub{save_marked('k')}, "any"], |
| 53 |
a068 => |
| 54 |
["Save marked groups as |chi(R)|", sub{save_marked('rm')}, "any"], |
| 55 |
a071 => |
| 56 |
["Save marked groups as Re[chi(R)]", sub{save_marked('rr')}, "any"], |
| 57 |
a074 => |
| 58 |
["Save marked groups as Im[chi(R)]", sub{save_marked('ri')}, "any"], |
| 59 |
a078 => |
| 60 |
["Save marked groups as |chi(q)|", sub{save_marked('qm')}, "any"], |
| 61 |
a081 => |
| 62 |
["Save marked groups as Re[chi(q)]", sub{save_marked('qr')}, "any"], |
| 63 |
a084 => |
| 64 |
["Save marked groups as Im[chi(q)]", sub{save_marked('qi')}, "any"], |
| 65 |
#a088 => |
| 66 |
#["Close project", sub{reset_window($which_showing, $fat_showing) |
| 67 |
# unless ($fat_showing eq 'normal'); |
| 68 |
# delete_many($list, $dmode, 0)}, "any", 'Ctrl-w'], |
| 69 |
a091 => |
| 70 |
['Quit', \&quit_athena, "any", 'Ctrl-q'], |
| 71 |
}, |
| 72 |
Edit => |
| 73 |
{ |
| 74 |
a001 => |
| 75 |
["Display Ifeffit buffer", sub{raise_palette('ifeffit'); $top->update;}, "any", 'Ctrl-1'] , |
| 76 |
a004 => |
| 77 |
["Show group's titles", sub{raise_palette('titles'); $top->update;}, "any", 'Ctrl-2'], |
| 78 |
a008 => |
| 79 |
["Edit data as text", \&setup_data, "any", 'Ctrl-3'], |
| 80 |
a011 => |
| 81 |
["Show group's arrays", sub{Echo('No data!'), return unless ($current); |
| 82 |
raise_palette('ifeffit'); |
| 83 |
return if ($current eq "Default Parameters"); |
| 84 |
$setup->dispose("show \@group $current\n", $dmode); |
| 85 |
$top->update}, "any"], |
| 86 |
a014 => |
| 87 |
["Show all strings", sub{raise_palette('ifeffit'); |
| 88 |
$setup->dispose("show \@strings\n", $dmode); |
| 89 |
$top->update}, "any"], |
| 90 |
a018 => |
| 91 |
["Show all macros", sub{raise_palette('ifeffit'); |
| 92 |
$setup->dispose("show \@macros\n", $dmode); |
| 93 |
$top->update}, "any"], |
| 94 |
a021 => |
| 95 |
["Display echo buffer", sub{raise_palette('echo'); $top->update;}, "any", 'Ctrl-4'], |
| 96 |
a024 => |
| 97 |
["Record a macro", sub{raise_palette('macro'); $top->update;}, "any", 'Ctrl-5'], |
| 98 |
a028 => |
| 99 |
["Load a macro" , \&load_macro, "any"], |
| 100 |
a031 => |
| 101 |
["Write in project journal", sub{raise_palette('journal'); $top->update;}, "any", 'Ctrl-6'], |
| 102 |
a034 => |
| 103 |
["Write an Excel report (all groups)", sub{&report_excel('all')}, "any"], |
| 104 |
a038 => |
| 105 |
["Write an Excel report (marked groups)", sub{&report_excel('marked')}, "any"], |
| 106 |
a041 => |
| 107 |
["Write a CSV report (all groups)", sub{&report_csv('all')}, "any"], |
| 108 |
a044 => |
| 109 |
["Write a CSV report (marked groups)", sub{&report_csv('marked')}, "any"], |
| 110 |
a048 => |
| 111 |
["Write an ascii report (all groups)", sub{&report_ascii('all')}, "any"], |
| 112 |
a051 => |
| 113 |
["Write an ascii report (marked groups)", sub{&report_ascii('marked')}, "any"], |
| 114 |
}, |
| 115 |
|
| 116 |
Group => |
| 117 |
{ |
| 118 |
a001 => |
| 119 |
["Copy group", \©_group, "any", 'Ctrl-y'], |
| 120 |
a004 => |
| 121 |
["Make detector groups", \&make_detectors, "any"], |
| 122 |
a008 => |
| 123 |
["Make background group", \&make_background, "any"], |
| 124 |
a011 => |
| 125 |
["Change group label", \&get_new_name, "any", 'Ctrl-l'], |
| 126 |
a014 => |
| 127 |
["Remove group", sub{delete_group($list, $dmode);}, "any"], |
| 128 |
a018 => |
| 129 |
["Identify group's record type", \&identify_group, "any"], |
| 130 |
a021 => |
| 131 |
["Move group up", \&group_up, "any", 'Alt-k'], |
| 132 |
a024 => |
| 133 |
["Move group down", \&group_down, "any", 'Alt-j'], |
| 134 |
a028 => |
| 135 |
["Remove marked groups", sub{delete_many($list, $dmode, 1)}, "any"], |
| 136 |
a031 => |
| 137 |
["Set all groups' values to the current", sub{Echo('No data!'), return unless ($current); |
| 138 |
Echo("Parameters for all groups reset to \`$current\'"); |
| 139 |
my $orig = $current; |
| 140 |
foreach my $x (keys %marked) { |
| 141 |
next if ($x eq 'Default Parameters'); |
| 142 |
next if ($x eq $current); |
| 143 |
$groups{$x}->set_to_another($groups{$current}); |
| 144 |
set_properties(1, $x, 0); |
| 145 |
} |
| 146 |
; |
| 147 |
set_properties(1, $orig, 0); |
| 148 |
Echo(@done);}, "any"], |
| 149 |
a034 => |
| 150 |
["Set all marked groups' values to the current", sub{Echo('No data!'), return unless ($current); |
| 151 |
Echo("Parameters for all marked groups reset to \`$current\'"); |
| 152 |
my $orig = $current; |
| 153 |
foreach my $x (keys %marked) { |
| 154 |
next if ($x eq 'Default Parameters'); |
| 155 |
next if ($x eq $current); |
| 156 |
next unless ($marked{$x}); |
| 157 |
$groups{$x}->set_to_another($groups{$current}); |
| 158 |
set_properties(1, $x, 0); |
| 159 |
} |
| 160 |
; |
| 161 |
set_properties(1, $orig, 0); |
| 162 |
Echo(@done);}, "any"], |
| 163 |
a038 => |
| 164 |
["Set current groups' values to their defaults", sub{Echo('No data!'), return unless ($current); |
| 165 |
my @keys = grep {/^(bft|bkg|fft)/} (keys %widget); |
| 166 |
set_params('def', @keys); |
| 167 |
set_properties(1, $current, 0); |
| 168 |
Echo("Reset all values for this group to their defaults");}, "any"], |
| 169 |
a041 => |
| 170 |
["Reset E0 for this group", sub{set_edge($current, 'edge')}, "any"], |
| 171 |
a044 => |
| 172 |
["Set E0 to a set fraction of the edge step", sub{set_edge($current, 'fraction')}, "any"], |
| 173 |
a048 => |
| 174 |
["Set E0 to atomic value", sub{set_edge($current, 'atomic')}, "any"], |
| 175 |
}, |
| 176 |
|
| 177 |
Plot => |
| 178 |
{ |
| 179 |
a0001 => |
| 180 |
['Prompt for space for plotting current group', sub{&dispatch_space('plot_current')}, "any"], |
| 181 |
a0005 => |
| 182 |
['Prompt for space for plotting marked groups', sub{&dispatch_space('plot_marked')}, "any"], |
| 183 |
|
| 184 |
|
| 185 |
a001 => |
| 186 |
['Plot merge+standard deviation', sub{my $group = $groups{$current}->{group}; |
| 187 |
my $space = $groups{$current}->{is_merge}; |
| 188 |
&plot_merge($group, $space);}, "any"], |
| 189 |
a004 => |
| 190 |
['Plot chi(E)', sub{my $str = 'k' . $plot_features{k_w} . 'e'; |
| 191 |
$groups{$current}->plotk($str,$dmode,\%plot_features, \@indicator) }, "any"], |
| 192 |
a008 => |
| 193 |
['Plot chi(E), marked', sub{my $str = $plot_features{k_w} . 'e'; |
| 194 |
$groups{$current}->plot_marked($str,$dmode,\%groups, |
| 195 |
\%marked, \%plot_features, |
| 196 |
$list, \@indicator) }, "any"], |
| 197 |
a011 => |
| 198 |
['Zoom', \&zoom, "any", 'Ctrl-='], |
| 199 |
a014 => |
| 200 |
['Unzoom', sub{&replot('replot')}, "any", 'Ctrl--'], |
| 201 |
a018 => |
| 202 |
['Cursor', \&cursor, "any", 'Ctrl-.'], |
| 203 |
## save last plot as an image |
| 204 |
a021 => |
| 205 |
['Print last plot', sub{&replot('print')}, "any", 'Ctrl-p'], |
| 206 |
##a024 => |
| 207 |
##['Detach plot buttons', \&detach_plot, "any"], |
| 208 |
}, |
| 209 |
|
| 210 |
Mark => |
| 211 |
{ |
| 212 |
a001 => |
| 213 |
['Mark all groups', sub{mark('all')}, "any", 'Ctrl-a'], |
| 214 |
a004 => |
| 215 |
['Invert marks', sub{mark('toggle')}, "any", 'Ctrl-i'], |
| 216 |
a008 => |
| 217 |
['Clear all marks', sub{mark('none')}, "any", 'Ctrl-u'], |
| 218 |
a011 => |
| 219 |
["Toggle this group's mark", sub{mark('this')}, "any", 'Ctrl-t'], |
| 220 |
a014 => |
| 221 |
["Mark regex", sub{mark('regex')}, "any", 'Ctrl-r'], |
| 222 |
a017 => |
| 223 |
["Unmark regex", sub{mark('unregex')}, "any"], |
| 224 |
}, |
| 225 |
|
| 226 |
Data => |
| 227 |
{ |
| 228 |
a011 => |
| 229 |
["Open calibration dialog", \&calibrate, "normal"], |
| 230 |
a012 => |
| 231 |
{"Calibrate" =>{ |
| 232 |
a010 => |
| 233 |
['Select a point', sub{$widget{calib_select} ->invoke()}, "calibration"], |
| 234 |
a020 => |
| 235 |
['Replot', sub{$widget{calib_replot} ->invoke()}, "calibration"], |
| 236 |
a030 => |
| 237 |
['Calibrate', sub{$widget{calib_calibrate}->invoke()}, "calibration"], |
| 238 |
}, |
| 239 |
}, |
| 240 |
a031 => |
| 241 |
['Open deglitching dialog', \°litch_palette, "normal"], |
| 242 |
a032 => |
| 243 |
{"Deglitch" =>{ |
| 244 |
a010 => |
| 245 |
["Choose a point", sub{$widget{deg_single}->invoke()}, "deglitching"], |
| 246 |
a020 => |
| 247 |
["Remove a point", sub{$widget{deg_point} ->invoke()}, "deglitching"], |
| 248 |
a030 => |
| 249 |
["Replot", sub{$widget{deg_replot}->invoke()}, "deglitch"], |
| 250 |
a040 => |
| 251 |
["Remove glitches", sub{$widget{deg_remove}->invoke()}, "deglitching"], |
| 252 |
}, |
| 253 |
}, |
| 254 |
a051 => |
| 255 |
['Open truncation dialog', \&truncate_palette, "normal"], |
| 256 |
a052 => |
| 257 |
{"Truncate" =>{ |
| 258 |
a010 => |
| 259 |
["Replot", sub{$widget{trun_replot} ->invoke()}, "truncation"], |
| 260 |
a020 => |
| 261 |
["Truncate", sub{$widget{trun_truncate}->invoke()}, "truncation"], |
| 262 |
}, |
| 263 |
}, |
| 264 |
a071 => |
| 265 |
['Open smoothing dialog', \&smooth, "normal"], |
| 266 |
a072 => |
| 267 |
{"Smooth" =>{ |
| 268 |
a010 => |
| 269 |
["Choose iterative smoothing", sub{$widget{sm_it_button}->invoke()}, "smoothing"], |
| 270 |
a020 => |
| 271 |
["Choose Fourier filter smoothing", sub{$widget{sm_ff_button}->invoke()}, "smoothing"], |
| 272 |
a030 => |
| 273 |
["Plot data and smoothed spectrum", sub{$widget{sm_plot}->invoke()}, "smoothing"], |
| 274 |
a040 => |
| 275 |
["Put smoothed data into a group", sub{$widget{sm_save}->invoke()}, "smoothing"], |
| 276 |
}, |
| 277 |
}, |
| 278 |
a900 => |
| 279 |
['How many spline knots?', \&nknots, "any"], |
| 280 |
}, |
| 281 |
|
| 282 |
Align => |
| 283 |
{ |
| 284 |
a011 => |
| 285 |
['Align scans', sub{&align_two($config{align}{align_default})}, "normal"], |
| 286 |
a012 => |
| 287 |
{"Align" =>{ |
| 288 |
a010 => |
| 289 |
["Auto align", sub{$widget{align_auto} ->invoke()}, "alignment"], |
| 290 |
a020 => |
| 291 |
["Replot", sub{$widget{align_replot} ->invoke()}, "alignment"], |
| 292 |
a030 => |
| 293 |
["plus 5", sub{$widget{align_plus5} ->invoke()}, "alignment"], |
| 294 |
a040 => |
| 295 |
["minus 5", sub{$widget{align_minus5} ->invoke()}, "alignment"], |
| 296 |
a050 => |
| 297 |
["plus 1", sub{$widget{align_plus1} ->invoke()}, "alignment"], |
| 298 |
a060 => |
| 299 |
["minus 1", sub{$widget{align_minus1} ->invoke()}, "alignment"], |
| 300 |
a070 => |
| 301 |
["plus 1/2", sub{$widget{'align_plus0.5'} ->invoke()}, "alignment"], |
| 302 |
a080 => |
| 303 |
["minus 1/2", sub{$widget{'align_minus0.1'}->invoke()}, "alignment"], |
| 304 |
a090 => |
| 305 |
["plus 1/10", sub{$widget{'align_plu0.1'} ->invoke()}, "alignment"], |
| 306 |
a100 => |
| 307 |
["minus 1/10", sub{$widget{'align_minus0.1'}->invoke()}, "alignment"], |
| 308 |
a110 => |
| 309 |
["Restore value", sub{$widget{align_restore} ->invoke()}, "alignment"], |
| 310 |
} |
| 311 |
}, |
| 312 |
a071 => |
| 313 |
["Calibrate dispersive XAS", \&pixel, "normal"], |
| 314 |
a072 => |
| 315 |
{"Dispersive XAS" => { |
| 316 |
a010 => |
| 317 |
["Refine alignment parameters", sub{$widget{pixel_refine} ->invoke()}, "pixel"], |
| 318 |
a020 => |
| 319 |
["Toggle constraint button", sub{$widget{pixel_constrain} ->invoke()}, "pixel"], |
| 320 |
a030 => |
| 321 |
["Reset offset", sub{$widget{pixel_linear_button} ->invoke()}, "pixel"], |
| 322 |
a040 => |
| 323 |
["Replot standard and pixel data", sub{$widget{pixel_replot} ->invoke()}, "pixel"], |
| 324 |
a050 => |
| 325 |
["Make data group", sub{$widget{pixel_make} ->invoke()}, "pixel"], |
| 326 |
a060 => |
| 327 |
["Convert all marked pixel groups", sub{$widget{pixel_all} ->invoke()}, "pixel"], |
| 328 |
}, |
| 329 |
}, |
| 330 |
}, |
| 331 |
|
| 332 |
Merge => |
| 333 |
{ |
| 334 |
a001 => |
| 335 |
['Prompt for merge space', sub{&dispatch_space('merge')}, "normal"], |
| 336 |
a005 => |
| 337 |
['Merge marked data in chi(k)', sub{&merge_groups('k')}, "normal"], |
| 338 |
a010 => |
| 339 |
['Merge marked data in norm(E)', sub{&merge_groups('n')}, "normal"], |
| 340 |
a015 => |
| 341 |
['Merge marked data in mu(E)', sub{&merge_groups('e')}, "normal"], |
| 342 |
a020 => |
| 343 |
['Merge marked data in chi(R)', sub{&merge_groups('r')}, "normal"], |
| 344 |
a025 => |
| 345 |
['Merge marked data in chi(q)', sub{&merge_groups('q')}, "normal"], |
| 346 |
}, |
| 347 |
|
| 348 |
Diff => |
| 349 |
{ |
| 350 |
a001 => |
| 351 |
['Prompt for difference spectrum space', sub{&dispatch_space('difference')}, "normal"], |
| 352 |
a005 => |
| 353 |
['Open difference spectra dialog: norm(E)', sub{&difference('n')}, "normal"], |
| 354 |
a010 => |
| 355 |
['Open difference spectra dialog: chi(k)', sub{&difference('k')}, "normal"], |
| 356 |
a015 => |
| 357 |
['Open difference spectra dialog: mu(E)', sub{&difference('e')}, "normal"], |
| 358 |
a020 => |
| 359 |
['Open difference spectra dialog: chi(R)', sub{&difference('r')}, "normal"], |
| 360 |
a025 => |
| 361 |
['Open difference spectra dialog: chi(q)', sub{&difference('q')}, "normal"], |
| 362 |
a030 => |
| 363 |
{"Difference Spectra" => { |
| 364 |
a010 => |
| 365 |
["Integrate", sub{$widget{diff_integrate}->invoke()}, "difference spectrum"], |
| 366 |
a020 => |
| 367 |
["Replot", sub{$widget{diff_replot}->invoke()}, "difference spectrum"], |
| 368 |
a030 => |
| 369 |
["Make difference group", sub{$widget{diff_save}->invoke()}, "difference spectrum"], |
| 370 |
a040 => |
| 371 |
["Make difference groups from all marked groups", sub{$widget{diff_savemarked}->invoke()}, "difference spectrum"], |
| 372 |
a050 => |
| 373 |
["Toggle Integrate? button", sub{$widget{diff_savemarkedi}->invoke()}, "difference spectrum"], |
| 374 |
}, |
| 375 |
}, |
| 376 |
}, |
| 377 |
|
| 378 |
Analysis => |
| 379 |
{ |
| 380 |
a021 => |
| 381 |
['Open log-ratio dialog', \&log_ratio, "normal"], |
| 382 |
a022 => |
| 383 |
{"Log-Ratio" => { |
| 384 |
a010 => |
| 385 |
["Fit", sub{$widget{lr_fit} ->invoke()}, "log ratio"], |
| 386 |
a020 => |
| 387 |
["Plot log-ratio", sub{$widget{lr_lr} ->invoke()}, "log ratio"], |
| 388 |
a030 => |
| 389 |
["Plot phase difference", sub{$widget{lr_pd} ->invoke()}, "log ratio"], |
| 390 |
a040 => |
| 391 |
["Save ratio data", sub{$widget{lr_save} ->invoke()}, "log ratio"], |
| 392 |
a050 => |
| 393 |
["Write log file", sub{$widget{lr_log} ->invoke()}, "log ratio"], |
| 394 |
a060 => |
| 395 |
["Plot in k", sub{$widget{lr_plotk}->invoke()}, "log ratio"], |
| 396 |
a070 => |
| 397 |
["Plot in R", sub{$widget{lr_plotr}->invoke()}, "log ratio"], |
| 398 |
a080 => |
| 399 |
["Plot in q", sub{$widget{lr_plotq}->invoke()}, "log ratio"], |
| 400 |
}, |
| 401 |
}, |
| 402 |
a041 => |
| 403 |
['Open peak fitting dialog', \&peak_fit, "normal"], |
| 404 |
a042 => |
| 405 |
{"Peak fit" => { |
| 406 |
a010 => |
| 407 |
["Toggle components button", sub{$widget{peak_components}->invoke()}, "peak fitting"], |
| 408 |
a020 => |
| 409 |
["Toggle centroids button", sub{$widget{peak_show} ->invoke()}, "peak fitting"], |
| 410 |
a030 => |
| 411 |
["Fit and plot", sub{$widget{peak_fit} ->invoke()}, "peak fitting"], |
| 412 |
a040 => |
| 413 |
["Reset amplitudes and widths", sub{$widget{peak_reset} ->invoke()}, "peak fitting"], |
| 414 |
a050 => |
| 415 |
["Save best fit function as a data group",sub{$widget{peak_save} ->invoke()}, "peak fitting"], |
| 416 |
a060 => |
| 417 |
["Write a log file", sub{$widget{peak_log} ->invoke()}, "peak fitting"], |
| 418 |
}, |
| 419 |
}, |
| 420 |
|
| 421 |
a051 => |
| 422 |
['Open linear combination fitting dialog', \&lcf, "normal"], |
| 423 |
a052 => |
| 424 |
{"Linear combination fit" => { |
| 425 |
a010 => |
| 426 |
["Fit", sub{$widget{lcf_fit}->invoke()}, "linear combination fitting"], |
| 427 |
a020 => |
| 428 |
["Plot data and fit", sub{$widget{lcf_plot}->invoke()}, "linear combination fitting"], |
| 429 |
a030 => |
| 430 |
["Write a report", sub{$widget{lcf_report}->invoke()}, "linear combination fitting"], |
| 431 |
a040 => |
| 432 |
["Save fit as a group", sub{$widget{lcf_group}->invoke()}, "linear combination fitting"], |
| 433 |
a050 => |
| 434 |
["Reset", sub{$widget{lcf_reset}->invoke()}, "linear combination fitting"], |
| 435 |
a060 => |
| 436 |
["Toggle linear background", sub{$widget{lcf_linear}->invoke()}, "linear combination fitting"], |
| 437 |
}, |
| 438 |
}, |
| 439 |
}, |
| 440 |
|
| 441 |
## Add key binding data for your new analysis chore |
| 442 |
## here |
| 443 |
|
| 444 |
# a091 => |
| 445 |
# ['Open foobarication dialog', \&foobaricate, "normal"], |
| 446 |
# a092 => |
| 447 |
# {"Foobaricate" => |
| 448 |
# { |
| 449 |
# a005 => ["Do one thing", \&sub_ref1, "demo"], |
| 450 |
# a010 => ["Do another thing", \&sub_ref2, "demo"], |
| 451 |
# }, |
| 452 |
# }, |
| 453 |
|
| 454 |
Settings => |
| 455 |
{ |
| 456 |
a005 => |
| 457 |
['Swap panels', \&swap_panels, "any", 'Ctrl-/'], |
| 458 |
a010 => |
| 459 |
["Purge web download cache", \&purge_web_cache, "any"], |
| 460 |
a031 => |
| 461 |
["Edit preferences", \&prefs, "normal"], |
| 462 |
a032 => |
| 463 |
{Preferences => { |
| 464 |
a010 => |
| 465 |
["Save all parameters to Athena's defaults", sub{$widget{prefs_all} ->invoke()}, "preferences"], |
| 466 |
a020 => |
| 467 |
["Apply changes to this session", sub{$widget{prefs_apply} ->invoke()}, "preferences"], |
| 468 |
a030 => |
| 469 |
["Save changes for future sessions", sub{$widget{prefs_future} ->invoke()}, "preferences"], |
| 470 |
}, |
| 471 |
}, |
| 472 |
}, |
| 473 |
|
| 474 |
Help => |
| 475 |
{ |
| 476 |
a010 => |
| 477 |
['Document', sub{pod_display("index.pod")}, "any", 'Ctrl-m'], |
| 478 |
a020 => |
| 479 |
['Import a demo projects', \&read_demo, "normal"], |
| 480 |
a030 => |
| 481 |
['Show a hint', \&show_hint, "any", 'Ctrl-h'], |
| 482 |
a040 => |
| 483 |
['About Ifeffit', sub{Echo("Using Ifeffit ". Ifeffit::get_string("\$&build"))}, "any"], |
| 484 |
a050 => |
| 485 |
['About Athena', sub{Echo($About)}, "any"], |
| 486 |
a060 => |
| 487 |
["Check Ifeffit's memory usage", sub{$groups{"Default Parameters"} -> memory_check($top, \&Echo, \%groups, $max_heap, 1, 0)}, "any"], |
| 488 |
}, |
| 489 |
); |
| 490 |
## open FOO, ">foo"; |
| 491 |
## $Data::Dumper::Indent = 2; |
| 492 |
## $Data::Dumper::Deparse=1; |
| 493 |
## print FOO Data::Dumper->Dump([\%key_data], [qw(*key_data)]); |
| 494 |
## $Data::Dumper::Indent = 0; |
| 495 |
## close FOO; |
| 496 |
}; |
| 497 |
|
| 498 |
|
| 499 |
sub key_bindings { |
| 500 |
my %keys_params = (); |
| 501 |
$keys_params{save} = 0; |
| 502 |
$keys_params{modifier} = 'control'; |
| 503 |
$keys_params{modifier_label} = "Ctrl-$config{general}{user_key}"; |
| 504 |
$fat_showing = 'keys'; |
| 505 |
$hash_pointer = \%keys_params; |
| 506 |
map {$_ -> configure(-state=>'disabled')} |
| 507 |
($data_menu, $merge_menu, $anal_menu, $settings_menu); |
| 508 |
$fat -> packForget; |
| 509 |
my $keys = $container->Frame(@fatgeom, -relief=>'sunken', -borderwidth=>3) |
| 510 |
-> pack(-fill=>'both', -expand=>1); |
| 511 |
#$keys -> packPropagate(0); |
| 512 |
$which_showing = $keys; |
| 513 |
$keys -> Label(-text=>"Edit Key Bindings", |
| 514 |
-font=>$config{fonts}{large}, |
| 515 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 516 |
-> pack(-side=>'top', -fill=>'x', -anchor=>'w'); |
| 517 |
|
| 518 |
|
| 519 |
$keys -> Button(-text=>'Return to the main window', @button_list, |
| 520 |
-background=>$config{colors}{background2}, |
| 521 |
-activebackground=>$config{colors}{activebackground2}, |
| 522 |
-command=>sub{ |
| 523 |
if ($keys_params{save}) { |
| 524 |
my $message = "Do you want to save your key bindings for future sessions?"; |
| 525 |
my $dialog = |
| 526 |
$top -> Dialog(-bitmap => 'questhead', |
| 527 |
-text => $message, |
| 528 |
-title => 'Athena: save key bindings?', |
| 529 |
-buttons => ['Yes', 'No'], |
| 530 |
-default_button => 'Yes',); |
| 531 |
my $response = $dialog->Show(); |
| 532 |
&keys_save if ($response eq 'Yes'); |
| 533 |
}; |
| 534 |
&reset_window($keys, "key bindings", 0)} |
| 535 |
) |
| 536 |
-> pack(-side=>'bottom', -fill=>'x'); |
| 537 |
$keys -> Button(-text=>'Document section: key bindings', @button_list, |
| 538 |
-command=>sub{pod_display("ui::keys.pod")},) |
| 539 |
-> pack(-side=>'bottom', -fill=>'x', -pady=>4); |
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
my $labframe = $keys -> LabFrame(-label=>'All functions', |
| 544 |
-labelside=>'acrosstop') |
| 545 |
-> pack(-side=>'top', -expand=>1, -fill=>'both'); |
| 546 |
my $tree; |
| 547 |
$tree = $labframe -> Scrolled('Tree', |
| 548 |
-scrollbars => 'se', |
| 549 |
-width => 45, |
| 550 |
-background => $config{colors}{hlist}, |
| 551 |
-browsecmd => sub{&keys_browse($tree, \%keys_params)} |
| 552 |
) |
| 553 |
-> pack(-expand=>1, -fill=>'both'); |
| 554 |
$tree->Subwidget("xscrollbar")->configure(-background=>$config{colors}{background}, |
| 555 |
($is_windows) ? () : (-width=>8)); |
| 556 |
$tree->Subwidget("yscrollbar")->configure(-background=>$config{colors}{background}, |
| 557 |
($is_windows) ? () : (-width=>8)); |
| 558 |
|
| 559 |
my $frame = $keys -> Frame(-relief=>'flat') |
| 560 |
-> pack(-side=>'top'); |
| 561 |
|
| 562 |
$frame -> Label(-text=>'Category: ', |
| 563 |
-justify=>'right', |
| 564 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 565 |
-> grid(-row=>0, -column=>0, -sticky=>'e', -columnspan=>3); |
| 566 |
$frame -> Label(-text=>' ', -width=>35, -justify=>'left', |
| 567 |
-textvariable=>\$keys_params{category}) |
| 568 |
-> grid(-row=>0, -column=>3, -sticky=>'e', -columnspan=>2); |
| 569 |
$frame -> Label(-text=>'Valid when showing: ', |
| 570 |
-justify=>'right', |
| 571 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 572 |
-> grid(-row=>1, -column=>0, -sticky=>'e', -columnspan=>3); |
| 573 |
$frame -> Label(-text=>' ', -width=>35, -justify=>'left', |
| 574 |
-textvariable=>\$keys_params{valid}) |
| 575 |
-> grid(-row=>1, -column=>3, -sticky=>'e', -columnspan=>2); |
| 576 |
$frame -> Label(-text=>'Description: ', |
| 577 |
-justify=>'right', |
| 578 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 579 |
-> grid(-row=>2, -column=>0, -sticky=>'e', -columnspan=>3); |
| 580 |
$frame -> Label(-text=>' ', -width=>35, -justify=>'left', |
| 581 |
-textvariable=>\$keys_params{descr}) |
| 582 |
-> grid(-row=>2, -column=>3, -sticky=>'e', -columnspan=>2); |
| 583 |
$frame -> Label(-text=>'Bound to: ', |
| 584 |
-justify=>'right', |
| 585 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 586 |
-> grid(-row=>3, -column=>0, -sticky=>'e', -columnspan=>3); |
| 587 |
$frame -> Label(-text=>' ', -width=>35, -justify=>'left', |
| 588 |
-textvariable=>\$keys_params{bound}) |
| 589 |
-> grid(-row=>3, -column=>3, -sticky=>'e', -columnspan=>2); |
| 590 |
|
| 591 |
$frame -> Label(-text=>'Key: ', |
| 592 |
-justify=>'right', |
| 593 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 594 |
-> grid(-row=>4, -column=>0, -sticky=>'e'); |
| 595 |
$widget{keys_modifier} = $frame -> Optionmenu(-font=>$config{fonts}{small}, |
| 596 |
-textvariable => \$keys_params{modifier_label}, |
| 597 |
-width=>12, |
| 598 |
-borderwidth=>1, |
| 599 |
-state=>'disabled') |
| 600 |
-> grid(-row=>4, -column=>1); |
| 601 |
foreach my $i ("Ctrl-$config{general}{user_key}", "Alt-$config{general}{user_key}") { |
| 602 |
$widget{keys_modifier} -> command(-label => $i, |
| 603 |
-command=>sub{ |
| 604 |
$keys_params{modifier_label} = $i; |
| 605 |
$keys_params{modifier} = ($i =~ /^Ctrl/) ? 'control' : 'meta'; |
| 606 |
}) |
| 607 |
}; |
| 608 |
|
| 609 |
$widget{keys_key} = $frame -> KeyEntry(-width => 3, |
| 610 |
-justify => 'center', |
| 611 |
-font => $config{fonts}{fixed} |
| 612 |
-state => 'disabled',) |
| 613 |
-> grid(-row=>4, -column=>2, -sticky=>'w'); |
| 614 |
$widget{keys_bindit} = $frame |
| 615 |
-> Button(-text=>"Bind it!", @button_list, |
| 616 |
-state => 'disabled', |
| 617 |
-command=>sub{&keys_bind($tree, \%keys_params)}) |
| 618 |
-> grid(-row=>4, -column=>3, -sticky=>'e', -padx=>2); |
| 619 |
$widget{keys_unbind} = $frame |
| 620 |
-> Button(-text=>"Unbind", @button_list, |
| 621 |
-state => 'disabled', |
| 622 |
-command=>sub{&keys_unbind($tree, \%keys_params)}) |
| 623 |
-> grid(-row=>4, -column=>4, -sticky=>'w', -padx=>2); |
| 624 |
|
| 625 |
$frame -> Button(-text=>"Show all bindings", @button_list, |
| 626 |
-command=>\&keys_show_all) |
| 627 |
-> grid(-row=>5, -column=>0, -columnspan=>5, -sticky=>'ew'); |
| 628 |
#$frame -> Button(-text=>"Apply key bindings to current session", @button_list, |
| 629 |
# -command=>[\&Echo, "Apply."]) |
| 630 |
# -> grid(-row=>6, -column=>0, -columnspan=>4, -sticky=>'ew'); |
| 631 |
$widget{keys_save} = $frame |
| 632 |
-> Button(-text=>"Save key bindings for future sessions", @button_list, |
| 633 |
-command=>\&keys_save, |
| 634 |
-state=>'disabled') |
| 635 |
-> grid(-row=>7, -column=>0, -columnspan=>5, -sticky=>'ew'); |
| 636 |
$frame -> Button(-text=>"Clear all key bindings", @button_list, |
| 637 |
-command=>\&keys_clear) |
| 638 |
-> grid(-row=>8, -column=>0, -columnspan=>5, -sticky=>'ew'); |
| 639 |
|
| 640 |
&keys_fill_tree($tree, \%keys_params); |
| 641 |
}; |
| 642 |
|
| 643 |
|
| 644 |
## the way the tree paths are chosen, infoAnchor can be split on the |
| 645 |
## dots to yield the hash keys that get to the commands in %key_data |
| 646 |
sub keys_fill_tree { |
| 647 |
my $tree = $_[0]; |
| 648 |
foreach my $p (qw(File Edit Group Plot Mark Data Align Merge Diff |
| 649 |
Analysis Settings Help)) { |
| 650 |
$tree -> add($p, -text=>$p, -data=>'category'); |
| 651 |
foreach my $first (sort keys %{$key_data{$p}}) { |
| 652 |
if (ref($key_data{$p}->{$first}) eq 'ARRAY') { |
| 653 |
## these are commands in the menubar menus |
| 654 |
## $this is a concatination of the hash keys needed to get to |
| 655 |
## this command |
| 656 |
my $this = join(".", $p, $first); |
| 657 |
$tree -> add($this, |
| 658 |
-text=>$key_data{$p}->{$first}->[0], |
| 659 |
-data=>$key_data{$p}->{$first}); |
| 660 |
$tree -> setmode($this, 'none'); |
| 661 |
} elsif (ref($key_data{$p}->{$first}) eq 'HASH') { |
| 662 |
## these are commands on the various data processing views |
| 663 |
foreach my $second (sort keys %{$key_data{$p}->{$first}}) { |
| 664 |
my $this = join(".", $p, $first); |
| 665 |
$tree -> add($this, -text=>$second, -data=>'category'); |
| 666 |
foreach my $third (sort keys %{$key_data{$p}->{$first}->{$second}}) { |
| 667 |
## $child is a concatination of the hash keys needed to |
| 668 |
## get to this command |
| 669 |
my $child = join(".", $p, $first, $third); |
| 670 |
$tree -> add($child, |
| 671 |
-text=>$key_data{$p}->{$first}->{$second}->{$third}->[0], |
| 672 |
-data=>$key_data{$p}->{$first}->{$second}->{$third}); |
| 673 |
$tree -> setmode($child, 'none'); |
| 674 |
}; |
| 675 |
$tree -> setmode($this, 'close'); |
| 676 |
$tree -> close($this); |
| 677 |
}; |
| 678 |
}; |
| 679 |
}; |
| 680 |
$tree -> setmode($p, 'close'); |
| 681 |
$tree -> close($p); |
| 682 |
}; |
| 683 |
$tree->autosetmode(); |
| 684 |
}; |
| 685 |
|
| 686 |
sub keys_browse { |
| 687 |
my ($tree, $rhash) = @_; |
| 688 |
my $this = $tree->infoAnchor; |
| 689 |
$widget{keys_key} -> delete(0, 'end'); |
| 690 |
unless ($this) { # clicking on [+] button |
| 691 |
$$rhash{category} = ""; |
| 692 |
$$rhash{descr} = ""; |
| 693 |
$$rhash{function} = ""; |
| 694 |
$$rhash{valid} = ""; |
| 695 |
$$rhash{bound} = ""; |
| 696 |
map { $widget{'keys_'.$_} -> configure(-state=>'disabled') } (qw(bindit unbind key modifier)); |
| 697 |
return; |
| 698 |
}; |
| 699 |
my $data = $tree->infoData($this); |
| 700 |
|
| 701 |
if (ref($data) eq 'ARRAY') { # this is a command |
| 702 |
my @list = split(/\./, $this); |
| 703 |
if ($#list == 1) { |
| 704 |
$$rhash{category} = $list[0]; |
| 705 |
} else { |
| 706 |
## the ugly thing at the end of the next line is to pull the |
| 707 |
## name of the sub-branch out of the %key_data data structure |
| 708 |
$$rhash{category} = $list[0] . ' -> ' . (keys %{$key_data{$list[0]}->{$list[1]}})[0]; |
| 709 |
}; |
| 710 |
$$rhash{descr} = $$data[0]; |
| 711 |
$$rhash{function} = $$data[1]; |
| 712 |
$$rhash{valid} = $$data[2] . " view"; |
| 713 |
$$rhash{bound} = $$data[3] || ""; |
| 714 |
foreach my $k (keys %{$config{controlkeys}}) { |
| 715 |
if ($config{controlkeys}{$k} eq $this) { |
| 716 |
if ($$rhash{bound}) { |
| 717 |
$$rhash{bound} .= " Ctrl-$config{general}{user_key} $k"; |
| 718 |
} else { |
| 719 |
$$rhash{bound} = "Ctrl-$config{general}{user_key} $k"; |
| 720 |
}; |
| 721 |
}; |
| 722 |
}; |
| 723 |
foreach my $k (keys %{$config{metakeys}}) { |
| 724 |
if ($config{metakeys}{$k} eq $this) { |
| 725 |
if ($$rhash{bound}) { |
| 726 |
$$rhash{bound} .= " Alt-$config{general}{user_key} $k"; |
| 727 |
} else { |
| 728 |
$$rhash{bound} = "Alt-$config{general}{user_key} $k"; |
| 729 |
}; |
| 730 |
}; |
| 731 |
}; |
| 732 |
map { $widget{'keys_'.$_} -> configure(-state=>'normal') } (qw(bindit unbind key modifier)); |
| 733 |
|
| 734 |
} else { # category header |
| 735 |
$$rhash{category} = (split(/\./, $this))[0]; |
| 736 |
$$rhash{descr} = ""; |
| 737 |
$$rhash{function} = ""; |
| 738 |
$$rhash{valid} = ""; |
| 739 |
$$rhash{bound} = ""; |
| 740 |
map { $widget{'keys_'.$_} -> configure(-state=>'disabled') } (qw(bindit unbind key modifier)); |
| 741 |
}; |
| 742 |
}; |
| 743 |
|
| 744 |
|
| 745 |
sub keys_bind { |
| 746 |
my ($tree, $rhash) = @_; |
| 747 |
my $key = $widget{keys_key} -> get(); |
| 748 |
return if ($key =~ /^\s+$/); |
| 749 |
my $modifier = $$rhash{modifier}; |
| 750 |
my $mod = substr(uc($modifier), 0, 1); |
| 751 |
my $val = $tree -> infoAnchor; |
| 752 |
$config{$modifier.'keys'}{$key} = $val; |
| 753 |
$widget{keys_save} -> configure(-state=>'normal'); |
| 754 |
$$rhash{save} = 1; |
| 755 |
$tree -> KeyboardBrowse; |
| 756 |
$widget{keys_key} -> insert('end', $key); |
| 757 |
Echo("Bound $mod, - $key to \"$$rhash{descr}\""); |
| 758 |
}; |
| 759 |
|
| 760 |
|
| 761 |
sub keys_unbind { |
| 762 |
my ($tree, $rhash) = @_; |
| 763 |
my $key = $widget{keys_key} -> get(); |
| 764 |
return if ($key =~ /^\s*$/); |
| 765 |
my $modifier = $$rhash{modifier}; |
| 766 |
Error("$modifier-, $key is not bound to a function"), return unless exists $config{$modifier.'keys'}{$key}; |
| 767 |
delete $config{$modifier.'keys'}{$key}; |
| 768 |
$widget{keys_save} -> configure(-state=>'normal'); |
| 769 |
$$rhash{save} = 1; |
| 770 |
$tree -> KeyboardBrowse; |
| 771 |
$widget{keys_key} -> insert('end', $key); |
| 772 |
my $mod = ($modifier eq 'control') ? "C" : "A"; |
| 773 |
Echo("Removed binding to $mod-, $key"); |
| 774 |
}; |
| 775 |
|
| 776 |
sub keys_clear { |
| 777 |
foreach my $k (keys %{$config{controlkeys}}) { |
| 778 |
delete $config{controlkeys}{$k}; |
| 779 |
}; |
| 780 |
foreach my $k (keys %{$config{metakeys}}) { |
| 781 |
delete $config{metakeys}{$k}; |
| 782 |
}; |
| 783 |
Echo("Erase all bound keys for the current session."); |
| 784 |
}; |
| 785 |
|
| 786 |
|
| 787 |
sub keys_show_all { |
| 788 |
my $message = "The following key sequences have been bound:\n\n"; |
| 789 |
my $count = 0; |
| 790 |
foreach my $k (sort keys %{$config{controlkeys}}) { |
| 791 |
my @list = split(/\./, $config{controlkeys}{$k}); |
| 792 |
my $category; |
| 793 |
if ($#list == 1) { |
| 794 |
$category = join(' -> ', $list[0], $key_data{$list[0]}->{$list[1]}->[0]); |
| 795 |
} else { |
| 796 |
## the ugly thing at the end of the next line is to pull the |
| 797 |
## name of the sub-branch out of the %key_data data structure |
| 798 |
my $branch = (keys %{$key_data{$list[0]}->{$list[1]}})[0]; |
| 799 |
$category = join(' -> ', $list[0], |
| 800 |
(keys %{$key_data{$list[0]}->{$list[1]}})[0], |
| 801 |
$key_data{$list[0]}->{$list[1]}->{$branch}->{$list[2]}->[0] |
| 802 |
); |
| 803 |
|
| 804 |
}; |
| 805 |
$message .= " C $config{general}{user_key} - $k:\t$category\n"; |
| 806 |
++$count; |
| 807 |
}; |
| 808 |
foreach my $k (sort keys %{$config{metakeys}}) { |
| 809 |
my @list = split(/\./, $config{metakeys}{$k}); |
| 810 |
my $category; |
| 811 |
if ($#list == 1) { |
| 812 |
$category = join(' -> ', $list[0], $key_data{$list[0]}->{$list[1]}->[0]); |
| 813 |
} else { |
| 814 |
## the ugly thing at the end of the next line is to pull the |
| 815 |
## name of the sub-branch out of the %key_data data structure |
| 816 |
my $branch = (keys %{$key_data{$list[0]}->{$list[1]}})[0]; |
| 817 |
$category = join(' -> ', $list[0], |
| 818 |
(keys %{$key_data{$list[0]}->{$list[1]}})[0], |
| 819 |
$key_data{$list[0]}->{$list[1]}->{$branch}->{$list[2]}->[0] |
| 820 |
); |
| 821 |
|
| 822 |
}; |
| 823 |
$message .= " A $config{general}{user_key} - $k:\t$category\n"; |
| 824 |
++$count; |
| 825 |
}; |
| 826 |
($message = "There currently are no defined key bindings.") unless $count; |
| 827 |
my $dialog = |
| 828 |
$top -> Dialog(-bitmap => 'info', |
| 829 |
-text => $message, |
| 830 |
-title => 'Athena: key bindings', |
| 831 |
-buttons => ['OK'], |
| 832 |
-default_button => 'OK',); |
| 833 |
my $response = $dialog->Show(); |
| 834 |
}; |
| 835 |
|
| 836 |
|
| 837 |
sub keys_save { |
| 838 |
my $rhash = $_[0]; |
| 839 |
rename $personal_rcfile, $personal_rcfile.".bak"; |
| 840 |
my $config_ref = tied %config; |
| 841 |
$config_ref -> WriteConfig($personal_rcfile); |
| 842 |
$$rhash{save} = 0; |
| 843 |
$widget{keys_save} -> configure(-state=>'disabled'); |
| 844 |
Echo("Saved key bindings to \"$personal_rcfile\""); |
| 845 |
}; |
| 846 |
|
| 847 |
|
| 848 |
sub keys_dispatch { |
| 849 |
my $modifier = $_[1]; |
| 850 |
#print join(" ", @_), $/; |
| 851 |
my $mod = ($modifier eq 'control') ? "C" : "A"; |
| 852 |
my $who = $top->focusCurrent; |
| 853 |
$multikey = ""; |
| 854 |
Echonow("$mod-$config{general}{user_key} - <<waiting for end of key sequence...>>"); |
| 855 |
$echo -> focus(); |
| 856 |
$echo -> grab; |
| 857 |
$echo -> waitVariable(\$multikey); |
| 858 |
$echo -> grabRelease; |
| 859 |
$who -> focus; |
| 860 |
|
| 861 |
## my %nonalphanumerics = (period=>'.', |
| 862 |
## comma=>',', |
| 863 |
## bracketleft=>'[', |
| 864 |
## bracketright=>']', |
| 865 |
## semicolon=>';', |
| 866 |
## colon=>':', |
| 867 |
## equal=>'=', |
| 868 |
## plus=>'+', |
| 869 |
## minus=>'-', |
| 870 |
## slash=>'/', |
| 871 |
## apostrophe=>"\'", |
| 872 |
## backslash=>"\\", |
| 873 |
## grave=>'`', |
| 874 |
## space=>' ', |
| 875 |
## ); |
| 876 |
## ($multikey = $nonalphanumerics{$multikey}) if exists $nonalphanumerics{$multikey}; |
| 877 |
Error("$mod-, - $multikey is not bound to a command"), return unless (exists $config{$modifier.'keys'}{$multikey}); |
| 878 |
|
| 879 |
## need to translate $multikey for the non-alphanumerics |
| 880 |
my @id = split(/\./, $config{$modifier.'keys'}{$multikey}); |
| 881 |
my ($description, $function, $view); |
| 882 |
if ($#id == 1) { |
| 883 |
$description = $key_data{$id[0]}->{$id[1]}->[0]; |
| 884 |
$function = $key_data{$id[0]}->{$id[1]}->[1]; |
| 885 |
$view = $key_data{$id[0]}->{$id[1]}->[2]; |
| 886 |
} else { |
| 887 |
my $branch = (keys %{$key_data{$id[0]}->{$id[1]}})[0]; |
| 888 |
$description = $key_data{$id[0]}->{$id[1]}->{$branch}->{$id[2]}->[0]; |
| 889 |
$function = $key_data{$id[0]}->{$id[1]}->{$branch}->{$id[2]}->[1]; |
| 890 |
$view = $key_data{$id[0]}->{$id[1]}->{$branch}->{$id[2]}->[2]; |
| 891 |
}; |
| 892 |
|
| 893 |
## check to make sure that this function can be called at this time. |
| 894 |
CHECKVIEW: { |
| 895 |
($view eq "normal")and do { |
| 896 |
Echo("$mod-, - $multikey aborted! \"$description\" can only be called in the normal view"), |
| 897 |
return unless ($fat_showing eq "normal"); |
| 898 |
last CHECKVIEW; |
| 899 |
}; |
| 900 |
($view eq "calibration") and do { |
| 901 |
Echo("$mod-, - $multikey aborted! \"$description\" can only be called in the calibration view"), |
| 902 |
return unless ($fat_showing eq 'calibrate'); |
| 903 |
last CHECKVIEW; |
| 904 |
}; |
| 905 |
($view eq "deglitching") and do { |
| 906 |
Echo("$mod-, - $multikey aborted! \"$description\" can only be called in the deglitching view"), |
| 907 |
return unless ($fat_showing eq 'deglitch'); |
| 908 |
last CHECKVIEW; |
| 909 |
}; |
| 910 |
($view eq "truncation") and do { |
| 911 |
Echo("$mod-, - $multikey aborted! \"$description\" can only be called in the truncation view"), |
| 912 |
return unless ($fat_showing eq 'truncate'); |
| 913 |
last CHECKVIEW; |
| 914 |
}; |
| 915 |
($view eq "smoothing") and do { |
| 916 |
Echo("$mod-, - $multikey aborted! \"$description\" can only be called in the smoothing view"), |
| 917 |
return unless ($fat_showing eq 'smooth'); |
| 918 |
last CHECKVIEW; |
| 919 |
}; |
| 920 |
($view eq "alignment") and do { |
| 921 |
Echo("$mod-, - $multikey aborted! \"$description\" can only be called in the alignment view"), |
| 922 |
return unless ($fat_showing eq 'align'); |
| 923 |
last CHECKVIEW; |
| 924 |
}; |
| 925 |
($view eq "difference spectrum") and do { |
| 926 |
Echo("$mod-, - $multikey aborted! \"$description\" can only be called in the difference spectrum view"), |
| 927 |
return unless ($fat_showing eq 'diff'); |
| 928 |
last CHECKVIEW; |
| 929 |
}; |
| 930 |
($view eq "log ratio") and do { |
| 931 |
Echo("$mod-, - $multikey aborted! \"$description\" can only be called in the log ratio view"), |
| 932 |
return unless ($fat_showing eq 'lograt'); |
| 933 |
last CHECKVIEW; |
| 934 |
}; |
| 935 |
($view eq "peak fitting") and do { |
| 936 |
Echo("$mod-, - $multikey aborted! \"$description\" can only be called in the peak fitting view"), |
| 937 |
return unless ($fat_showing eq 'peakfit'); |
| 938 |
last CHECKVIEW; |
| 939 |
}; |
| 940 |
($view eq "preferences") and do { |
| 941 |
Echo("$mod-, - $multikey aborted! \"$description\" can only be called in the preferences view"), |
| 942 |
return unless ($fat_showing eq 'prefs'); |
| 943 |
last CHECKVIEW; |
| 944 |
}; |
| 945 |
}; |
| 946 |
Echonow("$mod-, - $multikey ( $description )"); |
| 947 |
&$function; |
| 948 |
}; |
| 949 |
|
| 950 |
|
| 951 |
## this is a generalized multiplexer for dispatching functions |
| 952 |
## according to a space obtained from the keyboard. for example, one |
| 953 |
## might bind "C-, m" to this function for prompting for a mergeing |
| 954 |
## space. then the key chain "C-, m e" would merge the marked data in |
| 955 |
## mu(E) |
| 956 |
sub dispatch_space { |
| 957 |
my $function = $_[0]; |
| 958 |
my $space; |
| 959 |
|
| 960 |
## for merging and difference spectra, spaces are e=energy, |
| 961 |
## n=normalize, k=chi(k), r=chi(R), q=chi(q) |
| 962 |
my $spaces = "enkrq"; |
| 963 |
## saving current group also has d=derivative |
| 964 |
($spaces = "endkrq") if ($function eq 'save'); |
| 965 |
## plotting, dispatch these to the appropriate plotting functions |
| 966 |
if ($function =~ /^plot/) { |
| 967 |
&keyboard_plot if ($function eq 'plot_current'); |
| 968 |
keyboard_plot_marked if ($function eq 'plot_marked'); |
| 969 |
return; |
| 970 |
}; |
| 971 |
|
| 972 |
## reuse the trick of giving the echo area the focus and capturing |
| 973 |
## the next keystroke |
| 974 |
my $who = $top->focusCurrent; |
| 975 |
$multikey = ""; |
| 976 |
Echonow(ucfirst($function) . " in which space? [$spaces]"); |
| 977 |
$echo -> focus(); |
| 978 |
$echo -> grab; |
| 979 |
$echo -> waitVariable(\$multikey); |
| 980 |
$echo -> grabRelease; |
| 981 |
$who -> focus; |
| 982 |
|
| 983 |
Error("\"$multikey\" is not a $function space!"), return unless ($multikey =~ /[$spaces]/); |
| 984 |
FUNCTION: { |
| 985 |
&merge_groups($multikey), last FUNCTION if ($function eq 'merge'); |
| 986 |
&difference($multikey), last FUNCTION if ($function eq 'difference'); |
| 987 |
&save_chi($multikey), last FUNCTION if ($function eq 'save'); |
| 988 |
}; |
| 989 |
}; |
| 990 |
|
| 991 |
## my $message = ""; |
| 992 |
## ($message = "Merge data in ...") if ($function eq 'merge'); |
| 993 |
## ($message = "Make difference spectra in ...") if ($function eq 'diff'); |
| 994 |
## my $hint ="\n\nm n k r & q are keyboard shortcuts for the buttons below"; |
| 995 |
## my $dialog = |
| 996 |
## $top -> Dialog(-bitmap => 'question', |
| 997 |
## -text => $message.$hint, |
| 998 |
## -title => 'Athena: choose space', |
| 999 |
## -buttons => [qw/mu(E) norm(E) chi(k) chi(R) chi(q) cancel/],); |
| 1000 |
## $dialog -> bind('<Key-m>' => |
| 1001 |
## sub{ (($dialog->children())[1]->children)[1] -> invoke }); |
| 1002 |
## $dialog -> bind('<Key-n>' => |
| 1003 |
## sub{ (($dialog->children())[1]->children)[2] -> invoke }); |
| 1004 |
## $dialog -> bind('<Key-k>' => |
| 1005 |
## sub{ (($dialog->children())[1]->children)[3] -> invoke }); |
| 1006 |
## $dialog -> bind('<Key-r>' => |
| 1007 |
## sub{ (($dialog->children())[1]->children)[4] -> invoke }); |
| 1008 |
## $dialog -> bind('<Key-q>' => |
| 1009 |
## sub{ (($dialog->children())[1]->children)[5] -> invoke }); |
| 1010 |
## my $response = $dialog->Show(); |
| 1011 |
## Echo("Aborted!"), return if ($response eq 'cancel'); |
| 1012 |
## ($space = 'm') if ($response eq 'mu(E)'); |
| 1013 |
## ($space = 'n') if ($response eq 'norm(E)'); |
| 1014 |
## ($space = 'k') if ($response eq 'chi(k)'); |
| 1015 |
## ($space = 'r') if ($response eq 'chi(R)'); |
| 1016 |
## ($space = 'q') if ($response eq 'chi(q)'); |
| 1017 |
## $message =~ s/\.\.\./$response/; |
| 1018 |
## Echonow($message); |
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
## END OF KEY BINDINGS SUBSECTION |
| 1023 |
########################################################################################## |