Tkabber plugins

Check-in [5c5b4ca07c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Reformatted the code. Bind all events to TEntry also.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5c5b4ca07c385872337c4460126a10ce361b5e23
User & Date: sgolovan 2015-05-09 18:01:09.333
Context
2015-05-09
18:14
Reformatted the code. check-in: 195cf49721 user: sgolovan tags: trunk
18:01
Reformatted the code. Bind all events to TEntry also. check-in: 5c5b4ca07c user: sgolovan tags: trunk
17:53
Adapted the Traffic accounting plugin to the Ttk based interface. check-in: 214c43ba60 user: sgolovan tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to ChangeLog.
1




2
3
4
5
6
7
8
2015-05-09  Sergei Golovan  <sgolovan@nes.ru>





	* traffic/traffic.tcl: Adapted the Traffic accounting plugin to the
	  Ttk based interface.

	* traffic/msgs/de.msg, traffic/msgs/es.msg, traffic/msgs/pl.msg,
	  traffic/msgs/ru.msg, traffic/msgs/uk.msg, traffic/traffic.tcl:
	  Reformatted the code.

>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2015-05-09  Sergei Golovan  <sgolovan@nes.ru>

	* unixkeys/INSTALL, unixkeys/README, unixkeys/TODO,
	  unixkeys/msgs/ru.msg, unixkeys/unixkeys.tcl: Reformatted the code.
	  Bind all events to TEntry also.

	* traffic/traffic.tcl: Adapted the Traffic accounting plugin to the
	  Ttk based interface.

	* traffic/msgs/de.msg, traffic/msgs/es.msg, traffic/msgs/pl.msg,
	  traffic/msgs/ru.msg, traffic/msgs/uk.msg, traffic/traffic.tcl:
	  Reformatted the code.
Changes to unixkeys/INSTALL.
1
2
3
4
5
6
7
8
9
As usually, copy this directory under the ~/.tkabber/plugins directory
so that you get a hierarchy like this:
  ~/.tkabber/plugins
  ~/.tkabber/plugins/unixkeys/
  ~/.tkabber/plugins/unixkeys/unixkeys.tcl

Restart Tkabber, to get the plugin loaded.
Consult the README file for the details about using this plugin.

|







<
1
2
3
4
5
6
7
8

As usual, copy this directory under the ~/.tkabber/plugins directory
so that you get a hierarchy like this:
  ~/.tkabber/plugins
  ~/.tkabber/plugins/unixkeys/
  ~/.tkabber/plugins/unixkeys/unixkeys.tcl

Restart Tkabber, to get the plugin loaded.
Consult the README file for the details about using this plugin.

Changes to unixkeys/README.
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
plugin adds.

If you prefer M-e to be used for cursor motion as provided by
this plugin, add something like construct in the postload
section of your config.tcl:

foreach b [event info <<EmoticonsMenu>>] {
	event delete <<EmoticonsMenu>> $b
}

This will unbind *all* bindings from the Tk virtual event that
shows the emoticons palette, effectivly disabling its usage.
If you want to access this palette via some other gesture, add
it like this, for instance:








|







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
plugin adds.

If you prefer M-e to be used for cursor motion as provided by
this plugin, add something like construct in the postload
section of your config.tcl:

foreach b [event info <<EmoticonsMenu>>] {
    event delete <<EmoticonsMenu>> $b
}

This will unbind *all* bindings from the Tk virtual event that
shows the emoticons palette, effectivly disabling its usage.
If you want to access this palette via some other gesture, add
it like this, for instance:

124
125
126
127
128
129
130
131
sentence", not "end of text in the buffer" as this plugin does
for multiline entry widgets.

The plugin requires special tweaking to get M-e working, as
described above.


# vim:tw=64:noet







|
124
125
126
127
128
129
130
131
sentence", not "end of text in the buffer" as this plugin does
for multiline entry widgets.

The plugin requires special tweaking to get M-e working, as
described above.


# vim:tw=64:et
Changes to unixkeys/TODO.
1
2
3
* M-a, M-e in text widgets should move by sentences.

# vim:tw=64:noet


|
1
2
3
* M-a, M-e in text widgets should move by sentences.

# vim:tw=64:et
Changes to unixkeys/msgs/ru.msg.
1
2
3
4
5
6
7

8
9
10
11
12


# ru.msg --
#
#	Russian messages for the Tkabber Unixkeys plugin.
#
# Author: Sergei Golovan <sgolovan@nes.ru>

::msgcat::mcset ru "Whether the Unixkeys plugin is loaded." "Загружено ли расширение Unixkeys."

::msgcat::mcset ru "This plugin makes the widgets providing textual input\
		support certain combinations of keystrokes\
		familiar to the users of Readline and Emacs." \
	"Это расширение добавляет в поля текстового ввода поддержку комбинаций\
		клавиш, знакомых пользователям Readline и Emacs."




|



|
>

|
|
|
|
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# ru.msg --
#
#       Russian messages for the Tkabber Unixkeys plugin.
#
# Author: Sergei Golovan <sgolovan@nes.ru>

::msgcat::mcset ru "Whether the Unixkeys plugin is loaded." \
        "Загружено ли расширение Unixkeys."
::msgcat::mcset ru "This plugin makes the widgets providing textual input\
        support certain combinations of keystrokes\
        familiar to the users of Readline and Emacs." \
        "Это расширение добавляет в поля текстового ввода поддержку комбинаций\
        клавиш, знакомых пользователям Readline и Emacs."

# vim:ft=tcl:ts=8:sw=4:sts=4:et
Changes to unixkeys/unixkeys.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

53

54
55
56
57
58

59

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# unixkeys.tcl --
#
#	"Unixkeys" -- plugin for Tkabber.
#	Provides keybindings in Tk Text widgets which are familiar
#	to Unix users: they resemble "canonical" bindings found in
#	readline and Emacs.
#
# Author: Konstantin Khomoutov <flatworm@users.sourceforge.net>
#
# See license.terms for details on usage and distribution.
# See INSTALL for installation procedure.
# See README for usage guidelines.

package require msgcat

namespace eval unixkeys {
    ::msgcat::mcload [file join [file dirname [info script]] msgs]

    if {![::plugins::is_registered unixkeys]} {
        ::plugins::register unixkeys \
            -namespace [namespace current] \
            -source [info script] \
            -description [::msgcat::mc \
		"Whether the Unixkeys plugin is loaded."]\n[::msgcat::mc \
		"This plugin makes the widgets providing textual input\
		    support certain combinations of keystrokes\
		    familiar to the users of Readline and Emacs."] \
            -loadcommand [namespace code load] \
            -unloadcommand [namespace code unload]
        return
    }
}

proc unixkeys::load {} {
    foreach mod {Alt Meta} {
	Bind Text <$mod-Key-a> [bind Text <Control-Key-Home>]
	Bind Text <$mod-Key-e> [bind Text <Control-Key-End>]
	BindEntry <$mod-Key-a> [bind Entry <Key-Home>]
	BindEntry <$mod-Key-e> [bind Entry <Key-End>]
    }

    foreach mod {Alt Meta} {
	Bind Text <$mod-Key-b> [bind Text <Control-Key-Left>]
	Bind Text <$mod-Key-f> [bind Text <Control-Key-Right>]
    }
    BindEntry <Alt-Key-b> [bind Entry <Meta-Key-b>]
    BindEntry <Alt-Key-f> [bind Entry <Meta-Key-f>]

    Bind Text  <Control-Key-u> { %W delete {insert linestart} insert}
    BindEntry <Control-Key-u>  { %W delete 0 insert }

    foreach {mod key} {Alt BackSpace Control w} {

	Bind Text  <$mod-Key-$key> { %W delete [tk::TextPrevPos %W insert tcl_startOfPreviousWord] insert }

	BindEntry <$mod-Key-$key>  { %W delete [tk::EntryPreviousWord %W insert] insert }
    }

    foreach key {d Delete} {
	foreach mod {Alt Meta} {

	    Bind Text  <$mod-Key-$key> { %W delete insert [::tk::TextNextPos %W insert tcl_endOfWord] }

	    BindEntry <$mod-Key-$key>  { %W delete insert [::tk::EntryNextWord %W insert] }
	}
    }

    if {[string equal $::tcl_platform(os) windows]} {
	AddEvent <<Undo>> <Control-Key-underscore>
    }
    AddEvent <<Undo>> <Control-Key-x><Control-Key-u>

    Bind Text <Control-slash>     { %W tag add sel 1.0 end }
    Bind Text <Control-backslash> { %W tag remove sel 1.0 end }
    Bind Text <Control-Key-x><h>  { %W tag add sel 1.0 end }
    BindEntry <Control-Key-x><h>  [bind Entry <Control-slash>]
}

proc unixkeys::Bind {target event script} {
    set existing [bind $target $event]
    bind $target $event $script

    variable bindtable
    lappend bindtable $target $event $script $existing
}

proc unixkeys::BindEntry {event script} {
    Bind Entry   $event $script

    Bind BwEntry $event $script
}

proc unixkeys::AddEvent {name event} {
    event add $name $event

    variable evtable
    lappend evtable $name $event
}

proc unixkeys::unload {} {
    variable bindtable
    foreach {target event installed original} $bindtable {
	set existing [bind $target $event]
	if {[string equal $existing $installed]} {
	    bind $target $event $original
	}
    }
    unset bindtable

    variable evtable
    foreach {name event} $evtable {
	event delete $name $event
    }
    unset evtable
}

# vim:ts=8:sw=4:sts=4:noet


|
|
|
|

















|
|
|
|








|
|
|
|



|
|




|
|


>
|
>
|



|
>
|
>
|
|



|



|
|
|













>













|
|
|
|





|




|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# unixkeys.tcl --
#
#       "Unixkeys" -- plugin for Tkabber.
#       Provides keybindings in Tk Text widgets which are familiar
#       to Unix users: they resemble "canonical" bindings found in
#       readline and Emacs.
#
# Author: Konstantin Khomoutov <flatworm@users.sourceforge.net>
#
# See license.terms for details on usage and distribution.
# See INSTALL for installation procedure.
# See README for usage guidelines.

package require msgcat

namespace eval unixkeys {
    ::msgcat::mcload [file join [file dirname [info script]] msgs]

    if {![::plugins::is_registered unixkeys]} {
        ::plugins::register unixkeys \
            -namespace [namespace current] \
            -source [info script] \
            -description [::msgcat::mc \
                "Whether the Unixkeys plugin is loaded."]\n[::msgcat::mc \
                "This plugin makes the widgets providing textual input\
                    support certain combinations of keystrokes\
                    familiar to the users of Readline and Emacs."] \
            -loadcommand [namespace code load] \
            -unloadcommand [namespace code unload]
        return
    }
}

proc unixkeys::load {} {
    foreach mod {Alt Meta} {
        Bind Text <$mod-Key-a> [bind Text <Control-Key-Home>]
        Bind Text <$mod-Key-e> [bind Text <Control-Key-End>]
        BindEntry <$mod-Key-a> [bind Entry <Key-Home>]
        BindEntry <$mod-Key-e> [bind Entry <Key-End>]
    }

    foreach mod {Alt Meta} {
        Bind Text <$mod-Key-b> [bind Text <Control-Key-Left>]
        Bind Text <$mod-Key-f> [bind Text <Control-Key-Right>]
    }
    BindEntry <Alt-Key-b> [bind Entry <Meta-Key-b>]
    BindEntry <Alt-Key-f> [bind Entry <Meta-Key-f>]

    Bind Text <Control-Key-u> {%W delete {insert linestart} insert}
    BindEntry <Control-Key-u> {%W delete 0 insert}

    foreach {mod key} {Alt BackSpace Control w} {
        Bind Text <$mod-Key-$key> \
         {%W delete [tk::TextPrevPos %W insert tcl_startOfPreviousWord] insert}
        BindEntry <$mod-Key-$key> \
            {%W delete [tk::EntryPreviousWord %W insert] insert}
    }

    foreach key {d Delete} {
        foreach mod {Alt Meta} {
            Bind Text <$mod-Key-$key> \
                {%W delete insert [::tk::TextNextPos %W insert tcl_endOfWord]}
            BindEntry <$mod-Key-$key> \
                {%W delete insert [::tk::EntryNextWord %W insert]}
        }
    }

    if {[string equal $::tcl_platform(os) windows]} {
        AddEvent <<Undo>> <Control-Key-underscore>
    }
    AddEvent <<Undo>> <Control-Key-x><Control-Key-u>

    Bind Text <Control-slash>     {%W tag add sel 1.0 end}
    Bind Text <Control-backslash> {%W tag remove sel 1.0 end}
    Bind Text <Control-Key-x><h>  {%W tag add sel 1.0 end}
    BindEntry <Control-Key-x><h>  [bind Entry <Control-slash>]
}

proc unixkeys::Bind {target event script} {
    set existing [bind $target $event]
    bind $target $event $script

    variable bindtable
    lappend bindtable $target $event $script $existing
}

proc unixkeys::BindEntry {event script} {
    Bind Entry   $event $script
    Bind TEntry  $event $script
    Bind BwEntry $event $script
}

proc unixkeys::AddEvent {name event} {
    event add $name $event

    variable evtable
    lappend evtable $name $event
}

proc unixkeys::unload {} {
    variable bindtable
    foreach {target event installed original} $bindtable {
        set existing [bind $target $event]
        if {[string equal $existing $installed]} {
            bind $target $event $original
        }
    }
    unset bindtable

    variable evtable
    foreach {name event} $evtable {
        event delete $name $event
    }
    unset evtable
}

# vim:ts=8:sw=4:sts=4:et