Re: nimsuggest and --threads:on
For me `undeclared identifier` issue happens with `async` function too
Re: LSP client for VSCode
Yes it is in my PATH nimlsp --version nimlsp v0.2.4
LSP client for VSCode
I've installed [vscode-nim-lsp](https://github.com/bung87/vscode-nim-lsp) and [nimslp](https://github.com/PMunch/nimlsp) but it doesn't seems to work. (auto-completion, linting, hover, F2, F12, etc... doesn't work) I tried to make one but I couldn't make it work because of my limited knowledge of LSP and programing in general. Does anyone have plan to make lsp client for vscode? Also, I'm very curious about how symbol `renaming`, `reference searching` and `auto-completion` will work with macro. For example: import strformat var hi = "hi" #___^ does renaming this variable will also change echo &"{hi}" #___^ this too? Run
Re: Unicode support for Windows 10 console
> Input of strings of any length is supported. I can't add more characters beyond this.
Re: Unicode support for Windows 10 console
Thanks for the detailed explanation! `stdin.readLine() # <- Error: unhandled exception: EOF reached [EOFError]` However this error still occurs when using the `fgetws` version. (win api version works as expected.)
Re: Unicode support for Windows 10 console
import console let input = consoleReadLine() # <- Works great! consoleEcho input # <- Works great! Run I think this needs to be in the standard module because using `console.nim` breaks std functions: (at least for me.) stdout.write "something" # <- Error: unhandled exception: index -1 not in ... echo "something" # <- Error: unhandled exception: index -1 not in ... let stdinput = stdin.readLine() # <- Error: unhandled exception: EOF reached [EOFError] Run
Re: Unicode support for Windows 10 console
# console.nim when defined(windows): import system/widestrs proc setMode(fd: int, mode: int): int {.importc: "_setmode", header: "io.h".} proc fgetws(str: WideCString, numChars: int, stream: File): bool {.importc, header: "stdio.h".} discard setMode(getFileHandle(stdin), 0x0002) # _O_U16TEXT proc consoleReadLine*(line: var string): bool = let buffer = newWideCString("", 256) result = fgetws(buffer, 256, stdin) let length = buffer.len if length > 0 and buffer[length - 1].int16 == 10: # discard '\n' buffer[length - 1] = Utf16Char(0) # discard extra '\n' in waiting: let buffer2 = newWideCString("", 2) discard fgetws(buffer2, 2, stdin) line = $buffer proc consoleReadLine*(): string = discard consoleReadLine(result) else: proc consoleReadLine*(line: var string): bool = result = stdin.readLine(line) proc consoleReadLine*(): string = result = stdin.readLine() Run ^ when using "nim c" ^ when using "nim c --gc:arc" hmm it outputs (bytes: 1026, data: input) instead of string itself when using --gc:arc
Re: Unicode support for Windows 10 console
Is checking fgetws result unnecessary? proc consoleReadLine*(line: var string): bool = let buffer = newWideCString("", 256) result = fgetws(buffer, 256, stdin) if result: let length = buffer.len if length > 0 and buffer[length - 1].int16 == 10: #discard '\n' buffer[length - 1] = Utf16Char(0) # discard extra '\n' in waiting: let buffer2 = newWideCString("", 2) discard fgetws(buffer2, 2, stdin) line = $buffer else: line = "" Run
Re: Unicode support for Windows 10 console
That's very cool! however let a = consoleReadLine() echo a let b = consoleReadLine() echo b Run if I run this code and press enter echo b also gets executed.
Re: Unicode support for Windows 10 console
vs code theme: [https://marketplace.visualstudio.com/items?itemName=GulajavaMinistudio.mayukaithemevsc](https://marketplace.visualstudio.com/items?itemName=GulajavaMinistudio.mayukaithemevsc)
Re: Unicode support for Windows 10 console
I found this froum thread helpful [https://forum.nim-lang.org/t/3898](https://forum.nim-lang.org/t/3898)
Calling proc with [() -> void] as a last parameter
import std/sugar # if [() -> void] is a last parameter of a proc you can do this(?) proc lambdaTest(a: int, lambdaProc: () -> void) = lambdaProc() lambdaTest(1): echo "[() -> void] as the last parameter." Run Just curious How does ":" syntax work?
Re: Unicode support for Windows 10 console
I think I soved this issue(?) # winconsole.nim when system.hostOS == "windows": import std/winlean import std/unicode proc readConsoleW(hConsoleInput: Handle, lpBuffer: pointer, nNumberOfCharsToRead: int, lpNumberOfCharsRead: pointer, pInputControl: pointer): bool {.stdcall, dynlib: "kernel32", importc: "ReadConsoleW".} var readBuff: array[256, uint16] var readCount: uint32 proc consoleInputToString(readBuff: array[256, uint16]): string = for i in 0..
Re: Unicode support for Windows 10 console
@ktamp Using your solution fixes Korean but it will still break if I use other languages. (ie: Japanese) Is there any "global" solution for this problem?
Re: Unicode support for Windows 10 console
> You did use "-d:nimDontSetUtf8CodePage" parameter for building your > executable, didn't you? yes I used -d:nimDontSetUtf8CodePage for building. > What is your "Current language for non-Unicode programs" in Windows? > (Settings -> Time & Language -> Date, time, & regional formatting -> > Additional date, time , & regional settings -> Change date, time, or number > formats -> Administrative) I hope you do not have "Beta: Use Unicode UTF-8 > for worldwide language support" enabled (also in Administrative tab). those things should not matter because unicode input using c# console app is working perfectly in my computer. > After running nim to compile your code, did you close and reopen cmd (or > Windows PowerShell)? Because running nim sets code-page to 65001. I didn't reopen cmd.
Re: Unicode support for Windows 10 console
@ktamp I have a same issue. (can't read unicode input from windows console) I used your console.nim but it doesn't work. i've encountered a very similar issue with zig. [https://github.com/ziglang/zig/issues/5148](https://github.com/ziglang/zig/issues/5148) maybe it's relevant?
Help: Zip (Creating / Opening)
I want to do Something like this. How can I do this in Nim? // PATH_FILE_Zip = Path of a Zip file // Read Zip File's Content Without Unzipping using (ZipArchive zip = ZipFile.Open(PATH_FILE_Zip, ZipArchiveMode.Read)) { // Order by File Name List entries = zip.Entries.OrderBy(c => c.Name.Length).ThenBy(c => c.Name).ToList(); for (int i = 0; i < entries.Count; i++) { using (StreamReader reader = new StreamReader(entries[order[i]].Open(), Encoding.UTF8)) { } } } Run // Create Temp Folder const string PATH_DIR_Data = Path.Combine(PATH_DIR_Root, "DATA-Temp"); Directory.CreateDirectory(PATH_DIR_Data); // Delete Old Zip File File.Delete(PATH_FILE_Zip); // Create Zip File Console.WriteLine("Creating Zip File..."); ZipFile.CreateFromDirectory(PATH_DIR_Data, PATH_FILE_Zip); // Delete Temp Folder Directory.Delete(PATH_DIR_Data, true); Run
Learning & Using Nim as a C# user + Fan logo Redesign
I'm not a programmer, but I'm currently using C# and Unity to make games as a hobby. And I recently discovered this fantastic language! I really want to make games with this lovely language but as an intermediate C# user I can't make a Game Engine by myself * * * So my Questions are: 1. Any Learning resource targeted at C# user? (comparison, difference, equivalent, etc...) 2. Any Korean Learning resource? (I'm not very good at English ) 3. Is there any Good Game Engine for Nim? (maybe Godot? [https://github.com/pragmagic/godot-nim](https://github.com/pragmagic/godot-nim) <\- is it actually usable and better than C# or GD Script?) 4. Is there any UI app Framework beside using web app? 5. How do I Debug in VS Code? 6. Is VS Code the best editor for Nim? (I'm using Windows) 7. I'm not going to make a Game Engine, but is it possible to use 3d Graphics Library? (maybe directX or Vulkan? _just curious :)_ ) # Fan logo Redesign * * * I actually don't think Nim needs to change a logo. I did a logo redesign just for fun! (Inspired by Gitlab Logo)