From 864c1f4e9dfa1e5bf8d351c520ea6a9308fae6fe Mon Sep 17 00:00:00 2001 From: d6 Date: Thu, 27 Jan 2022 21:55:10 -0500 Subject: [PATCH] asm command --HG-- branch : pmacs2 --- mode/tal.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mode/tal.py b/mode/tal.py index 1634909..32b4b0f 100644 --- a/mode/tal.py +++ b/mode/tal.py @@ -68,6 +68,23 @@ hi_cyan = ('cyan155', 'default') lo_blue = ('blue113', 'default') hi_blue = ('blue225', 'default') +class Talasm(Method): + '''Assemble the given .tal file''' + bname = '*Talasm*' + def run_pipe(self, w, args, switch, mname=None): + return w.application.run_pipe(args, w.buffer, self.bname, switch, mname) + def _execute(self, w, **vargs): + path = w.buffer.path + if path.endswith('.tal'): + dest = path[:-4] + '.rom' + else: + raise Exception('invalid path: %s' % path) + args = ['uxnasm', path, dest] + r = self.run_pipe(w, args, lambda x: x != 0, 'error') + b = w.application.get_buffer_by_name(self.bname) + b.orig_path = w.buffer.path + if r == 0: w.set_error(b.lines[-2]) + class Taldoc(Method): '''View documentation''' ops = { @@ -220,7 +237,7 @@ class Tal(Fundamental): name = 'tal' extensions = ['.tal'] grammar = TalGrammar - actions = [Taldoc] + actions = [Taldoc, Talasm] colors = { 'tal.addr': hi_cyan, 'tal.defmacro': hi_blue, @@ -239,6 +256,7 @@ class Tal(Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} _bindings = { + 'talasm': ('C-c c', 'C-c C-c'), 'taldoc': ('C-c p',), 'close-paren': (')',), 'close-brace': ('}',),