python类Console()的实例源码

ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def rectangle(self, rect, attr=None, fill=' '):
        '''Fill Rectangle.'''
        pass
        oldtop=self.WindowTop
        oldpos=self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill=fill[:1]*abs(x1-x0)
        else:
            rowfill=' '*abs(x1-x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0,y)
                self.write_color(rowfill,attr)
        self.pos(*oldpos)
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def install_readline(hook):
    def hook_wrap():
        try:
            res=hook()
        except KeyboardInterrupt,x:   #this exception does not seem to be caught
            res=""
        except EOFError:
            return None
        if res[-1:]=="\n":
            return res[:-1]
        else:
            return res
    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self,autoIndentSize): 
            return hook_wrap()
        def Write(self,text, style):
            System.Console.Write(text)
        def WriteLine(self,text, style): 
            System.Console.WriteLine(text)
    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
ironpython_console.py 文件源码 项目:isf 作者: w3h 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def rectangle(self, rect, attr=None, fill=' '):
        '''Fill Rectangle.'''
        oldtop = self.WindowTop
        oldpos = self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill = fill[:1] * abs(x1 - x0)
        else:
            rowfill = ' ' * abs(x1 - x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0, y)
                self.write_color(rowfill, attr)
        self.pos(*oldpos)
ironpython_console.py 文件源码 项目:isf 作者: w3h 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def install_readline(hook):
    def hook_wrap():
        try:
            res = hook()
        except KeyboardInterrupt as x:   #this exception does not seem to be caught
            res = ""
        except EOFError:
            return None
        if res[-1:] == "\n":
            return res[:-1]
        else:
            return res
    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self, autoIndentSize): 
            return hook_wrap()
        def Write(self, text, style):
            System.Console.Write(text)
        def WriteLine(self, text, style): 
            System.Console.WriteLine(text)
    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
ironpython_console.py 文件源码 项目:OWASP-ZSC-API 作者: viraintel 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def rectangle(self, rect, attr=None, fill=' '):
        '''Fill Rectangle.'''
        oldtop = self.WindowTop
        oldpos = self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill = fill[:1] * abs(x1 - x0)
        else:
            rowfill = ' ' * abs(x1 - x0)
        for y in range(y0, y1):
            System.Console.SetCursorPosition(x0, y)
            self.write_color(rowfill, attr)
        self.pos(*oldpos)
ironpython_console.py 文件源码 项目:OWASP-ZSC-API 作者: viraintel 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def install_readline(hook):
    def hook_wrap():
        try:
            res = hook()
        except KeyboardInterrupt as x:  #this exception does not seem to be caught
            res = ""
        except EOFError:
            return None
        if res[-1:] == "\n":
            return res[:-1]
        else:
            return res

    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self, autoIndentSize):
            return hook_wrap()

        def Write(self, text, style):
            System.Console.Write(text)

        def WriteLine(self, text, style):
            System.Console.WriteLine(text)

    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
ironpython_console.py 文件源码 项目:shadowbroker-auto 作者: wrfly 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def rectangle(self, rect, attr=None, fill=u' '):
        u'''Fill Rectangle.'''
        oldtop = self.WindowTop
        oldpos = self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill = fill[:1] * abs(x1 - x0)
        else:
            rowfill = u' ' * abs(x1 - x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0, y)
                self.write_color(rowfill, attr)
        self.pos(*oldpos)
ironpython_console.py 文件源码 项目:shadowbroker-auto 作者: wrfly 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def install_readline(hook):
    def hook_wrap():
        try:
            res = hook()
        except KeyboardInterrupt,x:   #this exception does not seem to be caught
            res = u""
        except EOFError:
            return None
        if res[-1:] == u"\n":
            return res[:-1]
        else:
            return res
    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self, autoIndentSize): 
            return hook_wrap()
        def Write(self, text, style):
            System.Console.Write(text)
        def WriteLine(self, text, style): 
            System.Console.WriteLine(text)
    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
ironpython_console.py 文件源码 项目:shadowbroker-auto 作者: wrfly 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def rectangle(self, rect, attr=None, fill=' '):
        '''Fill Rectangle.'''
        pass
        oldtop=self.WindowTop
        oldpos=self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill=fill[:1]*abs(x1-x0)
        else:
            rowfill=' '*abs(x1-x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0,y)
                self.write_color(rowfill,attr)
        self.pos(*oldpos)
ironpython_console.py 文件源码 项目:shadowbroker-auto 作者: wrfly 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def install_readline(hook):
    def hook_wrap():
        try:
            res=hook()
        except KeyboardInterrupt,x:   #this exception does not seem to be caught
            res=""
        except EOFError:
            return None
        if res[-1:]=="\n":
            return res[:-1]
        else:
            return res
    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self,autoIndentSize): 
            return hook_wrap()
        def Write(self,text, style):
            System.Console.Write(text)
        def WriteLine(self,text, style): 
            System.Console.WriteLine(text)
    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
ironpython_console.py 文件源码 项目:themole 作者: tiankonguse 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def rectangle(self, rect, attr=None, fill=' '):
        '''Fill Rectangle.'''
        oldtop = self.WindowTop
        oldpos = self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill = fill[:1] * abs(x1 - x0)
        else:
            rowfill = ' ' * abs(x1 - x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0, y)
                self.write_color(rowfill, attr)
        self.pos(*oldpos)
