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

[EXPERIMENT] linenoise (antirez/linenoise + msteveb/linenoise) #1742

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
- {name: "Linux (amd64 / mini)", os: ubuntu-latest, arch: amd64, mode: mini, shell: bash}
- {name: "Linux (arm64 / mini)", os: ubuntu-latest, arch: arm64, mode: mini, shell: bash}
- {name: "JS (web / mini)", os: ubuntu-latest, arch: amd64, mode: web, shell: bash}
- {name: "Windows (amd64 / full)", os: windows-latest, arch: amd64, mode: full, shell: "msys2 {0}"}
- {name: "Windows (amd64 / mini)", os: windows-latest, arch: amd64, mode: mini, shell: "msys2 {0}"}
#- {name: "Windows (amd64 / full)", os: windows-latest, arch: amd64, mode: full, shell: "msys2 {0}"}
#- {name: "Windows (amd64 / mini)", os: windows-latest, arch: amd64, mode: mini, shell: "msys2 {0}"}
- {name: "macOS (amd64 / full)", os: macOS-12, arch: amd64, mode: full, shell: bash}
- {name: "macOS (amd64 / mini)", os: macOS-12, arch: amd64, mode: mini, shell: bash}
- {name: "macOS (arm64 / full)", os: macos-latest, arch: arm64, mode: full, shell: bash}
Expand Down Expand Up @@ -106,4 +106,4 @@ jobs:
uses: 'actions/upload-artifact@v4'
with:
name: ${{ steps.artifact-details.outputs.ARTIFACT_NAME }}
path: ${{ steps.artifact-details.outputs.BINARY_PATH }}
path: ${{ steps.artifact-details.outputs.BINARY_PATH }}
10 changes: 5 additions & 5 deletions src/extras/linenoise.nim
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ type
len*: csize_t
cvec*: cstringArray

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

#=======================================
# Function prototypes
#=======================================

{.push header: "linenoise/linenoise.h", cdecl.}

proc linenoiseSetCompletionCallback*(cback: LinenoiseCompletionCallback, userdata: pointer): LinenoiseCompletionCallback {.importc: "linenoiseSetCompletionCallback".}
proc linenoiseSetHintsCallback*(callback: LinenoiseHintsCallback, userdata: pointer) {.importc: "linenoiseSetHintsCallback".}
proc linenoiseSetCompletionCallback*(cback: LinenoiseCompletionCallback) {.importc: "linenoiseSetCompletionCallback".}
proc linenoiseSetHintsCallback*(callback: 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.}
Expand Down
4 changes: 3 additions & 1 deletion src/extras/linenoise/linenoise-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ static int fd_read(struct current *current)
return SPECIAL_PAGE_UP;
case VK_NEXT:
return SPECIAL_PAGE_DOWN;
case VK_RETURN:
return k->uChar.UnicodeChar;
}
}
/* Note that control characters are already translated in AsciiChar */
Expand Down Expand Up @@ -374,4 +376,4 @@ static int getWindowSize(struct current *current)
current->y = info.dwCursorPosition.Y;
current->x = info.dwCursorPosition.X;
return 0;
}
}
Loading
Loading