Changeset 3027

Show
Ignore:
Timestamp:
06/22/08 19:17:44 (5 years ago)
Author:
nopper
Message:

Backing up

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/UmitPlugins/source-plugins/umit-console/sources/console/pyconsole.py

    r3025 r3027  
    4747    return prefix 
    4848 
    49 class VirtualStdIn(object): 
    50     def __init__(self): 
    51         self.buffer = str() 
    52      
    53     def feed(self, txt): 
    54         if txt: 
    55             self.buffer += txt 
    56      
    57     def read(self, size): 
    58         t = self.buffer[0:size] 
    59         self.buffer = self.buffer[size + 1:] 
    60         return t 
    61      
    62     def readline(self): 
    63         t = self.buffer.split('\n') 
    64         self.buffer = "\n".join(t[1:]) 
    65         return t[0] 
    66      
    67     def readlines(self): 
    68         t = self.buffer.split('\n') 
    69         self.buffer = "" 
    70         return t 
    71  
    7249class _ReadLine(object): 
    7350 
     
    131108        self.history = _ReadLine.History() 
    132109        self.nonword_re = re.compile("[^\w\._]") 
    133         self.my_stdin = VirtualStdIn() 
    134110 
    135111    def freeze_undo(self): 
     
    236212        self.tab_pressed = 0 
    237213        handled = True 
    238          
    239         self.my_stdin.feed(event.string) 
    240214 
    241215        state = event.state & (gdk.SHIFT_MASK | 
     
    432406 
    433407    def do_raw_input(self, text): 
    434         print "HERE" 
    435  
    436     def write(self, whatever): 
     408        pass 
     409 
     410    def write(self,whatever): 
    437411        self.buffer.insert_at_cursor(whatever) 
    438      
    439     def readline(self): 
    440         self.my_stdin.readline() 
     412 
    441413 
    442414class _Console(_ReadLine, code.InteractiveInterpreter): 
     
    465437        self.run_on_raw_input = start_script 
    466438        self.raw_input(self.ps1) 
    467      
     439 
    468440    def __start(self): 
    469441        self.cmd_buffer = "" 
     
    502474 
    503475    def runcode(self, code): 
    504         savedo = sys.stdout 
    505         savedi = sys.stdin 
    506          
     476        saved = sys.stdout 
    507477        sys.stdout = self 
    508         sys.stdin = self 
    509          
    510478        try: 
    511479            eval(code, self.locals) 
     
    514482        except: 
    515483            self.showtraceback() 
    516              
    517         sys.stdout = savedo 
    518         sys.stdin = savedi 
     484        sys.stdout = saved 
    519485 
    520486    def complete_attr(self, start, end): 
     
    579545        return completions 
    580546 
     547 
    581548def ReadLineType(t=gtk.TextView): 
    582549    class readline(t, _ReadLine):