vpet95 / prompt-sync-plus Goto Github PK
View Code? Open in Web Editor NEWA Node.js synchronous prompting library based on promp-sync
License: MIT License
A Node.js synchronous prompting library based on promp-sync
License: MIT License
The primary issue being: cleanup of displayed list + re-positioning of cursor doesn't work properly.
My suspicion here is that terminal cursor coordinates are relative to the terminal window view; if the number of suggested items is so high that its output causes the terminal to scroll, the x * y coordinates of the cursor just prior to the output are no longer correct. When this happens, search results that get pushed up above the "new" cursor position never get cleared out between keystrokes, leading to duplicate output.
A naïve fix I'd like to test is to save the cursor position prior to the output, then restore it after, but this is likely not going to work for the same reason mentioned above. (Bonus points: add up/down arrow key functionality to scroll through results)
Another thing I could try is truncating the list so it always only shows as many rows as can fit in the current terminal view (minus one row for a line indicating how many more are left off the screen).
Another question: can we detect terminal scroll events, and update our knowledge of the cursor position? Or is it subject to the same problem as the process.stdout.on("resize" () => {})
approach?
Another thought: add a maxRows
option to automatically truncate the list to some pre-defined number of rows regardless of whether the results fit on the screen.
Unable to call the constructor without an argument
import axios from 'axios';
import psp from "prompt-sync-plus";
const prompt = psp(); // Expected 1 argument got 0
const prompt = psp({ sigint: true });
Here it tells me it requires ALL the options of the Config
type
Looking at the type definitions, this is correct
declare type Config = {
autocomplete: {
behavior: AutocompleteBehavior;
fill: boolean;
searchFn?: (query: string) => string[];
sticky: boolean;
suggestColCount: number;
triggerKey: Key;
};
echo: string;
eot: boolean;
defaultResponse: string;
history?: PromptSyncHistoryObj;
sigint: boolean;
};
declare function PromptSyncPlus(config: Config | undefined): PromptType;
Should instead be somthing like:
declare type Config = {
autocomplete?: {
behavior: AutocompleteBehavior;
fill: boolean;
searchFn?: (query: string) => string[];
sticky: boolean;
suggestColCount: number;
triggerKey: Key;
};
echo?: string;
eot?: boolean;
defaultResponse?: string;
history?: PromptSyncHistoryObj;
sigint?: boolean;
};
declare function PromptSyncPlus(config?: Config): PromptType;
Greetings,
In Microsoft Windows Terminal, backspace do not delete character typed.
If let say I typed "one" and I backspaced once, the word maintain "one" but will be returned "on".
import psp from "promp-sync-plus;
const prompt = psp({sigint: true});
let testInput = prompt("Test input: ");
console.log(testInput)
Output:
PS C:\Users\Owner\Desktop> node test.js
Test input: one
on
PS C:\Users\Owner\Desktop>
Any help will be appreciated. Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.