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