cronvel / terminal-kit

Terminal utilities for node.js
MIT License
3.08k stars 198 forks source link

Unable to add left padding to singleLineMenu? #246

Open MisterSirCode opened 2 months ago

MisterSirCode commented 2 months ago

I noticed in the documentation, the multiline menu had a left padding option, but the single line menu does not.

Ive tried adding characters before it, but it doesnt move it at all..

I need to position this menu within a specific location, and its completely impossible as far as I can tell.

Adding space to the first item in the list does give me padding, but it obviously messes up the background color formatting :/

This is what Im stuck with right now:

image

It completely ruins the look of my project, so I was hoping there would be a fix for this or an alternative solution if someone knows one?

GothMetalhead commented 1 month ago

How did you add padding with space, i wanna see it Can you test :

...
const items = [ 'File' , 'Edit' , 'View' , 'History' , 'Bookmarks' , 'Tools' , 'Help' ] ;
var pad = ' '.repeat(10) // ten spaces 
items[0] = pad + items[0]; // adding padding to first item
...
term.singleLineMenu(items, options, function (error, response) {
let selectedText = response.selectedText.trimStart(); // clears padding with trimming
if (response.selectedIndex !== 0) { // if its not first item then dont trim
selectedText = response.selectedText;
}
...

It work on me succesfully