1 | # ---------------------------------------------------------------------- |
---|
2 | # WIDGET: diffview - view differences between two strings |
---|
3 | # |
---|
4 | # These are the class bindings for the Diffview widget. The widget |
---|
5 | # itself is implemented in C code, but this file customizes the |
---|
6 | # behavior of the widget by adding default bindings. It is loaded |
---|
7 | # when the widget initializes itself. |
---|
8 | # ====================================================================== |
---|
9 | # AUTHOR: Michael McLennan, Purdue University |
---|
10 | # Copyright (c) 2004-2011 Purdue Research Foundation |
---|
11 | # |
---|
12 | # See the file "license.terms" for information on usage and |
---|
13 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
14 | # ====================================================================== |
---|
15 | namespace eval Rappture { # forward declaration } |
---|
16 | |
---|
17 | # ---------------------------------------------------------------------- |
---|
18 | # Code for "usual" itk options |
---|
19 | # ---------------------------------------------------------------------- |
---|
20 | if {[catch {package require Itk}] == 0} { |
---|
21 | itk::usual Diffview { |
---|
22 | keep -background -foreground -cursor |
---|
23 | keep -addedbackground -addedforeground |
---|
24 | keep -deletedbackground -deletedforeground -overstrike |
---|
25 | keep -changedbackground -changedforeground |
---|
26 | keep -highlightcolor -highlightthickness |
---|
27 | rename -highlightbackground -background background Background |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | |
---|
32 | # ---------------------------------------------------------------------- |
---|
33 | # Key navigation |
---|
34 | # ---------------------------------------------------------------------- |
---|
35 | bind Diffview <Key-Up> { |
---|
36 | %W yview scroll -1 units |
---|
37 | } |
---|
38 | bind Diffview <Control-Key-Up> { |
---|
39 | %W yview scroll -1 pages |
---|
40 | } |
---|
41 | bind Diffview <Key-Prior> { |
---|
42 | %W yview scroll -1 pages |
---|
43 | } |
---|
44 | |
---|
45 | bind Diffview <Key-Down> { |
---|
46 | %W yview scroll 1 units |
---|
47 | } |
---|
48 | bind Diffview <Control-Key-Down> { |
---|
49 | %W yview scroll 1 pages |
---|
50 | } |
---|
51 | bind Diffview <Key-Next> { |
---|
52 | %W yview scroll 1 pages |
---|
53 | } |
---|
54 | |
---|
55 | bind Diffview <Key-Left> { |
---|
56 | %W xview scroll -1 units |
---|
57 | } |
---|
58 | bind Diffview <Control-Key-Left> { |
---|
59 | %W xview scroll -1 pages |
---|
60 | } |
---|
61 | |
---|
62 | bind Diffview <Key-Right> { |
---|
63 | %W xview scroll 1 units |
---|
64 | } |
---|
65 | bind Diffview <Control-Key-Right> { |
---|
66 | %W xview scroll 1 pages |
---|
67 | } |
---|
68 | |
---|
69 | # ---------------------------------------------------------------------- |
---|
70 | # Click/drag for fast scanning |
---|
71 | # ---------------------------------------------------------------------- |
---|
72 | bind Diffview <ButtonPress-2> { |
---|
73 | %W scan mark %x %y |
---|
74 | } |
---|
75 | bind Diffview <B2-Motion> { |
---|
76 | %W scan dragto %x %y |
---|
77 | } |
---|
78 | |
---|
79 | # ---------------------------------------------------------------------- |
---|
80 | # MouseWheel bindings |
---|
81 | # ---------------------------------------------------------------------- |
---|
82 | switch -- [tk windowingsystem] { |
---|
83 | classic - aqua { |
---|
84 | bind Diffview <MouseWheel> { |
---|
85 | %W yview scroll [expr {-(%D)}] units |
---|
86 | } |
---|
87 | bind Diffview <Option-MouseWheel> { |
---|
88 | %W yview scroll [expr {-10*(%D)}] units |
---|
89 | } |
---|
90 | bind Diffview <Shift-MouseWheel> { |
---|
91 | %W xview scroll [expr {-(%D)}] units |
---|
92 | } |
---|
93 | bind Diffview <Shift-Option-MouseWheel> { |
---|
94 | %W xview scroll [expr {-10*(%D)}] units |
---|
95 | } |
---|
96 | } |
---|
97 | x11 { |
---|
98 | # support for mousewheels on Linux comes from buttons 4/5 |
---|
99 | bind Diffview <4> { |
---|
100 | if {!$tk_strictMotif} { |
---|
101 | %W yview scroll -5 units |
---|
102 | } |
---|
103 | } |
---|
104 | bind Diffview <5> { |
---|
105 | if {!$tk_strictMotif} { |
---|
106 | %W yview scroll 5 units |
---|
107 | } |
---|
108 | } |
---|
109 | |
---|
110 | # in case anyone generates a <MouseWheel> event |
---|
111 | bind Diffview <MouseWheel> { |
---|
112 | %W yview scroll [expr {-(%D/120)*4}] units |
---|
113 | } |
---|
114 | } |
---|
115 | default { |
---|
116 | bind Diffview <MouseWheel> { |
---|
117 | %W yview scroll [expr {-(%D/120)*4}] units |
---|
118 | } |
---|
119 | } |
---|
120 | } |
---|