From b14a3eca0c6353b46bb2c70132d5570db4885b37 Mon Sep 17 00:00:00 2001 From: Mike Naberezny Date: Sat, 29 Nov 2008 07:06:38 +0000 Subject: [PATCH] Added shortcuts for monitor commands. --- CHANGES.txt | 5 +++++ src/py65/monitor.py | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3ee178f..a1d9fd8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +0.3 + + - Added shortcuts for monitor commands such as "m" for "memory". These + are mostly the same as the VICE monitor shortcuts. + 0.2 - Added a new "disassemble" command to the monitor. It can disassemble diff --git a/src/py65/monitor.py b/src/py65/monitor.py index 82cb21a..714e586 100644 --- a/src/py65/monitor.py +++ b/src/py65/monitor.py @@ -19,6 +19,7 @@ class Monitor(cmd.Cmd): self._mpu = MPU() self._install_mpu_observers() self._update_prompt() + self._add_shortcuts() self._address_parser = AddressParser() self._disassembler = Disassembler(self._mpu, self._address_parser) self._assembler = Assembler(self._address_parser) @@ -40,12 +41,32 @@ class Monitor(cmd.Cmd): self._update_prompt() return result + def _add_shortcuts(self): + self._shortcuts = {'~': 'tilde', + '?': 'help', + 'al': 'add_label', + 'd': 'disassemble', + 'dl': 'delete_label', + 'f': 'fill', + 'g': 'goto', + 'l': 'load', + 'll': 'load_labels', + 'm': 'mem', + 'r': 'registers', + 'ret': 'return', + 'rad': 'radix', + 'shl': 'show_labels', + 'x': 'quit', + 'z': 'step'} + def _preprocess_line(self, line): - # tilde command - matches = re.match('^~\s*', line) - if matches: - start, end = matches.span() - line = "tilde %s" % line[end:] + # command shortcuts + for shortcut, command in self._shortcuts.iteritems(): + pattern = '^%s\s+' % re.escape(shortcut) + matches = re.match(pattern, line) + if matches: + start, end = matches.span() + line = "%s %s" % (command, line[end:]) # line comments quoted = False @@ -298,10 +319,10 @@ class Monitor(cmd.Cmd): self._fill(start, start, map(ord, bytes)) def help_fill(self): - self.output("fill ") - self.output("Fill memory in the specified address range with the data in") - self.output(". If the size of the address range is greater") - self.output("than the size of the data_list, the data_list is repeated.") + self._output("fill ") + self._output("Fill memory in the specified address range with the data in") + self._output(". If the size of the address range is greater") + self._output("than the size of the data_list, the data_list is repeated.") def do_fill(self, args): split = shlex.split(args)