Skip to content

Commit

Permalink
Fixed mouse selection in terminal bing offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Apr 23, 2024
1 parent a7757dc commit 32a5230
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions scripting/editor_api_wasm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ proc getBackend*(): Backend =
result = parseJson($res).jsonTo(typeof(result))


proc editor_getHostOs_string_App_wasm(arg: cstring): cstring {.importc.}
proc getHostOs*(): string =
var argsJson = newJArray()
let argsJsonString = $argsJson
let res {.used.} = editor_getHostOs_string_App_wasm(argsJsonString.cstring)
result = parseJson($res).jsonTo(typeof(result))


proc editor_loadApplicationFile_Option_string_App_string_wasm(arg: cstring): cstring {.
importc.}
proc loadApplicationFile*(path: string): Option[string] =
Expand Down
10 changes: 10 additions & 0 deletions src/app.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,16 @@ static:
proc getBackend*(self: App): Backend {.expose("editor").} =
return self.backend

proc getHostOs*(self: App): string {.expose("editor").} =
when defined(linux):
return "linux"
elif defined(windows):
return "windows"
elif defined(js):
return "browser"
else:
return "unknown"

proc loadApplicationFile*(self: App, path: string): Option[string] {.expose("editor").} =
## Load a file from the application directory (path is relative to the executable)
return fs.loadApplicationFile(path).some
Expand Down
4 changes: 2 additions & 2 deletions src/ui/node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1372,10 +1372,10 @@ macro panel*(builder: UINodeBuilder, inFlags: UINodeFlags, args: varargs[untyped

proc findNodeContaining*(node: UINode, pos: Vec2, predicate: proc(node: UINode): bool): Option[UINode] =
result = UINode.none
if pos.x < node.lx or pos.x > node.lx + node.lw or pos.y < node.ly or pos.y > node.ly + node.lh:
if pos.x < node.lx or pos.x >= node.lx + node.lw or pos.y < node.ly or pos.y >= node.ly + node.lh:
return

# echo "findNodeContaining ", node.dump, " at " ,pos, " with ", (node.lx, node.ly, node.lw, node.lh)
# debugf"findNodeContaining at {pos} with {(node.lx, node.ly, node.lw, node.lh)}: {node.dump}"

if node.first.isNil: # has no children
if predicate.isNotNil and not predicate(node):
Expand Down

0 comments on commit 32a5230

Please sign in to comment.