| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,6 +65,9 @@ | |||
| 65 | 65 | # This for config | |
| 66 | 66 | from bpython.config import Struct, loadini, migrate_rc | |
| 67 | 67 | ||
| 68 | + # This for keys | ||
| 69 | + from bpython.keys import key_dispatch | ||
| 70 | + | ||
| 68 | 71 | from bpython import __version__ | |
| 69 | 72 | ||
| 70 | 73 | def log(x): | |
@@ -1323,11 +1326,11 @@ def p_key(self): | |||
| 1323 | 1326 | else: | |
| 1324 | 1327 | return '' | |
| 1325 | 1328 | ||
| 1326 | - elif self.c == 'KEY_F(2)': | ||
| 1329 | + elif self.c in key_dispatch[OPTS.save_key]: | ||
| 1327 | 1330 | self.write2file() | |
| 1328 | 1331 | return '' | |
| 1329 | 1332 | ||
| 1330 | - elif self.c == 'KEY_F(8)': | ||
| 1333 | + elif self.c == key_dispatch[OPTS.pastebin_key]: | ||
| 1331 | 1334 | self.pastebin() | |
| 1332 | 1335 | return '' | |
| 1333 | 1336 | ||
@@ -1618,7 +1621,6 @@ def get_key(self): | |||
| 1618 | 1621 | if self.idle: | |
| 1619 | 1622 | self.idle(self) | |
| 1620 | 1623 | ||
| 1621 | - | ||
| 1622 | 1624 | class Statusbar(object): | |
| 1623 | 1625 | """This class provides the status bar at the bottom of the screen. | |
| 1624 | 1626 | It has message() and prompt() methods for user interactivity, as | |
@@ -1720,7 +1722,7 @@ def bs(s): | |||
| 1720 | 1722 | o = bs(o) | |
| 1721 | 1723 | continue | |
| 1722 | 1724 | ||
| 1723 | - if not c or c > 127: | ||
| 1725 | + if not c or c < 0 or c > 127: | ||
| 1724 | 1726 | continue | |
| 1725 | 1727 | c = chr(c) | |
| 1726 | 1728 | ||
@@ -1783,7 +1785,7 @@ def init_wins(scr, cols): | |||
| 1783 | 1785 | # This should show to be configured keys from bpython.ini | |
| 1784 | 1786 | # | |
| 1785 | 1787 | statusbar = Statusbar(scr, main_win, | |
| 1786 | - ".:: <C-d> Exit <C-r> Rewind <F2> Save <F8> Pastebin ::.", | ||
| 1788 | + ".:: <C-d> Exit <C-r> Rewind <%s> Save <%s> Pastebin ::." % (OPTS.save_key, OPTS.pastebin_key), | ||
| 1787 | 1789 | get_colpair('main')) | |
| 1788 | 1790 | ||
| 1789 | 1791 | return main_win, statusbar | |
@@ -1903,6 +1905,8 @@ def main_curses(scr): | |||
| 1903 | 1905 | ||
| 1904 | 1906 | main_win, statusbar = init_wins(scr, cols) | |
| 1905 | 1907 | ||
| 1908 | + curses.raw(True) | ||
| 1909 | + | ||
| 1906 | 1910 | interpreter = Interpreter() | |
| 1907 | 1911 | ||
| 1908 | 1912 | repl = Repl(main_win, interpreter, statusbar, idle) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,6 +41,8 @@ def loadini(struct, configfile): | |||
| 41 | 41 | struct.hist_file = config.safeget('general', 'hist_file', '~/.pythonhist') | |
| 42 | 42 | struct.hist_length = config.safeget('general', 'hist_length', 100) | |
| 43 | 43 | struct.flush_output = config.safeget('general', 'flush_output', True) | |
| 44 | + struct.pastebin_key = config.safeget('keyboard', 'pastebin', 'C-p') | ||
| 45 | + struct.save_key = config.safeget('keyboard', 'save', 'C-s') | ||
| 44 | 46 | color_scheme_name = config.safeget('general', 'color_scheme', 'default') | |
| 45 | 47 | ||
| 46 | 48 | if color_scheme_name == 'default': | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,43 @@ | |||
| 1 | + #!/usr/bin/env python | ||
| 2 | + # | ||
| 3 | + # The MIT License | ||
| 4 | + # | ||
| 5 | + # Copyright (c) 2008 Simon de Vlieger | ||
| 6 | + # | ||
| 7 | + # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 8 | + # of this software and associated documentation files (the "Software"), to deal | ||
| 9 | + # in the Software without restriction, including without limitation the rights | ||
| 10 | + # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 11 | + # copies of the Software, and to permit persons to whom the Software is | ||
| 12 | + # furnished to do so, subject to the following conditions: | ||
| 13 | + # | ||
| 14 | + # The above copyright notice and this permission notice shall be included in | ||
| 15 | + # all copies or substantial portions of the Software. | ||
| 16 | + # | ||
| 17 | + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 18 | + # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 19 | + # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 20 | + # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 21 | + # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 22 | + # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 23 | + # THE SOFTWARE. | ||
| 24 | + # | ||
| 25 | + | ||
| 26 | + import string | ||
| 27 | + | ||
| 28 | + key_dispatch = {} | ||
| 29 | + | ||
| 30 | + # fill dispatch with letters | ||
| 31 | + for c in string.lowercase: | ||
| 32 | + key_dispatch['C-%s' % c] = (chr(string.lowercase.index(c)+1), '^%s' % c.upper()) | ||
| 33 | + | ||
| 34 | + # fill dispatch with cool characters | ||
| 35 | + key_dispatch['C-['] = (chr(27), '^[') | ||
| 36 | + key_dispatch['C-\\'] = (chr(28), '^\\') | ||
| 37 | + key_dispatch['C-]'] = (chr(29), '^]') | ||
| 38 | + key_dispatch['C-^'] = (chr(30), '^^') | ||
| 39 | + key_dispatch['C-_'] = (chr(31), '^_') | ||
| 40 | + | ||
| 41 | + # fill dispatch with function keys | ||
| 42 | + for x in xrange(1,13): | ||
| 43 | + key_dispatch['F%s' % str(x)] = 'KEY_F(%s)' % str(x) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,8 @@ tab_length = 4 | |||
| 30 | 30 | # Color schemes should be put in ~/.bpython/ | |
| 31 | 31 | # e.g. to use the theme ~/.bpython/foo.theme set color_scheme = foo | |
| 32 | 32 | # Leave blank or set to "default" to use the default theme | |
| 33 | - color_scheme = dark | ||
| 34 | - | ||
| 33 | + color_scheme = default | ||
| 35 | 34 | ||
| 35 | + [keyboard] | ||
| 36 | + pastebin = F8 | ||
| 37 | + save = C-s | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments