1
0

Fixed some minor bugs

This commit is contained in:
Jon Michael Aanes 2017-11-14 13:54:55 +01:00
parent 6bf24bb234
commit f3dba06048
2 changed files with 17 additions and 4 deletions

2
test_tig_3.tig Normal file
View File

@ -0,0 +1,2 @@
/* print: |hello| */
print(concat("", concat("hello", "")))

View File

@ -79,6 +79,11 @@ let
then concat(ll.val, ll_to_s(ll.next)) then concat(ll.val, ll_to_s(ll.next))
else "" else ""
function ll_length (ll:stringll) : int =
if ll = nil
then 0
else 1 + ll_length(ll.next)
var MAXWIDTH := 40 var MAXWIDTH := 40
function is_whitespace (char:string) : int = function is_whitespace (char:string) : int =
@ -117,7 +122,10 @@ let
let var words := split_words(text) let var words := split_words(text)
var splitstr := insert_whitespace_between_words(words, linewidth) var splitstr := insert_whitespace_between_words(words, linewidth)
in in
ll_to_s(splitstr.next.next.next) if ll_length(splitstr) > 2 then
ll_to_s(splitstr.next.next.next)
else
ll_to_s(splitstr)
end end
function max (a:int, b:int) : int = function max (a:int, b:int) : int =
@ -160,7 +168,8 @@ let
/* Draw stuff */ /* Draw stuff */
function drawtextbubble (text:string) = function drawtextbubble (text:string) =
let var textwidth := longest_line_length(text) let
var textwidth := longest_line_length(text)
var textheight := nr_char_in_str(text, "\n") + 1 var textheight := nr_char_in_str(text, "\n") + 1
var bubblewidth := textwidth + 4 var bubblewidth := textwidth + 4
var after_text := concat3("\013\027[",int_to_s(bubblewidth-1),"C|") var after_text := concat3("\013\027[",int_to_s(bubblewidth-1),"C|")
@ -172,10 +181,12 @@ let
function drawtiger () = print(indentstring(TIGER, INDENT, "")) function drawtiger () = print(indentstring(TIGER, INDENT, ""))
var text := getinput() var text := getinput()
var wrappedtext := wrapstring(text, MAXWIDTH)
in in
drawtextbubble(wrapstring(text, MAXWIDTH)); drawtextbubble(wrappedtext);
drawtiger(); drawtiger();
print("\n") print("\n");
flush()
end end