How to use the terminal-kit.terminal.inputField function in terminal-kit

To help you get started, we’ve selected a few terminal-kit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cronvel / terminal-kit / sample / input-field-doc1.js View on Github external
"use strict" ;

var term = require( 'terminal-kit' ).terminal ;

var history = [ 'John' , 'Jack' , 'Joey' , 'Billy' , 'Bob' ] ;

var autoComplete = [
	'Barack Obama' , 'George W. Bush' , 'Bill Clinton' , 'George Bush' ,
	'Ronald W. Reagan' , 'Jimmy Carter' , 'Gerald Ford' , 'Richard Nixon' ,
	'Lyndon Johnson' , 'John F. Kennedy' , 'Dwight Eisenhower' ,
	'Harry Truman' , 'Franklin Roosevelt'
] ;

term( 'Please enter your name: ' ) ;

term.inputField(
	{ history: history , autoComplete: autoComplete , autoCompleteMenu: true } ,
	function( error , input ) {

		term.green( "\nYour name is '%s'\n" , input ) ;
		process.exit() ;
	}
) ;
github brannondorsey / chattervox / src / ui / init.ts View on Github external
async function promptCallsign(): Promise {
    term(`\nWhat is your call sign (default: ${defaultConfig.callsign})? `)
    let callsign: string = (await term.inputField().promise).trim().toUpperCase()
    if (callsign === '') return defaultConfig.callsign
    else if (isCallsign(callsign)) return callsign
    else {
        term('\nCallsign must be between 1 and 6 alphanumeric characters.')
        return promptCallsign()
    }
}
github brannondorsey / chattervox / src / ui / init.ts View on Github external
async function askUser(): Promise {

    let callsign: string = await promptCallsign()
    let ssid: number = await promptSSID()

    term(`\nDo you have a dedicated hardware TNC that you would like to use instead of Direwolf (default: no)? `)
    let hasDedicatedTNC: string = (await term.inputField().promise).trim().toLowerCase()
    let dedicatedTNC: boolean = (hasDedicatedTNC === 'yes' || hasDedicatedTNC === 'y')

    let kissPort: string
    let kissBaud: number
    if (dedicatedTNC) {
        term(`\nWhat is the serial port device name of this TNC (e.g. /dev/ttyS0)? `)
        kissPort = (await term.inputField().promise).trim()

        term(`\nWhat is the baud rate for this serial device (default ${defaultConfig.kissBaud})? `)
        const baud = (await term.inputField().promise).trim()
        kissBaud = baud === '' ? defaultConfig.kissBaud : parseInt(baud)
    } else {
        term(`\nWould you like to connect to Direwolf over serial instead of the default TCP connection (default: no)? `)
        let prefersSerialRaw: string = (await term.inputField().promise).trim().toLowerCase()
        let prefersSerial: boolean = (prefersSerialRaw === 'yes' || prefersSerialRaw === 'y')
        if (prefersSerial) {
            kissPort = '/tmp/kisstnc'
        }
    }

    const conf: Config = JSON.parse(JSON.stringify(defaultConfig))
    conf.callsign = callsign
    conf.ssid = ssid
github brannondorsey / chattervox / src / ui / chat.ts View on Github external
async function prompt(callsign: string): Promise {
    myColorFunction(`\n${callsign}`)(': ')
    input = term.inputField({ cancelable: true })
    const message = await input.promise
    return message
}
github cronvel / terminal-kit / sample / input-field-hilighted.js View on Github external

"use strict" ;

var term = require( 'terminal-kit' ).terminal ;

term( '> ' ) ;

var autoComplete = [
	'dnf install' ,
	'dnf search' ,
	'sudo' ,
	'sudo dnf install' ,
	'sudo dnf search' ,
] ;

term.inputField(
	{
		autoComplete: autoComplete ,
		autoCompleteMenu: true ,
		style: term.brightCyan ,
		tokenStyleHook: function( token , previousTokens , style ) {
			if ( token === 'sudo' ) { return style.red ; }
		} ,
		tokenFinishHook: function( tokens , style ) {
				if ( tokens.join( ' ' ) === "dnf install" )
			{
				style.brightBlack( " node" ) ;
			}
		}
	} ,
	function( error , input ) {
github brannondorsey / chattervox / src / ui / init.ts View on Github external
async function promptSSID(): Promise {
    term(`\nWhat SSID would you like to associate with this station (press ENTER to skip)? `)
    let ssid: string = await term.inputField().promise
    if (ssid.trim() === '') return 0
    else if (!isNaN(parseInt(ssid))) {
        let num = parseInt(ssid)
        if (num >= 0 && num <= 15) return num
    }
    term('\nSSID must be a number between 0 and 15.')
    return promptSSID()
}
github cronvel / terminal-kit / sample / input-field-doc4.js View on Github external
var term = require( 'terminal-kit' ).terminal ;

term( 'shell> ' ) ;

var autoComplete = [
	'dnf install' ,
	'dnf install nodejs' ,
	'dnf search' ,
	'sudo' ,
	'sudo dnf install' ,
	'sudo dnf install nodejs' ,
	'sudo dnf search' ,
] ;

term.inputField(
	{
		autoComplete: autoComplete ,
		autoCompleteHint: true ,
		autoCompleteMenu: true ,
		tokenHook: function( token , isEndOfInput , previousTokens , term , config ) {
			var previousText = previousTokens.join( ' ' ) ;
			
			switch ( token )
			{
				case 'sudo' :
					config.style = term.red ;
					return previousTokens.length ? null : term.bold.red ;
				case 'dnf' :
					return previousText === '' || previousText === 'sudo' ? term.brightMagenta : null ;
				case 'install' :
					config.style = term.brightBlue ;