ironpython_console.py 文件源码 项目:themole 作者: tiankonguse 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def install_readline(hook):
    def hook_wrap():
        try:
            res = hook()
        except KeyboardInterrupt as x:   #this exception does not seem to be caught
            res = ""
        except EOFError:
            return None
        if res[-1:] == "\n":
            return res[:-1]
        else:
            return res
    class IronPythonWrapper(IronPythonConsole.IConsole):
        def ReadLine(self, autoIndentSize): 
            return hook_wrap()
        def Write(self, text, style):
            System.Console.Write(text)
        def WriteLine(self, text, style): 
            System.Console.WriteLine(text)
    IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, newbuffer=0):
        '''Initialize the Console object.

        newbuffer=1 will allocate a new buffer so the old content will be restored
        on exit.
        '''
        self.serial=0
        self.attr = System.Console.ForegroundColor
        self.saveattr = winattr[str(System.Console.ForegroundColor).lower()]
        self.savebg=System.Console.BackgroundColor
        log('initial attr=%s' % self.attr)
        log_sock("%s"%self.saveattr)
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _get(self):
        top=System.Console.WindowTop
        log_sock("WindowTop:%s"%top,"console")
        return top
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _set(self,value):
        top=System.Console.WindowTop
        log_sock("Set WindowTop:old:%s,new:%s"%(top,value),"console")
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def pos(self, x=None, y=None):
        '''Move or query the window cursor.'''
        if x is not None:
            System.Console.CursorLeft=x
        else:
            x=System.Console.CursorLeft
        if y is not None:
            System.Console.CursorTop=y
        else:
            y=System.Console.CursorTop
        return x,y
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def home(self):
        '''Move to home.'''
        self.pos(0,0)

# Map ANSI color escape sequences into Windows Console Attributes
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def page(self, attr=None, fill=' '):
        '''Fill the entire screen.'''
        System.Console.Clear()
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def clear_to_end_of_window(self):
        oldtop=self.WindowTop
        lastline=self.WindowTop+System.Console.WindowHeight
        pos=self.pos()
        w,h=self.size()
        length=w-pos[0]+min((lastline-pos[1]-1),5)*w-1
        self.write_color(length*" ")
        self.pos(*pos)
        self.WindowTop=oldtop
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def scroll_window(self, lines):
        '''Scroll the window by the indicated number of lines.'''
        top=self.WindowTop+lines
        if top<0:
            top=0
        if top+System.Console.WindowHeight>System.Console.BufferHeight:
            top=System.Console.BufferHeight
        self.WindowTop=top
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def getkeypress(self):
        '''Return next key press event from the queue, ignoring others.'''
        ck=System.ConsoleKey
        while 1:
            e = System.Console.ReadKey(True)
            if e.Key == System.ConsoleKey.PageDown: #PageDown
                self.scroll_window(12)
            elif e.Key == System.ConsoleKey.PageUp:#PageUp
                self.scroll_window(-12)
            elif str(e.KeyChar)=="\000":#Drop deadkeys
                log_sock("Deadkey: %s"%e)
                return event(self,e)
                pass
            else:
                return event(self,e)
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def size(self, width=None, height=None):
        '''Set/get window size.'''
        sc=System.Console


        if width is not None and height is not None:
            sc.BufferWidth,sc.BufferHeight=width,height
        else:
            return sc.BufferWidth,sc.BufferHeight

        if width is not None and height is not None:
            sc.WindowWidth,sc.WindowHeight=width,height
        else:
            return sc.WindowWidth-1,sc.WindowHeight-1
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def cursor(self, visible=True, size=None):
        '''Set cursor on or off.'''
        System.Console.CursorVisible=visible
ironpython_console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def bell(self):
        System.Console.Beep()
ironpython_console.py 文件源码 项目:isf 作者: w3h 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, newbuffer=0):
        '''Initialize the Console object.

        newbuffer=1 will allocate a new buffer so the old content will be restored
        on exit.
        '''
        self.serial = 0
        self.attr = System.Console.ForegroundColor
        self.saveattr = winattr[str(System.Console.ForegroundColor).lower()]
        self.savebg = System.Console.BackgroundColor
        log('initial attr=%s' % self.attr)
ironpython_console.py 文件源码 项目:isf 作者: w3h 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _get(self):
        top = System.Console.WindowTop
        log("WindowTop:%s"%top)
        return top
ironpython_console.py 文件源码 项目:isf 作者: w3h 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _set(self, value):
        top = System.Console.WindowTop
        log("Set WindowTop:old:%s,new:%s"%(top, value))
ironpython_console.py 文件源码 项目:isf 作者: w3h 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def pos(self, x=None, y=None):
        '''Move or query the window cursor.'''
        if x is not None:
            System.Console.CursorLeft=x
        else:
            x = System.Console.CursorLeft
        if y is not None:
            System.Console.CursorTop=y
        else:
            y = System.Console.CursorTop
        return x, y
ironpython_console.py 文件源码 项目:isf 作者: w3h 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def home(self):
        '''Move to home.'''
        self.pos(0, 0)

# Map ANSI color escape sequences into Windows Console Attributes
ironpython_console.py 文件源码 项目:isf 作者: w3h 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def page(self, attr=None, fill=' '):
        '''Fill the entire screen.'''
        System.Console.Clear()


问题


面经


文章

微信
公众号

扫码关注公众号