예제 #1
0
파일: argo_frame.py 프로젝트: dengzhp/argon
 def readline(self,acceptable=ac.is_safe_char,finish=ac.ks_finish,buf_size=20, prompt='', prefix=u''):
     if prompt :
         self.write(prompt)
     if prefix :
         buf = list(prefix)
         self.write(prefix)
     else:
         buf = []
     while len(buf) < buf_size:
         ds = self.read_secret(2)
         if len(ds) == 1 and ac.is_gbk_zh(ds):  ## fix_bug for sterm
             ds += self.read_secret()
         if ds == ac.k_backspace :
             if buf :
                 data = buf.pop()
                 self.write(ac.backspace * ac.srcwidth(data))
                 continue
         elif ds in finish :
             return ''.join(buf)
         elif ds == ac.k_ctrl_c:
             return False
         elif acceptable(ds):
             buf.append(ds)
             self.write(ds)
     return ''.join(buf)
예제 #2
0
파일: bbs.py 프로젝트: LTaoist/chaofeng
 def _socket_holder(self, buffer_size=1024):
     while True:
         data = self.sock.recv(buffer_size)
         # print repr(data)
         if len(data) == 1 and ascii.is_gbk_zh(data):  # Ugly
             data += self.sock.recv(1)
         if data in ascii.CC:
             yield ascii.CC[data]
         elif data:
             try:
                 data = self.u(data)
             except UnicodeDecodeError:
                 print 'UnicodeDecodeError'
                 continue
             for char in data:
                 yield char
         else:
             raise BrokenConnection(self.session.ip, self.session.port)
예제 #3
0
파일: edit.py 프로젝트: dengzhp/argon
 def get(self,char):
     if self.ugly :
         char = self.ugly + char
         self.ugly = ''
     elif len(char) == 1 and ac.is_gbk_zh(char):
         self.ugly = char
         return
         
     if char in config.hotkeys['edit_editor'] :
         self.e.do_editor_command( config.hotkeys['edit_editor'][char])
     elif char == config.hotkeys['edit_2ndcmd_start'] :
         x = self.read_secret()
         if x in config.hotkeys['edit_editor_2nd']:
             self.e.do_editor_command(config.hotkeys['edit_editor_2nd'][x])
     elif char in config.hotkeys['edit']:
         getattr(self, config.hotkeys['edit'][char])()
     else:
         self.e.safe_insert_iter(char)