当前位置: 首页>>代码示例>>Python>>正文


Python curses.ascii方法代码示例

本文整理汇总了Python中curses.ascii方法的典型用法代码示例。如果您正苦于以下问题:Python curses.ascii方法的具体用法?Python curses.ascii怎么用?Python curses.ascii使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在curses的用法示例。


在下文中一共展示了curses.ascii方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _search_validator

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def _search_validator(self, ch):
        """Fix Enter and backspace for textbox.

        Used as an aux function for the textpad.edit method

        """
        if ch == curses.ascii.NL:  # Enter
            return curses.ascii.BEL
        elif ch == 127:  # Backspace
            self.search_str = self.textpad.gather().strip().lower()[:-1]
            return 8
        else:
            if 0 < ch < 256:
                c = chr(ch)
                if c in string.printable:
                    res = self.textpad.gather().strip().lower()
                    self.search_str = res + chr(ch)
                    self.search_results(look_in_cur=True)
                    self.display()
            return ch 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:22,代码来源:tabview.py

示例2: _insert_printable_char

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def _insert_printable_char(self, ch):
        self._update_max_yx()
        (y, x) = self.win.getyx()
        backyx = None
        while y < self.maxy or x < self.maxx:
            if self.insert_mode:
                oldch = self.win.inch()
            # The try-catch ignores the error we trigger from some curses
            # versions by trying to write into the lowest-rightmost spot
            # in the window.
            try:
                self.win.addch(ch)
            except curses.error:
                pass
            if not self.insert_mode or not curses.ascii.isprint(oldch):
                break
            ch = oldch
            (y, x) = self.win.getyx()
            # Remember where to put the cursor back since we are in insert_mode
            if backyx is None:
                backyx = y, x

        if backyx is not None:
            self.win.move(*backyx) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:textpad.py

示例3: gather

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def gather(self):
        "Collect and return the contents of the window."
        result = ""
        self._update_max_yx()
        for y in range(self.maxy+1):
            self.win.move(y, 0)
            stop = self._end_of_line(y)
            if stop == 0 and self.stripspaces:
                continue
            for x in range(self.maxx+1):
                if self.stripspaces and x > stop:
                    break
                result = result + chr(curses.ascii.ascii(self.win.inch(y, x)))
            if self.maxy > 0:
                result = result + "\n"
        return result 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:textpad.py

示例4: _insert_printable_char

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def _insert_printable_char(self, ch):
        (y, x) = self.win.getyx()
        if y < self.maxy or x < self.maxx:
            if self.insert_mode:
                oldch = self.win.inch()
            # The try-catch ignores the error we trigger from some curses
            # versions by trying to write into the lowest-rightmost spot
            # in the window.
            try:
                self.win.addch(ch)
            except curses.error:
                pass
            if self.insert_mode:
                (backy, backx) = self.win.getyx()
                if curses.ascii.isprint(oldch):
                    self._insert_printable_char(oldch)
                    self.win.move(backy, backx) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:19,代码来源:textpad.py

示例5: set_up_handlers

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def set_up_handlers(self):
        """This function should be called somewhere during object initialisation (which all library-defined widgets do). You might like to override this in your own definition,
but in most cases the add_handers or add_complex_handlers methods are what you want."""
        #called in __init__
        self.handlers = {
                   curses.ascii.NL:     self.h_exit_down,
                   curses.ascii.CR:     self.h_exit_down,
                   curses.ascii.TAB:    self.h_exit_down,
                   curses.KEY_BTAB:     self.h_exit_up,
                   curses.KEY_DOWN:     self.h_exit_down,
                   curses.KEY_UP:       self.h_exit_up,
                   curses.KEY_LEFT:     self.h_exit_left,
                   curses.KEY_RIGHT:    self.h_exit_right,
                   # "^P":                self.h_exit_up,
                   # "^N":                self.h_exit_down,
                   curses.ascii.ESC:    self.h_exit_escape,
                   curses.KEY_MOUSE:    self.h_exit_mouse,
                   }

        self.complex_handlers = [] 
开发者ID:hexway,项目名称:apple_bleee,代码行数:22,代码来源:wgwidget.py

