From a90efe752de78f2164203b2862dd089a9d9f445a Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 12 Dec 2018 12:34:35 +0100 Subject: [PATCH] merged #53 manually; todoapp must ignore empty input lines --- examples/todoapp/todoapp.nim | 5 +++-- karax/jstrutils.nim | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/todoapp/todoapp.nim b/examples/todoapp/todoapp.nim index 9f5e99f..b944de5 100644 --- a/examples/todoapp/todoapp.nim +++ b/examples/todoapp/todoapp.nim @@ -41,8 +41,9 @@ proc updateEntry(pos: int, content: cstring, completed: bool) = markAsCompleted(pos, completed) proc onTodoEnter(ev: Event; n: VNode) = - addEntry(n.value, false) - n.value = "" + if n.value.strip() != "": + addEntry(n.value, false) + n.value = "" proc removeHandler(ev: Event; n: VNode) = updateEntry(n.index, cstring(nil), false) diff --git a/karax/jstrutils.nim b/karax/jstrutils.nim index a6f2cc9..6b83afb 100644 --- a/karax/jstrutils.nim +++ b/karax/jstrutils.nim @@ -4,6 +4,8 @@ proc split*(s, sep: cstring): seq[cstring] {.importcpp, nodecl.} proc split*(s, sep: cstring; max: int): seq[cstring] {.importcpp, nodecl.} +proc strip*(s: cstring): cstring {.importcpp: "#.trim()", nodecl.} + proc startsWith*(a, b: cstring): bool {.importcpp: "startsWith", nodecl.} proc contains*(a, b: cstring): bool {.importcpp: "(#.indexOf(#)>=0)", nodecl.}