Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
choltreppe committed Nov 3, 2023
1 parent 6b0b804 commit 98ae35c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions karax/karaxdsl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ proc toKstring(n: NimNode): NimNode =
proc newDotAsgn(tmp: NimNode, key: string, x: NimNode): NimNode =
result = newTree(nnkAsgn, newDotExpr(tmp, newIdentNode key), x)

proc handleNoRedrawPragma(call: var NimNode, tmpContext, name, anon: NimNode) =
proc handleNoRedrawPragma(call: NimNode, tmpContext, name, anon: NimNode): NimNode =
when defined(js):
if anon.pragma.kind == nnkPragma and len(anon.pragma) > 0:
var hasNoRedrawPragma = false
Expand All @@ -55,8 +55,9 @@ proc handleNoRedrawPragma(call: var NimNode, tmpContext, name, anon: NimNode) =
anon.pragma.del(i)
break
if hasNoRedrawPragma:
call = newCall(ident"addEventHandlerNoRedraw", tmpContext,
return newCall(ident"addEventHandlerNoRedraw", tmpContext,
newDotExpr(bindSym"EventKind", name), anon)
call

proc tcall2(n, tmpContext: NimNode): NimNode =
# we need to distinguish statement and expression contexts:
Expand Down Expand Up @@ -108,9 +109,9 @@ proc tcall2(n, tmpContext: NimNode): NimNode =
if tmpContext == nil:
error "no VNode to attach the event handler to"
else:
result = newCall(evHandler(), tmpContext,
newDotExpr(bindSym"EventKind", n[0]), anon, ident("kxi"))
handleNoRedrawPragma(result, tmpContext, n[0], anon)
let call = newCall(evHandler(), tmpContext,
newDotExpr(bindSym"EventKind", n[0]), anon, ident("kxi"))
result = handleNoRedrawPragma(call, tmpContext, n[0], anon)
else:
result = n
of nnkVarSection, nnkLetSection, nnkConstSection:
Expand Down

0 comments on commit 98ae35c

Please sign in to comment.