]>
git.r.bdr.sh - rbdr/dotfiles/blob - weechat/python/upside_down.py
e07a7bf561910b79913a65bfe7340d7c9ccfc423
1 # -*- coding: utf-8 -*-
3 # Copyright (c) 2009 by xt <xt@bash.no>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # USAGE: Bind a key to command /flip . Then write some text at input line
21 # press your key to transform it to upside down.
24 # (this script requires WeeChat 0.3.0 or newer)
28 # version 0.3: steal more chars from m4v
29 # 2010-01-06, xt <xt@bash.no>
30 # version 0.2: fix idiotic programming
31 # 2009-11-12, xt <xt@bash.no>
32 # version 0.1: initial release
37 SCRIPT_NAME
= "upside_down"
38 SCRIPT_AUTHOR
= "xt <xt@bash.no>"
39 SCRIPT_VERSION
= "0.3"
40 SCRIPT_LICENSE
= "GPL3"
41 SCRIPT_DESC
= "Replaces text you write with upside down text"
47 u
'A' : u
'\N{FOR ALL}',
48 u
'B' : u
'\N{GREEK SMALL LETTER XI}',
49 u
'C' : u
'\N{ROMAN NUMERAL REVERSED ONE HUNDRED}',
50 u
'D' : u
'\N{LEFT HALF BLACK CIRCLE}',
51 u
'E' : u
'\N{LATIN CAPITAL LETTER REVERSED E}',
52 u
'F' : u
'\N{TURNED CAPITAL F}',
53 u
'G' : u
'\N{TURNED SANS-SERIF CAPITAL G}',
54 u
'J' : u
'\N{LATIN SMALL LETTER LONG S}',
55 u
'K' : u
'\N{RIGHT NORMAL FACTOR SEMIDIRECT PRODUCT}',
58 u
'N' : u
'\N{LATIN LETTER SMALL CAPITAL REVERSED N}',
59 u
'P' : u
'\N{CYRILLIC CAPITAL LETTER KOMI DE}',
60 u
'Q' : u
'\N{GREEK CAPITAL LETTER OMICRON WITH TONOS}',
61 u
'R' : u
'\N{LATIN LETTER SMALL CAPITAL TURNED R}',
62 u
'T' : u
'\N{UP TACK}',
63 u
'U' : u
'\N{INTERSECTION}',
65 u
'Y' : u
'\N{TURNED SANS-SERIF CAPITAL Y}',
100 '\u2234' : u
'\u2235',
105 if w
.register(SCRIPT_NAME
, SCRIPT_AUTHOR
, SCRIPT_VERSION
, SCRIPT_LICENSE
,
106 SCRIPT_DESC
, "", ""):
107 for option
, default_value
in settings
.iteritems():
108 if not w
.config_is_set_plugin(option
):
109 w
.config_set_plugin(option
, default_value
)
110 w
.hook_command("flip",
113 "text: text to be flipped\n"
115 "", "flip_cmd_cb", "")
118 def flip_cmd_cb(data
, buffer, args
):
119 ''' Command /flip '''
120 translate_input
= args
121 if not translate_input
:
122 translate_input
= w
.buffer_get_string(w
.current_buffer(), "input")
124 for char
in translate_input
:
125 if char
in replacements
:
126 char
= replacements
[char
]
128 outstring
= outstring
.encode('UTF-8')
129 w
.buffer_set(w
.current_buffer(), 'input', outstring
)
130 return w
.WEECHAT_RC_OK