Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows REPL + LineNoise #400

Merged
merged 36 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ca0eeeb
attempt to forcefully re-enable linenoise for Windows (and see what h…
drkameleon Jan 15, 2022
5f76082
we have to remove this conditional directive too in order to test Win…
drkameleon Jan 15, 2022
989f513
build update
drkameleon Jan 15, 2022
08ea0d9
build update
drkameleon Jan 15, 2022
41d4e6b
force compile `linenoise.c` on Windows builds (apparantly it's not au…
drkameleon Jan 15, 2022
5ff0e9a
Merge branch 'master' of https://github.com/arturo-lang/arturo into r…
drkameleon Jan 15, 2022
c276873
no message
drkameleon Mar 4, 2022
2c22a52
Revert "attempt to forcefully re-enable linenoise for Windows (and se…
drkameleon Mar 4, 2022
a8b1baf
Revert "we have to remove this conditional directive too in order to …
drkameleon Mar 4, 2022
587089b
Revert "force compile `linenoise.c` on Windows builds (apparantly it'…
drkameleon Mar 4, 2022
ff88e56
Revert "updated Nim version (`1.4.0`->`1.6.2`) for Windows builds"
drkameleon Mar 4, 2022
c397677
Merge branch 'master' of https://github.com/arturo-lang/arturo into r…
drkameleon Mar 4, 2022
9180144
build update
drkameleon Mar 4, 2022
4cf9280
build update
drkameleon Mar 4, 2022
2f910d3
fix `input` (and REPL-related input) for WIndows - so that at least i…
drkameleon Mar 4, 2022
98eabdd
build update
drkameleon Mar 4, 2022
bd4932d
integrate Win-enabled linenoise library
drkameleon Mar 4, 2022
0d2b0db
Io: re-enable `input` command (with `.repl`) for Windows
drkameleon Mar 4, 2022
24cfd48
do import helpers/repl even for Windows
drkameleon Mar 4, 2022
669a0d1
Helpers/repl: fix paths for Windows
drkameleon Mar 4, 2022
0c3d4e6
replace with `normalizedPath`
drkameleon Mar 4, 2022
89e8cb7
build update
drkameleon Mar 4, 2022
06da0b7
build update
drkameleon Mar 4, 2022
b5436ae
build update
drkameleon Mar 4, 2022
fe96d2d
unify linenoise wrapper implementation (same wrapper for Windows & Ma…
drkameleon Mar 4, 2022
0eebd4c
remove unused imports
drkameleon Mar 4, 2022
f9bf0f7
build update
drkameleon Mar 4, 2022
b4f6882
added missing files for new-style linenoise implementation
drkameleon Mar 4, 2022
2c940e2
added (yet another) missing file for Windows linenoise implementation
drkameleon Mar 4, 2022
c281123
add header search path
drkameleon Mar 4, 2022
4c56f42
build update
drkameleon Mar 4, 2022
f514495
added missing dependency
drkameleon Mar 4, 2022
f00477d
explicitly add header path to compiled C source
drkameleon Mar 4, 2022
747145f
add include paths for every single one of the C sources
drkameleon Mar 4, 2022
f9e9b75
fix minor typo
drkameleon Mar 4, 2022
dc6af07
minor fixes to make new-style library uniform
drkameleon Mar 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/extras/linenoise.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
when defined(windows):
import os

{.passC: "-I" & parentDir(currentSourcePath()) .}

{.compile("linenoise/linenoise.c", "-I" & parentDir(currentSourcePath())).}
{.compile("linenoise/stringbuf.c", "-I" & parentDir(currentSourcePath())).}
{.compile("linenoise/utf8.c", "-I" & parentDir(currentSourcePath())).}

#=======================================
# Types
#=======================================

type
LinenoiseCompletions* = object
len*: csize_t
cvec*: cstringArray

LinenoiseCompletionCallback* = proc (buf: cstring; lc: ptr LinenoiseCompletions) {.cdecl.}
LinenoiseHintsCallback* = proc (buf: cstring; color: var cint; bold: var cint): cstring {.cdecl.}
LinenoiseFreeHintsCallback* = proc (buf: cstring; color: var cint; bold: var cint) {.cdecl.}


#=======================================
# C Imports
#=======================================

when defined(windows):
{.push header: "linenoise/linenoise.h", cdecl.}
proc linenoiseSetCompletionCallback*(cback: ptr LinenoiseCompletionCallback) {.importc: "linenoiseSetCompletionCallback".}
proc linenoiseSetHintsCallback*(cback: ptr LinenoiseHintsCallback) {.importc: "linenoiseSetHintsCallback".}
proc linenoiseAddCompletion*(a2: ptr LinenoiseCompletions; a3: cstring) {.importc: "linenoiseAddCompletion".}
proc linenoiseReadLine*(prompt: cstring): cstring {.importc: "linenoise".}
proc linenoiseHistoryAdd*(line: cstring): cint {.importc: "linenoiseHistoryAdd", discardable.}
proc linenoiseHistorySetMaxLen*(len: cint): cint {.importc: "linenoiseHistorySetMaxLen".}
proc linenoiseHistorySave*(filename: cstring): cint {.importc: "linenoiseHistorySave".}
proc linenoiseHistoryLoad*(filename: cstring): cint {.importc: "linenoiseHistoryLoad".}
proc linenoiseClearScreen*() {.importc: "linenoiseClearScreen".}
proc linenoiseSetMultiLine*(ml: cint) {.importc: "linenoiseSetMultiLine".}
proc linenoisePrintKeyCodes*() {.importc: "linenoisePrintKeyCodes".}
when defined(windows):
{.pop.}
proc free*(s: cstring) {.importc: "free", header: "<stdlib.h>".}
Loading