Mercurial > python-cmd2
diff cmd2.py @ 83:2176ce847939
merged copy to both clipboards in
author | catherine@Elli.myhome.westell.com |
---|---|
date | Sun, 13 Jul 2008 07:51:02 -0400 |
parents | bbf0afc6868b |
children | 416ea36af789 |
line wrap: on
line diff
--- a/cmd2.py Fri Jul 04 14:34:37 2008 -0400 +++ b/cmd2.py Sun Jul 13 07:51:02 2008 -0400 @@ -119,6 +119,10 @@ xclipproc = subprocess.Popen('xclip -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) xclipproc.stdin.write(txt) xclipproc.stdin.close() + # but we want it in both the "primary" and "mouse" clipboards + xclipproc = subprocess.Popen('xclip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) + xclipproc.stdin.write(txt) + xclipproc.stdin.close() else: def getPasteBuffer(): raise OSError, pastebufferr % ('xclip', 'On Debian/Ubuntu, install with "sudo apt-get install xclip"') @@ -155,7 +159,6 @@ break settable = ['prompt', 'continuationPrompt', 'defaultFileName', 'editor', 'caseInsensitive'] - terminators = ';\n' #TODO: strip this _TO_PASTE_BUFFER = 1 def do_cmdenvironment(self, args): self.stdout.write(""" @@ -164,7 +167,7 @@ Settable parameters: %(settable)s """ % { 'casesensitive': ('not ' and self.caseInsensitive) or '', - 'terminators': ' '.join(self.terminators), + 'terminators': self.terminatorPattern, 'settable': ' '.join(self.settable) }) @@ -226,15 +229,18 @@ if isinstance(s, pyparsing.ParseResults): return s result = (pyparsing.SkipTo(pyparsing.StringEnd()))('fullStatement').parseString(s) - result['statement'] = result.fullStatement - result['parseable'] = result.fullStatement + if s[0] in self.shortcuts: + s = self.shortcuts[s[0]] + ' ' + s[1:] + result['statement'] = s + result['parseable'] = s result += parseSearchResults(self.terminatorPattern, s) if result.terminator: result['statement'] = result.upToIncluding + result['unterminated'] = result.before result['parseable'] = result.after else: result += parseSearchResults(self.punctuationPattern, s) - result['statement'] = result.before + result['statement'] = result['unterminated'] = result.before result += parseSearchResults(self.pipePattern, result.parseable) result += parseSearchResults(self.redirectInPattern, result.parseable) result += parseSearchResults(self.redirectOutPattern, result.parseable) @@ -263,6 +269,9 @@ commands by the interpreter should stop. """ + line = line.strip() + if not line: + return statement = self.parsed(line) while (statement.command in self.multilineCommands) and not \ (statement.terminator or assumeComplete): @@ -643,4 +652,4 @@ setattr(self.obj, attrib, getattr(self, attrib)) if __name__ == '__main__': - doctest.testmod() \ No newline at end of file + doctest.testmod()