source: branches/1.3/gui/scripts/diffview.tcl @ 4447

Last change on this file since 4447 was 3330, checked in by gah, 12 years ago

merge (by hand) with Rappture1.2 branch

File size: 3.7 KB
Line 
1# -*- mode: tcl; indent-tabs-mode: nil -*-
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
11#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
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# ======================================================================
16namespace eval Rappture { # forward declaration }
17
18# ----------------------------------------------------------------------
19# Code for "usual" itk options
20# ----------------------------------------------------------------------
21if {[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# ----------------------------------------------------------------------
34# Key navigation
35# ----------------------------------------------------------------------
36bind Diffview <Key-Up> {
37    %W yview scroll -1 units
38}
39bind Diffview <Control-Key-Up> {
40    %W yview scroll -1 pages
41}
42bind Diffview <Key-Prior> {
43    %W yview scroll -1 pages
44}
45
46bind Diffview <Key-Down> {
47    %W yview scroll 1 units
48}
49bind Diffview <Control-Key-Down> {
50    %W yview scroll 1 pages
51}
52bind Diffview <Key-Next> {
53    %W yview scroll 1 pages
54}
55
56bind Diffview <Key-Left> {
57    %W xview scroll -1 units
58}
59bind Diffview <Control-Key-Left> {
60    %W xview scroll -1 pages
61}
62
63bind Diffview <Key-Right> {
64    %W xview scroll 1 units
65}
66bind Diffview <Control-Key-Right> {
67    %W xview scroll 1 pages
68}
69
70# ----------------------------------------------------------------------
71# Click/drag for fast scanning
72# ----------------------------------------------------------------------
73bind Diffview <ButtonPress-2> {
74    %W scan mark %x %y
75}
76bind Diffview <B2-Motion> {
77    %W scan dragto %x %y
78}
79
80# ----------------------------------------------------------------------
81# MouseWheel bindings
82# ----------------------------------------------------------------------
83switch -- [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}
Note: See TracBrowser for help on using the repository browser.