diff --git a/src/absytree.nim b/src/absytree.nim index ca31a936..026d1ed3 100644 --- a/src/absytree.nim +++ b/src/absytree.nim @@ -14,7 +14,7 @@ else: static: echo "Compiling for unknown" -import std/[parseopt, options, os, sets] +import std/[parseopt, options, macros] import compilation_config, custom_logger, scripting_api @@ -115,14 +115,14 @@ var renderedLastFrame = false proc runApp(): Future[void] {.async.} = var ed = await newEditor(backend.get, rend) - addTimer 1000, false, proc(fd: AsyncFD): bool = + addTimer 2, false, proc(fd: AsyncFD): bool = return false var frameIndex = 0 var frameTime = 0.0 let minPollPerFrameMs = 1.0 - let maxPollPerFrameMs = 10.0 + let maxPollPerFrameMs = 5.0 var pollBudgetMs = 0.0 while not ed.closeRequested: defer: @@ -135,7 +135,7 @@ proc runApp(): Future[void] {.async.} = let eventCounter = rend.processEvents() let eventTime = eventTimer.elapsed.ms - var layoutTime, updateTime, renderTime: float + var updateTime, renderTime: float block: let delta = ed.frameTimer.elapsed.ms ed.frameTimer = startTimer() @@ -177,20 +177,22 @@ proc runApp(): Future[void] {.async.} = poll(2) else: try: - pollBudgetMs += max(minPollPerFrameMs, maxPollPerFrameMs - totalTimer.elapsed.ms) + pollBudgetMs += clamp(15 - totalTimer.elapsed.ms, minPollPerFrameMs, maxPollPerFrameMs) + var totalPollTime = 0.0 while pollBudgetMs > maxPollPerFrameMs: let start = startTimer() poll(maxPollPerFrameMs.int) pollBudgetMs -= start.elapsed.ms + totalPollTime = totalPollTime + start.elapsed.ms except CatchableError: # log(lvlError, fmt"Failed to poll async dispatcher: {getCurrentExceptionMsg()}: {getCurrentException().getStackTrace()}") discard let pollTime = pollTimer.elapsed.ms - let timeToSleep = 8 - totalTimer.elapsed.ms - if timeToSleep > 1: - # debugf"sleep for {timeToSleep.int}ms" - sleep(timeToSleep.int) + # let timeToSleep = 8 - totalTimer.elapsed.ms + # if timeToSleep > 1: + # # debugf"sleep for {timeToSleep.int}ms" + # sleep(timeToSleep.int) let totalTime = totalTimer.elapsed.ms if eventCounter > 0 or totalTime > 20: diff --git a/src/absytree_js.nim b/src/absytree_js.nim index 02f69032..d8bba1fd 100644 --- a/src/absytree_js.nim +++ b/src/absytree_js.nim @@ -5,8 +5,8 @@ logCategory "main-js" logger.enableConsoleLogger() -import std/[strformat, dom, macros, sets] -import util, app, timer, platform/widget_builders, platform/platform, platform/browser_platform, text/text_document, event, theme, custom_async +import std/[strformat, dom, macros] +import util, app, timer, platform/widget_builders, platform/platform, platform/browser_platform, text/text_document, event, custom_async import language/language_server from scripting_api import Backend @@ -22,7 +22,6 @@ var initializedEditor = false var hasRequestedRerender = false var isRenderInProgress = false -var frameTime = 0.0 var frameIndex = 0 var advanceFrame = false diff --git a/src/app.nim b/src/app.nim index 25a5c1e4..fb6bba02 100644 --- a/src/app.nim +++ b/src/app.nim @@ -1959,7 +1959,6 @@ proc handleAction(self: App, action: string, arg: string): bool = return true template createNimScriptContextConstructorAndGenerateBindings*(): untyped = - import std/[macros, macrocache] import ast_document, model_document, text/text_editor, selector_popup, lsp_client when not defined(js): proc createAddins(): VmAddins = diff --git a/src/array_set.nim b/src/array_set.nim index 5441ab37..0e0df4a5 100644 --- a/src/array_set.nim +++ b/src/array_set.nim @@ -1,5 +1,3 @@ -import std/[sequtils] - func `in`*[T](x: T, xs: openArray[T]): bool = xs.find(x) != -1 func incl*[T](xs: var seq[T], x: T) = diff --git a/src/ast/base_language_wasm.nim b/src/ast/base_language_wasm.nim index 96ab756f..14e4cb46 100644 --- a/src/ast/base_language_wasm.nim +++ b/src/ast/base_language_wasm.nim @@ -99,7 +99,7 @@ proc compileRemainingFunctions(self: BaseLanguageWasmCompiler) = self.compileFunction(function[0], function[1]) proc compileToBinary*(self: BaseLanguageWasmCompiler, node: AstNode): seq[uint8] = - let funcIdx = self.getOrCreateWasmFunc(node, exportName="test".some) + discard self.getOrCreateWasmFunc(node, exportName="test".some) self.compileRemainingFunctions() let binary = self.builder.generateBinary() diff --git a/src/ast_document.nim b/src/ast_document.nim index 6ec43994..4b8a1e97 100644 --- a/src/ast_document.nim +++ b/src/ast_document.nim @@ -2028,7 +2028,8 @@ proc getItemAtPixelPosition(self: AstDocumentEditor, posWindow: Vec2): Option[in # return index.some method handleScroll*(self: AstDocumentEditor, scroll: Vec2, mousePosWindow: Vec2) = - let scrollAmount = scroll.y * self.configProvider.getValue("ast.scroll-speed", 20.0) + discard + # let scrollAmount = scroll.y * self.configProvider.getValue("ast.scroll-speed", 20.0) # todo # if not self.lastCompletionsWidget.isNil and self.lastCompletionsWidget.lastBounds.contains(mousePosWindow): diff --git a/src/comb_sort.nim b/src/comb_sort.nim index 8b42a6f3..0c871159 100644 --- a/src/comb_sort.nim +++ b/src/comb_sort.nim @@ -1,4 +1,4 @@ -import std/[algorithm, random] +import std/[algorithm] export algorithm diff --git a/src/custom_logger.nim b/src/custom_logger.nim index d627aa77..614dc7ce 100644 --- a/src/custom_logger.nim +++ b/src/custom_logger.nim @@ -33,7 +33,7 @@ proc enableFileLogger*(self: CustomLogger) = proc enableConsoleLogger*(self: CustomLogger) = self.consoleLogger = logging.newConsoleLogger(self.levelThreshold, self.fmtStr, flushThreshold=logging.lvlAll).some -let isTerminal = when declared(isatty): isatty(stdout) else: false +let isTerminal {.used.} = when declared(isatty): isatty(stdout) else: false method log(self: CustomLogger, level: logging.Level, args: varargs[string, `$`]) = if self.fileLogger.getSome(l): diff --git a/src/language/language_server_nimsuggest.nim b/src/language/language_server_nimsuggest.nim index 3765da5e..3a02a847 100644 --- a/src/language/language_server_nimsuggest.nim +++ b/src/language/language_server_nimsuggest.nim @@ -1,4 +1,4 @@ -import std/[strutils, options, json, os, tables, macros, strformat, sugar] +import std/[strutils, options, json, tables, macros, strformat, sugar] import scripting_api except DocumentEditor, TextDocumentEditor, AstDocumentEditor import language_server_base, util import custom_logger, custom_async, async_http_client, websocket @@ -7,7 +7,7 @@ import platform/filesystem logCategory "ls-nimsuggest" when not defined(js): - import std/[asyncdispatch, osproc, asyncnet, tempfiles] + import std/[asyncdispatch, os, osproc, asyncnet, tempfiles] else: type Port* = distinct uint16 diff --git a/src/language_server_absytree_commands.nim b/src/language_server_absytree_commands.nim index 4eb62acf..68cce965 100644 --- a/src/language_server_absytree_commands.nim +++ b/src/language_server_absytree_commands.nim @@ -1,4 +1,4 @@ -import std/[strutils, options, tables] +import std/[options, tables] import scripting_api except DocumentEditor, TextDocumentEditor, AstDocumentEditor import language/language_server_base, util import custom_logger, custom_async, dispatch_tables diff --git a/src/lsp_client.nim b/src/lsp_client.nim index 9737fe73..6a7bef79 100644 --- a/src/lsp_client.nim +++ b/src/lsp_client.nim @@ -1,5 +1,5 @@ -import std/[json, strutils, strformat, tables, sets, os, options, macros, uri, sequtils, sugar] -import custom_logger, custom_async +import std/[json, strutils, strformat, macros] +import custom_logger import scripting/expose logCategory "lsp" @@ -7,7 +7,8 @@ logCategory "lsp" var logVerbose = false when not defined(js): - import myjsonutils, util, async_process, lsp_types + import std/[tables, sets, os, options, uri, sequtils, sugar] + import myjsonutils, util, async_process, lsp_types, custom_async export lsp_types diff --git a/src/platform/browser_platform.nim b/src/platform/browser_platform.nim index dc2cecbe..a3431b54 100644 --- a/src/platform/browser_platform.nim +++ b/src/platform/browser_platform.nim @@ -1,9 +1,12 @@ -import std/[strformat, tables, dom, unicode, strutils, sugar, json] -import platform, custom_logger, rect_utils, input, event, lrucache, theme, timer +import std/[tables, dom, unicode, strutils, sugar] +import platform, custom_logger, rect_utils, input, event, lrucache, timer import vmath import chroma as chroma import ui/node +when defined(uiNodeDebugData): + import std/json + export platform type @@ -347,8 +350,6 @@ method render*(self: BrowserPlatform) = self.boundsStack.add rect(vec2(), self.size) defer: discard self.boundsStack.pop() - var buffer = "" - var element: Element = if self.content.children.len > 0: self.content.children[0].Element else: nil let wasNil = element.isNil self.builder.drawNode(self, element, self.builder.root) @@ -372,12 +373,6 @@ proc createOrReplaceElement(element: var Element, name: cstring, nameUpper: cstr element = dif element.class = "widget" -proc updateRelativePosition(element: var Element, bounds: Rect) = - element.style.left = ($bounds.x.int).cstring - element.style.top = ($bounds.y.int).cstring - element.style.width = ($bounds.w.int).cstring - element.style.height = ($bounds.h.int).cstring - proc myToHtmlHex(c: Color): cstring = result = "rgba(".cstring result += round(c.r * 255).int diff --git a/src/platform/gui_platform.nim b/src/platform/gui_platform.nim index 66cf7d4c..96feea31 100644 --- a/src/platform/gui_platform.nim +++ b/src/platform/gui_platform.nim @@ -1,5 +1,5 @@ import std/[tables, strutils, options, sets] -import platform, util, platform/filesystem, timer +import platform, util, platform/filesystem import custom_logger, input, event, monitors, lrucache, id, rect_utils, theme import chroma, vmath, windy, boxy, boxy/textures, opengl, pixie/[contexts, fonts] import ui/node @@ -43,7 +43,7 @@ type proc toInput(rune: Rune): int64 proc toInput(button: Button): int64 -proc centerWindowOnMonitor(window: Window, monitor: int) +proc centerWindowOnMonitor*(window: Window, monitor: int) proc getFont*(self: GuiPlatform, font: string, fontSize: float32): Font proc getFont*(self: GuiPlatform, fontSize: float32, style: set[FontStyle]): Font proc getFont*(self: GuiPlatform, fontSize: float32, flags: UINodeFlags): Font @@ -304,7 +304,7 @@ proc toInput(button: Button): int64 = of NumpadDivide: ord '/' else: 0 -proc centerWindowOnMonitor(window: Window, monitor: int) = +proc centerWindowOnMonitor*(window: Window, monitor: int) = let monitorPos = getMonitorRect(monitor) let left = float(monitorPos.left) diff --git a/src/platform/terminal_platform.nim b/src/platform/terminal_platform.nim index 534755d4..56e0ce6f 100644 --- a/src/platform/terminal_platform.nim +++ b/src/platform/terminal_platform.nim @@ -282,19 +282,15 @@ method render*(self: TerminalPlatform) = if self.builder.root.lastSizeChange == self.builder.frameIndex: self.redrawEverything = true - let t1 = startTimer() self.builder.drawNode(self, self.builder.root, force = self.redrawEverything) - let t1Ms = t1.elapsed.ms # This can fail if the terminal was resized during rendering, but in that case we'll just rerender next frame - let t2 = startTimer() try: self.buffer.display() self.redrawEverything = false except CatchableError: log(lvlError, fmt"Failed to display buffer: {getCurrentExceptionMsg()}") self.redrawEverything = true - let t2Ms = t2.elapsed.ms proc setForegroundColor(self: TerminalPlatform, color: chroma.Color) = if self.trueColorSupport: @@ -324,17 +320,17 @@ proc fillRect(self: TerminalPlatform, bounds: Rect, color: chroma.Color) = self.buffer.fillBackground(bounds.x.int, bounds.y.int, bounds.xw.int - 1, bounds.yh.int - 1) self.buffer.setBackgroundColor(bgNone) -proc drawRect(self: TerminalPlatform, bounds: Rect, color: chroma.Color) = - let mask = if self.masks.len > 0: - self.masks[self.masks.high] - else: - rect(vec2(0, 0), self.size) +# proc drawRect(self: TerminalPlatform, bounds: Rect, color: chroma.Color) = +# let mask = if self.masks.len > 0: +# self.masks[self.masks.high] +# else: +# rect(vec2(0, 0), self.size) - let bounds = bounds and mask +# let bounds = bounds and mask - self.setBackgroundColor(color) - self.buffer.drawRect(bounds.x.int, bounds.y.int, bounds.xw.int - 1, bounds.yh.int - 1) - self.buffer.setBackgroundColor(bgNone) +# self.setBackgroundColor(color) +# self.buffer.drawRect(bounds.x.int, bounds.y.int, bounds.xw.int - 1, bounds.yh.int - 1) +# self.buffer.setBackgroundColor(bgNone) proc writeLine(self: TerminalPlatform, pos: Vec2, text: string) = let mask = if self.masks.len > 0: diff --git a/src/platform/widget_builder_ast_document.nim b/src/platform/widget_builder_ast_document.nim index 0b8274e7..166e857a 100644 --- a/src/platform/widget_builder_ast_document.nim +++ b/src/platform/widget_builder_ast_document.nim @@ -1,5 +1,5 @@ import std/[strformat, tables, sugar] -import util, app, app_interface, config_provider, document_editor, ast_document, ast, node_layout, compiler, text/text_document, custom_logger, platform, theme +import util, app, config_provider, document_editor, ast_document, ast, node_layout, compiler, text/text_document, custom_logger, platform, theme import widget_builders_base, widget_library, ui/node import vmath, bumpy, chroma @@ -36,42 +36,42 @@ import vmath, bumpy, chroma # typeWidget.anchor.max.x = 1 # widget.add(typeWidget) -proc updateBaseIndexAndScrollOffset(self: AstDocumentEditor, app: App, height: float) = - let totalLineHeight = app.platform.totalLineHeight - self.previousBaseIndex = self.previousBaseIndex.clamp(0..self.document.rootNode.len) +# proc updateBaseIndexAndScrollOffset(self: AstDocumentEditor, app: App, height: float) = +# let totalLineHeight = app.platform.totalLineHeight +# self.previousBaseIndex = self.previousBaseIndex.clamp(0..self.document.rootNode.len) - let selectedNodeId = self.node.id +# let selectedNodeId = self.node.id - var replacements = initTable[Id, VisualNode]() +# var replacements = initTable[Id, VisualNode]() - let indent = getOption[float32](app, "ast.indent", 20) - let inlineBlocks = getOption[bool](app, "ast.inline-blocks", false) - let verticalDivision = getOption[bool](app, "ast.vertical-division", false) +# let indent = getOption[float32](app, "ast.indent", 20) +# let inlineBlocks = getOption[bool](app, "ast.inline-blocks", false) +# let verticalDivision = getOption[bool](app, "ast.vertical-division", false) - # Adjust scroll offset and base index so that the first node on screen is the base - while self.scrollOffset < 0 and self.previousBaseIndex + 1 < self.document.rootNode.len: - let input = ctx.getOrCreateNodeLayoutInput NodeLayoutInput(node: self.document.rootNode[self.previousBaseIndex], selectedNode: selectedNodeId, replacements: replacements, revision: config.revision, measureText: (t) => self.app.platform.measureText(t), indent: indent, renderDivisionVertically: verticalDivision, inlineBlocks: inlineBlocks) - let layout = ctx.computeNodeLayout(input) +# # Adjust scroll offset and base index so that the first node on screen is the base +# while self.scrollOffset < 0 and self.previousBaseIndex + 1 < self.document.rootNode.len: +# let input = ctx.getOrCreateNodeLayoutInput NodeLayoutInput(node: self.document.rootNode[self.previousBaseIndex], selectedNode: selectedNodeId, replacements: replacements, revision: config.revision, measureText: (t) => self.app.platform.measureText(t), indent: indent, renderDivisionVertically: verticalDivision, inlineBlocks: inlineBlocks) +# let layout = ctx.computeNodeLayout(input) - if self.scrollOffset + layout.bounds.h + totalLineHeight >= height: - break +# if self.scrollOffset + layout.bounds.h + totalLineHeight >= height: +# break - self.previousBaseIndex += 1 - self.scrollOffset += layout.bounds.h + totalLineHeight +# self.previousBaseIndex += 1 +# self.scrollOffset += layout.bounds.h + totalLineHeight - # Adjust scroll offset and base index so that the first node on screen is the base - while self.scrollOffset > height and self.previousBaseIndex > 0: - let input = ctx.getOrCreateNodeLayoutInput NodeLayoutInput(node: self.document.rootNode[self.previousBaseIndex - 1], selectedNode: selectedNodeId, replacements: replacements, revision: config.revision, measureText: (t) => self.app.platform.measureText(t), indent: indent, renderDivisionVertically: verticalDivision, inlineBlocks: inlineBlocks) - let layout = ctx.computeNodeLayout(input) +# # Adjust scroll offset and base index so that the first node on screen is the base +# while self.scrollOffset > height and self.previousBaseIndex > 0: +# let input = ctx.getOrCreateNodeLayoutInput NodeLayoutInput(node: self.document.rootNode[self.previousBaseIndex - 1], selectedNode: selectedNodeId, replacements: replacements, revision: config.revision, measureText: (t) => self.app.platform.measureText(t), indent: indent, renderDivisionVertically: verticalDivision, inlineBlocks: inlineBlocks) +# let layout = ctx.computeNodeLayout(input) - if self.scrollOffset - layout.bounds.h <= 0: - break +# if self.scrollOffset - layout.bounds.h <= 0: +# break - self.previousBaseIndex -= 1 - self.scrollOffset -= layout.bounds.h + totalLineHeight +# self.previousBaseIndex -= 1 +# self.scrollOffset -= layout.bounds.h + totalLineHeight proc renderVisualNode*(self: AstDocumentEditor, builder: UINodeBuilder, app: App, node: VisualNode, selected: AstNode, bounds: Rect, offset: Vec2) = - let charWidth = app.platform.charWidth + # let charWidth = app.platform.charWidth # echo "renderVisualNode ", node @@ -148,8 +148,8 @@ proc renderVisualNode*(self: AstDocumentEditor, builder: UINodeBuilder, app: App # widget.insert(0, panel) proc renderVisualNodeLayout*(self: AstDocumentEditor, builder: UINodeBuilder, app: App, node: AstNode, bounds: Rect, layout: NodeLayout, offset: Vec2, y: float) = - let totalLineHeight = app.platform.totalLineHeight - let charWidth = app.platform.charWidth + # let totalLineHeight = app.platform.totalLineHeight + # let charWidth = app.platform.charWidth self.lastLayouts.add (layout, offset) @@ -375,7 +375,6 @@ proc createAstUI*(self: AstDocumentEditor, builder: UINodeBuilder, app: App, con var selectedNode = self.node - let totalLineHeight = builder.textHeight let indent = getOption[float32](app, "ast.indent", 20) let inlineBlocks = getOption[bool](app, "ast.inline-blocks", false) let verticalDivision = getOption[bool](app, "ast.vertical-division", false) diff --git a/src/platform/widget_builder_model_document.nim b/src/platform/widget_builder_model_document.nim index c7d741bb..a40e0a44 100644 --- a/src/platform/widget_builder_model_document.nim +++ b/src/platform/widget_builder_model_document.nim @@ -320,7 +320,7 @@ proc createCompletions(self: ModelDocumentEditor, builder: UINodeBuilder, app: A let backgroundColor = app.theme.color("panel.background", color(30/255, 30/255, 30/255)) let selectedBackgroundColor = app.theme.color("list.activeSelectionBackground", color(200/255, 200/255, 200/255)) - let docsColor = app.theme.color("editor.foreground", color(1, 1, 1)) + # let docsColor = app.theme.color("editor.foreground", color(1, 1, 1)) let nameColor = app.theme.tokenColor(@["entity.name.label", "entity.name"], color(1, 1, 1)) let scopeColor = app.theme.color("string", color(175/255, 1, 175/255)) diff --git a/src/platform/widget_builder_selector_popup.nim b/src/platform/widget_builder_selector_popup.nim index eb6f70ef..c43e449a 100644 --- a/src/platform/widget_builder_selector_popup.nim +++ b/src/platform/widget_builder_selector_popup.nim @@ -23,7 +23,7 @@ method createUI*(self: ThemeSelectorItem, builder: UINodeBuilder, app: App): seq builder.panel(&{FillX, SizeToContentY, DrawText}, text = self.path, textColor = textColor) method createUI*(self: SelectorPopup, builder: UINodeBuilder, app: App): seq[proc() {.closure.}] = - let dirty = self.dirty + # let dirty = self.dirty self.resetDirty() var flags = &{UINodeFlag.MaskContent, OverlappingChildren} @@ -65,9 +65,6 @@ method createUI*(self: SelectorPopup, builder: UINodeBuilder, app: App): seq[pro self.scrollOffset = max(self.selected - targetNumRenderedItems + 1, 0) lastRenderedIndex = min(self.scrollOffset + targetNumRenderedItems - 1, self.completions.high) - let numRenderedItems = max(lastRenderedIndex - self.scrollOffset + 1, 0) - - let textColor = app.theme.color("editor.foreground", color(225/255, 200/255, 200/255)).withAlpha(1) let backgroundColor = app.theme.color("panel.background", color(0.1, 0.1, 0.1)).withAlpha(1) let selectionColor = app.theme.color("list.activeSelectionBackground", color(0.8, 0.8, 0.8)).withAlpha(1) @@ -76,7 +73,6 @@ method createUI*(self: SelectorPopup, builder: UINodeBuilder, app: App): seq[pro builder.panel(&{FillX, SizeToContentY}): result.add self.textEditor.createUI(builder, app) - var top = 0.0 var widgetIndex = 0 for completionIndex in self.scrollOffset..lastRenderedIndex: defer: inc widgetIndex diff --git a/src/platform/widget_builder_text_document.nim b/src/platform/widget_builder_text_document.nim index 59f1a628..7e255cf2 100644 --- a/src/platform/widget_builder_text_document.nim +++ b/src/platform/widget_builder_text_document.nim @@ -306,7 +306,6 @@ proc createTextLines(self: TextDocumentEditor, builder: UINodeBuilder, app: App, let indentLevel = self.document.getIndentLevelForClosestLine(i) - var showingContext = false var wrapLine = wrapLines var i = i var backgroundColor = backgroundColor diff --git a/src/platform/widget_library.nim b/src/platform/widget_library.nim index fffb8fd8..f90d64ef 100644 --- a/src/platform/widget_library.nim +++ b/src/platform/widget_library.nim @@ -1,5 +1,5 @@ import std/[strformat, strutils] -import document, workspaces/workspace, ui/node +import document, ui/node import chroma template createHeader*(builder: UINodeBuilder, inRenderHeader: bool, inMode: string, inDocument: Document, inHeaderColor: Color, inTextColor: Color, body: untyped): UINode = diff --git a/src/query_system.nim b/src/query_system.nim index 4c6cb906..0a71dcf4 100644 --- a/src/query_system.nim +++ b/src/query_system.nim @@ -21,8 +21,6 @@ when defined(js): proc newCache[K, V](capacity: int): Cache[K, V] {.importjs: "(new Map())".} proc mapKeyJs*[A](key: A): cstring = - static: - echo "#### '", A, "'" const typeName = $A {.emit: ["let temp = ", key, ";"].} # @note: This assumes that the object doesn't actuall change so the generated id can be cached diff --git a/src/scripting/scripting_nim.nim b/src/scripting/scripting_nim.nim index 7c6ee4ee..da944aa1 100644 --- a/src/scripting/scripting_nim.nim +++ b/src/scripting/scripting_nim.nim @@ -207,7 +207,7 @@ proc myFindNimStdLib(): string = ## Returns "" on failure. let customNimStdLib = getAppDir() / "scripting" / "nim" / "lib" - if existsDir(customNimStdLib): + if dirExists(customNimStdLib): log lvlInfo, fmt"Using custom nim std lib '{customNimStdLib}'" return customNimStdLib diff --git a/src/scripting/scripting_wasm.nim b/src/scripting/scripting_wasm.nim index 5130928b..32675734 100644 --- a/src/scripting/scripting_wasm.nim +++ b/src/scripting/scripting_wasm.nim @@ -134,6 +134,7 @@ method handleScriptAction*(self: ScriptContextWasm, name: string, args: JsonNode # because this goes through all exposed functions at compile time to create the wasm import data. # That's why it's in a template template createEditorWasmImportConstructor*() = + import std/[macrocache] proc createEditorWasmImportsImpl(): WasmImports = macro addEditorFunctions(imports: WasmImports): untyped = var list = nnkStmtList.newTree() diff --git a/src/selector_popup.nim b/src/selector_popup.nim index c68897ff..a3bac4c3 100644 --- a/src/selector_popup.nim +++ b/src/selector_popup.nim @@ -1,4 +1,4 @@ -import std/[strutils, sugar, options, json, streams, random] +import std/[strutils, sugar, options, json, streams] import bumpy, vmath import app_interface, text/text_editor, popup, events, util, rect_utils, scripting/expose, event, input, custom_async, custom_logger, cancellation_token, myjsonutils import comb_sort, timer diff --git a/src/text/text_document.nim b/src/text/text_document.nim index 840acb8f..0774724e 100644 --- a/src/text/text_document.nim +++ b/src/text/text_document.nim @@ -1,4 +1,4 @@ -import std/[os, strutils, sequtils, sugar, options, json, strformat, tables, sets] +import std/[os, strutils, sequtils, sugar, options, json, strformat, tables] import scripting_api except DocumentEditor, TextDocumentEditor, AstDocumentEditor from scripting_api as api import nil import patty, bumpy diff --git a/src/timer.nim b/src/timer.nim index d2381f2d..3cb9eb21 100644 --- a/src/timer.nim +++ b/src/timer.nim @@ -1,6 +1,4 @@ -when not defined(nimscript): - include system/timers -else: +when defined(nimscript): type Ticks* = distinct int64 Nanos* = int64 @@ -41,6 +39,7 @@ else: result.nanosecond = 0 else: + include system/timers import std/times export Ticks, Nanos proc myGetTime*(): int32 = getTime().toUnix.int32 diff --git a/src/util.nim b/src/util.nim index b7cd3267..1853755f 100644 --- a/src/util.nim +++ b/src/util.nim @@ -1,4 +1,4 @@ -import std/[options, strutils, macros, genasts, math] +import std/[options, strutils, macros, genasts] export options {.used.} @@ -110,4 +110,5 @@ when defined(js): func roundPositive*[T: float64 | float32](x: T): T = jsRound(x) else: + import std/math func roundPositive*[T: float64 | float32](x: T): T = round(x) \ No newline at end of file