示例6: set_up_handlers

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def set_up_handlers(self):
        super(Textfield, self).set_up_handlers()    
    
        # For OS X
        del_key = curses.ascii.alt('~')
        
        self.handlers.update({curses.KEY_LEFT:    self.h_cursor_left,
                           curses.KEY_RIGHT:   self.h_cursor_right,
                   curses.KEY_DC:      self.h_delete_right,
                   curses.ascii.DEL:   self.h_delete_left,
                   curses.ascii.BS:    self.h_delete_left,
                   curses.KEY_BACKSPACE: self.h_delete_left,
                   # mac os x curses reports DEL as escape oddly
                   # no solution yet                   
                   "^K":           self.h_erase_right,
                   "^U":           self.h_erase_left,
            })

        self.complex_handlers.extend((
                        (self.t_input_isprint, self.h_addch),
                        # (self.t_is_ck, self.h_erase_right),
                        # (self.t_is_cu, self.h_erase_left),
                        )) 
开发者ID:hexway,项目名称:apple_bleee,代码行数:25,代码来源:wgtextbox.py

示例7: set_up_handlers

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def set_up_handlers(self):
        """This function should be called somewhere during object initialisation (which all library-defined widgets do). You might like to override this in your own definition,
but in most cases the add_handers or add_complex_handlers methods are what you want."""
        #called in __init__
        self.handlers = {
                   curses.ascii.NL:     self.h_exit_down,
                   curses.ascii.CR:     self.h_exit_down,
                   curses.ascii.TAB:    self.h_exit_down,
                   curses.KEY_BTAB:     self.h_exit_up,
                   curses.KEY_DOWN:     self.h_exit_down,
                   curses.KEY_UP:       self.h_exit_up,
                   curses.KEY_LEFT:     self.h_exit_left,
                   curses.KEY_RIGHT:    self.h_exit_right,
                   "^P":                self.h_exit_up,
                   "^N":                self.h_exit_down,
                   curses.ascii.ESC:    self.h_exit_escape,
                   curses.KEY_MOUSE:    self.h_exit_mouse,
                   }

        self.complex_handlers = [] 
开发者ID:sealingtech,项目名称:EDCOP,代码行数:22,代码来源:wgwidget.py

示例8: setTextBuffer

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def setTextBuffer(self, textBuffer):
        app.controller.Controller.setTextBuffer(self, textBuffer)
        normalCommandSet = {
            ord('^'): textBuffer.cursorStartOfLine,
            ord('$'): textBuffer.cursorEndOfLine,
            ord('h'): textBuffer.cursorLeft,
            ord('i'): self.switchToCommandSetInsert,
            ord('j'): textBuffer.cursorDown,
            ord('k'): textBuffer.cursorUp,
            ord('l'): textBuffer.cursorRight,
        }
        self.commandSet = normalCommandSet
        self.commandSet_Insert = {
            curses.ascii.ESC: self.switchToCommandSetNormal,
        }
        self.commandDefault = self.textBuffer.insertPrintable 
开发者ID:google,项目名称:ci_edit,代码行数:18,代码来源:vi_editor.py

示例9: KEY_CTRL

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def KEY_CTRL(key):
        return curses.ascii.ctrl(bytes(key)) 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:4,代码来源:tabview.py

示例10: _end_of_line

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def _end_of_line(self, y):
        """Go to the location of the first blank on the given line,
        returning the index of the last non-blank character."""
        self._update_max_yx()
        last = self.maxx
        while True:
            if curses.ascii.ascii(self.win.inch(y, last)) != curses.ascii.SP:
                last = min(self.maxx, last+1)
                break
            elif last == 0:
                break
            last = last - 1
        return last 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:textpad.py

示例11: _end_of_line

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def _end_of_line(self, y):
        """Go to the location of the first blank on the given line,
        returning the index of the last non-blank character."""
        last = self.maxx
        while True:
            if curses.ascii.ascii(self.win.inch(y, last)) != curses.ascii.SP:
                last = min(self.maxx, last+1)
                break
            elif last == 0:
                break
            last = last - 1
        return last 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:14,代码来源:textpad.py

示例12: gather

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def gather(self):
        "Collect and return the contents of the window."
        result = ""
        for y in range(self.maxy+1):
            self.win.move(y, 0)
            stop = self._end_of_line(y)
            if stop == 0 and self.stripspaces:
                continue
            for x in range(self.maxx+1):
                if self.stripspaces and x > stop:
                    break
                result = result + chr(curses.ascii.ascii(self.win.inch(y, x)))
            if self.maxy > 0:
                result = result + "\n"
        return result 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:17,代码来源:textpad.py

示例13: is_escape

# 需要导入模块: import curses [as 别名]
# 或者: from curses import ascii [as 别名]
def is_escape(key):
        """Checks for escape key."""
        if len(key) == 1:
            return ord(key) == curses.ascii.ESC
        return False 
开发者ID:cslarsen,项目名称:wpm,代码行数:7,代码来源:screen.py


注:本文中的curses.ascii方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。