From 3c36d902f7ada420b0aabef70034f4ff70823964 Mon Sep 17 00:00:00 2001 From: lilkeet Date: Mon, 18 Nov 2024 04:12:27 -0800 Subject: [PATCH 1/9] fully qualify nim compiler import paths --- api.nim | 2 +- buffer.nim | 2 +- buffertype.nim | 2 +- nimedit.nim | 5 ++++- nimscriptsupport.nim | 16 ++++++++-------- overviews.nim | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/api.nim b/api.nim index 22cdafd..75755ce 100644 --- a/api.nim +++ b/api.nim @@ -2,7 +2,7 @@ # List only the imports that the main file doesn't already import here: import - compiler/ast, compiler/vm, compiler/vmdef, + std/../../compiler/[ast, vm, vmdef], nimscriptsupport proc setupApi(result: PEvalContext; sh: SharedState) = diff --git a/buffer.nim b/buffer.nim index 18d9852..661ccd6 100644 --- a/buffer.nim +++ b/buffer.nim @@ -1,6 +1,6 @@ # Implementation uses a gap buffer with explicit undo stack. -import strutils, unicode, intsets, compiler/ast, tables +import strutils, unicode, intsets, std/../../compiler/ast, tables import styles, highlighters, nimscript/common, themes import sdl2, sdl2/ttf, prims import buffertype, unihelp, languages diff --git a/buffertype.nim b/buffertype.nim index 1a2c0f0..a5183b7 100644 --- a/buffertype.nim +++ b/buffertype.nim @@ -1,5 +1,5 @@ -import styles, nimscript/common, intsets, compiler/ast, tables +import styles, nimscript/common, intsets, std/../../compiler/ast, tables from times import Time from sdl2 import Rect diff --git a/nimedit.nim b/nimedit.nim index 71b1062..c798f8b 100644 --- a/nimedit.nim +++ b/nimedit.nim @@ -15,7 +15,7 @@ import nimscript/common, nimscript/keydefs, languages, themes, nimscriptsupport, tabbar, finder, scrollbar, indexer, overviews, nimsuggestclient, minimap -import compiler / pathutils +import std/../../compiler / pathutils when defined(windows): import dialogs @@ -1219,11 +1219,14 @@ proc mainProc(ed: Editor) = freeFonts sh.fontM destroy ed + +echo 2222 if sdl2.init(INIT_VIDEO) != SdlSuccess: echo "SDL_Init" elif ttfInit() != SdlSuccess: echo "TTF_Init" else: + echo 1 startTextInput() mainProc(Editor()) sdl2.quit() diff --git a/nimscriptsupport.nim b/nimscriptsupport.nim index e68d59e..e5e885e 100644 --- a/nimscriptsupport.nim +++ b/nimscriptsupport.nim @@ -1,20 +1,20 @@ import - compiler/ast, compiler/modules, compiler/passes, - compiler/condsyms, compiler/options, - compiler/llstream, compiler/vm, compiler/vmdef, - compiler/magicsys, compiler/idents, - compiler/modulegraphs, compiler/pathutils + std/../../compiler/[ast, modules, passes, + condsyms, options, + llstream, vm, vmdef, + magicsys, idents, + modulegraphs, pathutils] when NimMajor >= 2: import - compiler/pipelines, compiler/commands + std/../../compiler/[pipelines, commands] else: import - compiler/sem + std/../../compiler/sem -from compiler/scriptconfig import setupVM +from std/../../compiler//scriptconfig import setupVM import os, strutils import themes, styles, nimscript/common diff --git a/overviews.nim b/overviews.nim index 4835539..f074b59 100644 --- a/overviews.nim +++ b/overviews.nim @@ -4,7 +4,7 @@ import buffertype, buffer import parseutils, strutils, intsets, nimscriptsupport, - compiler / [ast, idents, parser, astalgo, renderer, + std/../../compiler / [ast, idents, parser, astalgo, renderer, lineinfos, options] proc errorHandler(conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg: string) = From 619e2a0ab2af7621493c717b249995250ecb90cc Mon Sep 17 00:00:00 2001 From: lilkeet Date: Mon, 18 Nov 2024 04:45:35 -0800 Subject: [PATCH 2/9] implement choosnim installation location on windows --- nimscriptsupport.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nimscriptsupport.nim b/nimscriptsupport.nim index e5e885e..828a227 100644 --- a/nimscriptsupport.nim +++ b/nimscriptsupport.nim @@ -122,7 +122,13 @@ proc detectNimLib(): string = result = nimexe.expandSymlink.splitPath()[0] /../ "lib" except OSError: result = getHomeDir() / ".choosenim/toolchains/nim-" & NimVersion / "lib" + elif defined(windows): + result = getHomeDir() / ".choosenim/toolchains/nim-" & NimVersion / "lib" + else: + # TODO + {.error: "not implemented".} if not fileExists(result / "system.nim"): + echo result quit "cannot find Nim's stdlib location" when not defined(release): echo result From 4c737442798dfca8f72b2dafbabf5bbdc9901bde Mon Sep 17 00:00:00 2001 From: lilkeet Date: Sun, 17 Nov 2024 23:54:03 -0600 Subject: [PATCH 3/9] cleanup debug echo stmts --- nimedit.nim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nimedit.nim b/nimedit.nim index c798f8b..0e210b6 100644 --- a/nimedit.nim +++ b/nimedit.nim @@ -1220,13 +1220,12 @@ proc mainProc(ed: Editor) = destroy ed -echo 2222 + if sdl2.init(INIT_VIDEO) != SdlSuccess: echo "SDL_Init" elif ttfInit() != SdlSuccess: echo "TTF_Init" else: - echo 1 startTextInput() mainProc(Editor()) sdl2.quit() From a82610f387cc984e1931fd70c583d30af70214d2 Mon Sep 17 00:00:00 2001 From: lilkeet Date: Mon, 2 Dec 2024 17:34:03 -0600 Subject: [PATCH 4/9] change nim/compiler import path per https://github.com/Araq/nimedit/pull/30#issuecomment-2485195046 --- api.nim | 2 +- buffer.nim | 2 +- buffertype.nim | 2 +- nimedit.nim | 2 +- nimscriptsupport.nim | 8 ++++---- overviews.nim | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api.nim b/api.nim index 75755ce..bf27e20 100644 --- a/api.nim +++ b/api.nim @@ -2,7 +2,7 @@ # List only the imports that the main file doesn't already import here: import - std/../../compiler/[ast, vm, vmdef], + compiler/[ast, vm, vmdef], nimscriptsupport proc setupApi(result: PEvalContext; sh: SharedState) = diff --git a/buffer.nim b/buffer.nim index 661ccd6..18d9852 100644 --- a/buffer.nim +++ b/buffer.nim @@ -1,6 +1,6 @@ # Implementation uses a gap buffer with explicit undo stack. -import strutils, unicode, intsets, std/../../compiler/ast, tables +import strutils, unicode, intsets, compiler/ast, tables import styles, highlighters, nimscript/common, themes import sdl2, sdl2/ttf, prims import buffertype, unihelp, languages diff --git a/buffertype.nim b/buffertype.nim index a5183b7..1a2c0f0 100644 --- a/buffertype.nim +++ b/buffertype.nim @@ -1,5 +1,5 @@ -import styles, nimscript/common, intsets, std/../../compiler/ast, tables +import styles, nimscript/common, intsets, compiler/ast, tables from times import Time from sdl2 import Rect diff --git a/nimedit.nim b/nimedit.nim index 0e210b6..2aefa0a 100644 --- a/nimedit.nim +++ b/nimedit.nim @@ -15,7 +15,7 @@ import nimscript/common, nimscript/keydefs, languages, themes, nimscriptsupport, tabbar, finder, scrollbar, indexer, overviews, nimsuggestclient, minimap -import std/../../compiler / pathutils +import compiler / pathutils when defined(windows): import dialogs diff --git a/nimscriptsupport.nim b/nimscriptsupport.nim index 828a227..0b5fe75 100644 --- a/nimscriptsupport.nim +++ b/nimscriptsupport.nim @@ -1,6 +1,6 @@ import - std/../../compiler/[ast, modules, passes, + compiler/[ast, modules, passes, condsyms, options, llstream, vm, vmdef, magicsys, idents, @@ -8,13 +8,13 @@ import when NimMajor >= 2: import - std/../../compiler/[pipelines, commands] + compiler/[pipelines, commands] else: import - std/../../compiler/sem + compiler/sem -from std/../../compiler//scriptconfig import setupVM +from compiler/scriptconfig import setupVM import os, strutils import themes, styles, nimscript/common diff --git a/overviews.nim b/overviews.nim index f074b59..4835539 100644 --- a/overviews.nim +++ b/overviews.nim @@ -4,7 +4,7 @@ import buffertype, buffer import parseutils, strutils, intsets, nimscriptsupport, - std/../../compiler / [ast, idents, parser, astalgo, renderer, + compiler / [ast, idents, parser, astalgo, renderer, lineinfos, options] proc errorHandler(conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg: string) = From b877ed5b734f4af9cd88e743e8cb79a05565c0dd Mon Sep 17 00:00:00 2001 From: lilkeet Date: Mon, 2 Dec 2024 17:37:09 -0600 Subject: [PATCH 5/9] add nim config file per https://github.com/Araq/nimedit/pull/30#issuecomment-2485195046 --- nim.cfg | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 nim.cfg diff --git a/nim.cfg b/nim.cfg new file mode 100644 index 0000000..ee923fe --- /dev/null +++ b/nim.cfg @@ -0,0 +1,2 @@ + +--path: "$nim" From 26a6f085244a9bee97f461c366824a6462bfef33 Mon Sep 17 00:00:00 2001 From: lilkeet Date: Mon, 2 Dec 2024 17:45:09 -0600 Subject: [PATCH 6/9] add explanation comment --- nim.cfg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nim.cfg b/nim.cfg index ee923fe..7fa7a08 100644 --- a/nim.cfg +++ b/nim.cfg @@ -1,2 +1,5 @@ +# we need access to the compiler, so we'll switch our compilation path to its +# source: --path: "$nim" +# see https://nim-lang.org/docs/nimc.html#compiler-usage-commandminusline-switches From e66eb1bca621bf13a998c1b7758aedd25e4ddebc Mon Sep 17 00:00:00 2001 From: lilkeet Date: Tue, 3 Dec 2024 00:55:28 -0600 Subject: [PATCH 7/9] add dpi awareness --- nimedit.nim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nimedit.nim b/nimedit.nim index 2aefa0a..d4eeebb 100644 --- a/nimedit.nim +++ b/nimedit.nim @@ -678,7 +678,7 @@ proc createSdlWindow(ed: Editor; maximize: range[0u32 .. 1u32]) = let maximized = SDL_WINDOW_MAXIMIZED * maximize ed.window = createWindow(windowTitle, 10, 30, ed.screenW, ed.screenH, - SDL_WINDOW_RESIZABLE or maximized) + SDL_WINDOW_RESIZABLE or maximized or SDL_WINDOW_ALLOW_HIGHDPI) ed.window.getSize(ed.screenW, ed.screenH) ed.renderer = createRenderer(ed.window, -1, Renderer_Software) @@ -1220,8 +1220,10 @@ proc mainProc(ed: Editor) = destroy ed - -if sdl2.init(INIT_VIDEO) != SdlSuccess: +# no sdl2 hints defined? we'll just do them verbatim then +if setHint("SDL_WINDOWS_DPI_AWARENESS", "permonitorv2") != SdlSuccess: + echo "dpi failure" +elif sdl2.init(INIT_VIDEO) != SdlSuccess: echo "SDL_Init" elif ttfInit() != SdlSuccess: echo "TTF_Init" From 63e0a8f2d26ed0bf6225e60866569912f1c8594f Mon Sep 17 00:00:00 2001 From: lilkeet Date: Tue, 3 Dec 2024 00:31:54 -0600 Subject: [PATCH 8/9] Revert "add dpi awareness" to prepare for sync This reverts commit e66eb1bca621bf13a998c1b7758aedd25e4ddebc. --- nimedit.nim | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/nimedit.nim b/nimedit.nim index d4eeebb..2aefa0a 100644 --- a/nimedit.nim +++ b/nimedit.nim @@ -678,7 +678,7 @@ proc createSdlWindow(ed: Editor; maximize: range[0u32 .. 1u32]) = let maximized = SDL_WINDOW_MAXIMIZED * maximize ed.window = createWindow(windowTitle, 10, 30, ed.screenW, ed.screenH, - SDL_WINDOW_RESIZABLE or maximized or SDL_WINDOW_ALLOW_HIGHDPI) + SDL_WINDOW_RESIZABLE or maximized) ed.window.getSize(ed.screenW, ed.screenH) ed.renderer = createRenderer(ed.window, -1, Renderer_Software) @@ -1220,10 +1220,8 @@ proc mainProc(ed: Editor) = destroy ed -# no sdl2 hints defined? we'll just do them verbatim then -if setHint("SDL_WINDOWS_DPI_AWARENESS", "permonitorv2") != SdlSuccess: - echo "dpi failure" -elif sdl2.init(INIT_VIDEO) != SdlSuccess: + +if sdl2.init(INIT_VIDEO) != SdlSuccess: echo "SDL_Init" elif ttfInit() != SdlSuccess: echo "TTF_Init" From 65362c241fb10180ea6534539c178957a25a83e8 Mon Sep 17 00:00:00 2001 From: lilkeet Date: Tue, 3 Dec 2024 00:34:39 -0600 Subject: [PATCH 9/9] reapply e66eb1bca621bf13a998c1b7758aedd25e4ddebc --- nimedit.nim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nimedit.nim b/nimedit.nim index 2aefa0a..d4eeebb 100644 --- a/nimedit.nim +++ b/nimedit.nim @@ -678,7 +678,7 @@ proc createSdlWindow(ed: Editor; maximize: range[0u32 .. 1u32]) = let maximized = SDL_WINDOW_MAXIMIZED * maximize ed.window = createWindow(windowTitle, 10, 30, ed.screenW, ed.screenH, - SDL_WINDOW_RESIZABLE or maximized) + SDL_WINDOW_RESIZABLE or maximized or SDL_WINDOW_ALLOW_HIGHDPI) ed.window.getSize(ed.screenW, ed.screenH) ed.renderer = createRenderer(ed.window, -1, Renderer_Software) @@ -1220,8 +1220,10 @@ proc mainProc(ed: Editor) = destroy ed - -if sdl2.init(INIT_VIDEO) != SdlSuccess: +# no sdl2 hints defined? we'll just do them verbatim then +if setHint("SDL_WINDOWS_DPI_AWARENESS", "permonitorv2") != SdlSuccess: + echo "dpi failure" +elif sdl2.init(INIT_VIDEO) != SdlSuccess: echo "SDL_Init" elif ttfInit() != SdlSuccess: echo "TTF_Init"