How to use the terminal-kit.terminal 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 DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
});

start();

term.slowTyping(
  "What a wonderful world!\n",
  { flashStyle: term.brightWhite },
  () => {}
);

// low level

term("My name is ")
  .red("Jack")(" and I'm ")
  .green("32\n");
term("My name is ^rJack^ and I'm ^g32\n");

term.noFormat.red("hello");

term.noFormat("hello");

// color methods with a second argument
term.color(1, "test");
term.darkColor(1, "test");
term.brightColor(1, "test");
term.color256(1, "test");
term.colorRgb(255, 0, 0, "test");
term.colorRgbHex("#ff0000", "test");
term.colorGrayscale(192, "test");

// bgColor methods with a second argument
term.bgColor(1, "test");
github brannondorsey / chattervox / src / ui / init.ts View on Github external
term(`We'll ask you some questions to create an initial settings configuration.\n\n`)

    let conf: Config
    while (true) {
        conf = await askUser()
        term.yellow(`\n${JSON.stringify(conf, null, 2)}`)
        term(`\nIs this correct [Y/n]? `)
        const correct = (await term.inputField().promise).trim().toLowerCase()
        if (correct === '' || correct === 'yes' || correct === 'y') break
    }

    // create the ~/.chattervox dir, config.json, and keystore.json
    init()

    const ks: Keystore = new Keystore(conf.keystoreFile)
    term(`\nGenerating ECDSA keypair...`)
    const key: Key = ks.genKeyPair(conf.callsign)
    await timeout(2000) // delay for dramatic effect, lol
    term(`\nPublic Key: ^c${key.public}^\n`)

    // signatures are created using a private key, but we don't want to include
    // the private key in the config file, so instead we use the public key
    // as the identifier, and then actually sign with the private key.
    conf.signingKey = key.public

    try {
        save(conf)
        term(`\nSettings saved to ${defaultConfigPath}\n`)
    } catch (err) {
        term(`\nError saving settings to ${defaultConfigPath}\n`)
        term.processExit()
    }
github sjurba / rebase-editor / lib / editor.js View on Github external
function resetTerminal() {
  term.saveCursor();
  term.moveTo(1, showStatus ? 2 : 1);
  lineNum = 0;
  term.eraseDisplayBelow();
  var data = input.map(cropLine).map(highlightLine).join('\n');
  data = data.replace(/(#\sCommands:[^]*?#\s*\n)/, '$1' + editorCommands.join('\n# ') + '\n#\n');
  data = data.replace(/#\sx, exec.*\s*\n/, '');
  data = data.replace(/#\sd, drop.*\s*\n/, '');
  data = data.split('\n').slice(0, term.height - 1).join('\n');
  status('Status');
  term(data);
  term.restoreCursor();
}
github cronvel / terminal-kit / sample / file-input-doc1.js View on Github external
The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
*/
"use strict" ;

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

term( 'Choose a file: ' ) ;

term.fileInput(
	//{ baseDir: __dirname + '/../' } ,
	{ baseDir: '../' } ,
	function( error , input ) {
		if ( error )
		{
			term.red.bold( "\nAn error occurs: " + error + "\n" ) ;
		}
		else
		{
			term.green( "\nYour file is '%s'\n" , input ) ;
		}
		
		process.exit() ;
	}
github cronvel / terminal-kit / sample / single-column-menu-doc1.js View on Github external
term.singleColumnMenu( items , function( error , response ) {
	term( '\n' ).eraseLineAfter.green(
		"#%s selected: %s (%s,%s)\n" ,
		response.selectedIndex ,
		response.selectedText ,
		response.x ,
		response.y
	) ;
	process.exit() ;
} ) ;
github sogehige / sogeBot / tools / cleanup.js View on Github external
function areYouSure () {
  term('DO YOU KNOW WHAT ARE YOU DOING? [y|N]\n')
  term.yesOrNo({ yes: ['y'], no: ['n', 'ENTER'] }, (error, result) => {
    if (error) process.exit(error)

    if (result) {
      main()
    } else {
      term.red("'No' detected, if you don't know what are you doing, ask on https://discordapp.com/invite/52KpmuH\n")
      process.exit()
    }
  })
}
github criteo / loop / lib / term.js View on Github external
  proxy.server.termEvents.on('log', txt => term(txt))
github BrowserSync / recipes / recipes / server.proxy+sass+postcss / server.js View on Github external
sass.render(sassConfig, function(err, result) {
        //
        if (!err) {
            postcss([unprefixer, prefixer(post.autoprefixer), cssnano(post.cssnano)])
                .process(result.css.toString())
                .then(function(result) {
                    fs.writeFileSync(style.out, result.css);
                });
        } else {
            term('[').red('BS')('] ')(err.message + '\n');
        }
    });
}
github alarner / config-template / index.js View on Github external
if(line.value) {
					switch(line.type) {
						case 'string':
							term.yellow('"'+line.value+'"');
						break;
						case 'number':
							term.cyan(line.value);
						break;
						case 'boolean':
							term.magenta(line.value);
						break;
						case 'json':
							term.colorRgb(150, 200, 255, line.value);
						break;
						default:
							term(line.value);
						break;
					}
					
				}
				else if(line.empty) {
					term.yellow('""');
				}
				else if(line.deleted) {
					term.italic.colorRgb(50, 50, 50, '- removed -');
				}
				else {
					term.colorRgb(50, 50, 50, '______');
				}
				term(',');
			});
		}
github cronvel / http-requester / lib / display.js View on Github external
display.displayMessage = function( config , id , message ) {
	if ( config.server ) { term.blue( 'Message from #%i:' , id ) ; }
	else { term.blue( 'Message #%i:' , id ) ; }

	term(  ( message.indexOf( '\n' ) >= 0 ? '\n' : ' ' )  + message + '\n' ) ;
} ;