Tabs behaving sensibly in expect.
[forth.jl.git] / src / forth.jl
index f10ea04..dd808bb 100644 (file)
@@ -585,6 +585,14 @@ end)
 sources = Array{Any,1}()
 currentSource() = sources[length(sources)]
 
+CLOSEFILES_CFA = defPrimWord("CLOSEFILES", () -> begin
+    while currentSource() != STDIN
+        close(pop!(sources))
+    end
+
+    return NEXT
+end)
+
 EOF_CFA = defPrimWord("\x04", () -> begin
     if currentSource() != STDIN
         close(pop!(sources))
@@ -640,8 +648,13 @@ function getLineFromSTDIN()
 
         elseif key == '\b'
             if !isempty(line)
+                if line[length(line)] == '\t'
+                    print(string("\r\033[K",line[1:length(line)-1]))
+                else
+                    print("\b\033[K")
+                end
+
                 line = line[1:length(line)-1]
-                print("\b \b")
             end
 
         elseif key == '\e'
@@ -1031,7 +1044,7 @@ QUIT_CFA = defWord("QUIT",
     BRANCH_CFA,-4])
 
 ABORT_CFA = defWord("ABORT",
-    [PSP0_CFA, PSPSTORE_CFA, QUIT_CFA])
+    [CLOSEFILES_CFA, PSP0_CFA, PSPSTORE_CFA, QUIT_CFA])
 
 BYE_CFA = defPrimWord("BYE", () -> begin
     println("\nBye!")