diff options
Diffstat (limited to 'tools/nimrepl.nim')
-rwxr-xr-x | tools/nimrepl.nim | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tools/nimrepl.nim b/tools/nimrepl.nim index bf0578285..210ac2467 100755 --- a/tools/nimrepl.nim +++ b/tools/nimrepl.nim @@ -1,20 +1,22 @@ -import glib2, gtk2, gdk2, osproc, dialogs, strutils - -type - output = tuple[compiler, app: string] +# +# +# Nimrod REPL +# (c) Copyright 2010 Dominik Picheta +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# -proc execCode(code: string): output = +import glib2, gtk2, gdk2, osproc, dialogs, strutils +proc execCode(code: string): string = var f: TFile if open(f, "temp.nim", fmWrite): f.write(code) f.close() else: - raise newException(EIO, "Unable to open file") - - var compilerOutput = osproc.execProcess("nimrod c temp.nim") - var appOutput = osproc.execProcess("temp.exe") - return (compilerOutput, appOutput) + raise newException(EIO, "Unable to open file") + result = osproc.execProcess("nimrod run --verbosity:0 temp.nim") var shiftPressed = False var w: gtk2.PWindow @@ -83,8 +85,8 @@ proc inputKeyReleased(widget: PWidget, event: PEventKey, try: var r = execCode($InputText) - set_text(OutputTextBuffer, r[0] & r[1], len(r[0] & r[1])) - except: + set_text(OutputTextBuffer, r, len(r)) + except EIO: setError("Error: Could not open file temp.nim") |