Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/services/console/lib/purk/scripts/keys.py
blob: e26572cc2ea74ae9075523b6ff7e585d80872804 (plain)
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
import windows
import widgets
import irc

shortcuts = {
    '^b': '\x02',
    '^u': '\x1F',
    '^r': '\x16',
    '^k': '\x03',
    '^l': '\x04',
    '^o': '\x0F',
    }

def onKeyPress(e):
    if e.key in shortcuts:
        e.window.input.insert(shortcuts[e.key])

    elif e.key == '!c':
        e.window.output.copy()

    elif e.key == 'Page_Up':
        e.window.output.y = e.window.output.y - e.window.output.height / 2
    
    elif e.key == 'Page_Down':
        e.window.output.y = e.window.output.y + e.window.output.height / 2

    elif e.key == '^Home':
        e.window.output.y = 0
    
    elif e.key == '^End':
        e.window.output.y = e.window.output.ymax

    elif e.key in ('^Page_Up', '^Page_Down'):
        winlist = list(windows.manager)
        index = winlist.index(e.window) + ((e.key == '^Page_Down') and 1 or -1)
        if 0 <= index < len(winlist):
            winlist[index].activate()

    elif e.key == '!a':
        winlist = list(windows.manager)
        winlist = winlist[winlist.index(e.window):]+winlist
        w = [w for w in winlist if widgets.HILIT in w.activity]
        
        if not w:
            w = [w for w in winlist if widgets.TEXT in w.activity]
        
        if w:
            windows.manager.set_active(w[0])

    # tabbed browsing
    elif e.key == '^t':
        windows.new(windows.StatusWindow, irc.Network(), 'status').activate()

    elif e.key == '^w':
        windows.manager.get_active().close()
        
    elif e.key == '^f':
        window = windows.manager.get_active()
        
        find = widgets.FindBox(window)
        
        window.pack_start(find, expand=False)
        
        find.textbox.grab_focus()
    
    elif len(e.key) == 2 and e.key.startswith('!') and e.key[1].isdigit():
        n = int(e.key[1])
        if n and n <= len(core.manager):
             list(core.manager)[n-1].activate()
        #else e.key == "!0"