Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert red to python 3 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def run(self, execute, prompt, ctx):
<dim>(time travel)</dim> """))

time = prompt(banner)
if not len(time):
if not time:
return

now = int(ctx['loc'].get('time') or 0)
Expand Down Expand Up @@ -125,7 +125,7 @@ class Print(Command):

def run(self, execute, prompt, ctx):
var = prompt(vt100.magenta(vt100.dim('(print) ')))
if not len(var):
if not var:
return
output = execute('print ' + var)
return vt100.magenta(output)
Expand Down Expand Up @@ -198,7 +198,7 @@ class Custom(Command):

def run(self, execute, prompt, ctx):
command = prompt(vt100.dim('(odb) '))
if not len(command):
if not command:
return
output = execute(command)
return vt100.blue('>> {0}\n'.format(command)) + output
Expand Down
10 changes: 6 additions & 4 deletions red.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


debugger_log = open('/tmp/red.log', 'w')

def trace(text):
debugger_log.write(text)
debugger_log.flush()
Expand Down Expand Up @@ -116,7 +117,7 @@ def hl(src, breakpoint_lines):
text = re.sub(a_ptrn, vt100.bold('\\1'), text)
text = re.sub(b_ptrn, vt100.bold('\\1'), text)

symbol = u'\u2022' if has_breakpoint else ' '
symbol = '\u2022' if has_breakpoint else ' '

# Can't use red twice, the closing color tag will mess the outputs
if not is_current:
Expand Down Expand Up @@ -170,9 +171,10 @@ def main(args):
return 1

dbgr = subprocess.Popen(['ocamldebug', '-emacs'] + command_line,
encoding='utf-8',
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

print(debugger_command(dbgr, '')[0].replace('\tOCaml Debugger version ', vt100.red(u'\u2022 RED') + ' OCamlDebug v'))
print(debugger_command(dbgr, '')[0].replace('\tOCaml Debugger version ', vt100.red('\u2022 RED') + ' OCamlDebug v'))
print(vt100.dim('Press ? for help'))
print(debugger_command(dbgr, 'start')[0])

Expand Down Expand Up @@ -215,9 +217,9 @@ def prompt(text):
file_name = loc.get('file')
listing = hl(execute('list'), breakpoint_lines_for_file(breakpoints, file_name))
if listing:
console.print_text((u'\u2500[ %s ]' % loc.get('file')) + u'\u2500' * 300)
console.print_text(('\u2500[ %s ]' % loc.get('file')) + '\u2500' * 300)
console.print_text(listing)
console.print_text(u'\u2500' * 300)
console.print_text('\u2500' * 300)
else:
module = loc.get('module')
if module:
Expand Down
2 changes: 1 addition & 1 deletion vt100.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def print_text(self, text):
def safe_input(self, prompt=None):
self.lines_printed += 1
try:
return raw_input(prompt)
return input(prompt)
except:
pass

Expand Down