How to use terminal-kit - 10 common examples

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
// Get some user input
term.magenta("Enter your name: ");
term.inputField((error: any, input: any) => {
  term.green("\nYour name is '%s'\n", input);
});

function terminate() {
  term.grabInput(false);
  setTimeout(() => {}, 100);
}

term.bold.cyan("Type anything on the keyboard...\n");
term.green("Hit CTRL-C to quit.\n\n");

term.grabInput({ mouse: "button" });

term.on("key", (name: string, matches: any[], data: any) => {
  console.log("'key' event:", name);
  if (name === "CTRL_C") {
    terminate();
  }
});

term.on("terminal", (name: string, data: any) => {
  console.log("'terminal' event:", name, data);
});

term.on("mouse", (name: string, data: any) => {
  console.log("'mouse' event:", name, data);
});
github DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
term.magenta("Enter your name: ");
term.inputField((error: any, input: any) => {
  term.green("\nYour name is '%s'\n", input);
});

function terminate() {
  term.grabInput(false);
  setTimeout(() => {}, 100);
}

term.bold.cyan("Type anything on the keyboard...\n");
term.green("Hit CTRL-C to quit.\n\n");

term.grabInput({ mouse: "button" });

term.on("key", (name: string, matches: any[], data: any) => {
  console.log("'key' event:", name);
  if (name === "CTRL_C") {
    terminate();
  }
});

term.on("terminal", (name: string, data: any) => {
  console.log("'terminal' event:", name, data);
});

term.on("mouse", (name: string, data: any) => {
  console.log("'mouse' event:", name, data);
});

// Word-wrap this along the full terminal width
term.wrap.yellow(
github DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
setTimeout(() => {}, 100);
}

term.bold.cyan("Type anything on the keyboard...\n");
term.green("Hit CTRL-C to quit.\n\n");

term.grabInput({ mouse: "button" });

term.on("key", (name: string, matches: any[], data: any) => {
  console.log("'key' event:", name);
  if (name === "CTRL_C") {
    terminate();
  }
});

term.on("terminal", (name: string, data: any) => {
  console.log("'terminal' event:", name, data);
});

term.on("mouse", (name: string, data: any) => {
  console.log("'mouse' event:", name, data);
});

// Word-wrap this along the full terminal width
term.wrap.yellow(
  `'Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
     files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish'`
);

// Word-wrap this inside a column starting at x=10 with a width of 25 terminal cells
term.wrapColumn({ x: 10, width: 25 });
term.wrap.green(
github DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
// ... or even combined with other styles
term.moveTo.cyan(1, 1, "My name is %s, I'm %d.\n", "Jack", 32);

// Get some user input
term.magenta("Enter your name: ");
term.inputField((error: any, input: any) => {
  term.green("\nYour name is '%s'\n", input);
});

function terminate() {
  term.grabInput(false);
  setTimeout(() => {}, 100);
}

term.bold.cyan("Type anything on the keyboard...\n");
term.green("Hit CTRL-C to quit.\n\n");

term.grabInput({ mouse: "button" });

term.on("key", (name: string, matches: any[], data: any) => {
  console.log("'key' event:", name);
  if (name === "CTRL_C") {
    terminate();
  }
});

term.on("terminal", (name: string, data: any) => {
  console.log("'terminal' event:", name, data);
});

term.on("mouse", (name: string, data: any) => {
  console.log("'mouse' event:", name, data);
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 DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
autoComplete as ac,
  getDetectedTerminal,
  ScreenBufferHD,
  ScreenBuffer,
  Terminal
} from "terminal-kit";
import "node";
import * as fs from "fs";

new t.Rect({width: 4, height: 4});
// The term() function simply output a string to stdout, using current style
// output "Hello world!" in default terminal's colors
t.terminal("Hello world!\n");

// This output 'red' in red
term.red("red");

// This output 'bold' in bold
term.bold("bold");

// output 'mixed' using bold, underlined & red, exposing the style-mixing syntax
term.bold.underline.red("mixed");

// printf() style formatting everywhere:
// this will output 'My name is Jack, I'm 32.' in green
term.green("My name is %s, I'm %d.\n", "Jack", 32);

// Since v0.16.x, style markup are supported as a shorthand.
// Those two lines produce the same result.
term("My name is ")
  .red("Jack")(" and I'm ")
  .green("32\n");
github DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
"File",
  "Edit",
  "View",
  "History",
  "Bookmarks",
  "Tools",
  "Help"
];

const options = {
  y: 1, // the menu will be on the top of the terminal
  style: term.inverse,
  selectedStyle: term.dim.blue.bgGreen
};

term.clear();

term.singleLineMenu(items1, options, (error: any, response: any) => {
  term("\n").eraseLineAfter.green(
    "#%s selected: %s (%s,%s)\n",
    response.selectedIndex,
    response.selectedText,
    response.x,
    response.y
  );
});

term.cyan("The hall is spacious. Someone lighted few chandeliers.\n");
term.cyan("There are doorways south and west.\n");

const items2 = ["a. Go south", "b. Go west", "c. Go back to the street"];
github DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
// The term() function simply output a string to stdout, using current style
// output "Hello world!" in default terminal's colors
t.terminal("Hello world!\n");

// This output 'red' in red
term.red("red");

// This output 'bold' in bold
term.bold("bold");

// output 'mixed' using bold, underlined & red, exposing the style-mixing syntax
term.bold.underline.red("mixed");

// printf() style formatting everywhere:
// this will output 'My name is Jack, I'm 32.' in green
term.green("My name is %s, I'm %d.\n", "Jack", 32);

// Since v0.16.x, style markup are supported as a shorthand.
// Those two lines produce the same result.
term("My name is ")
  .red("Jack")(" and I'm ")
  .green("32\n");
term("My name is ^rJack^ and I'm ^g32\n");

// Width and height of the terminal
term("The terminal size is %dx%d", term.width, term.height);

// Move the cursor at the upper-left corner
term.moveTo(1, 1);

// We can always pass additional arguments that will be displayed...
term.moveTo(1, 1, "Upper-left corner");
github DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
// output 'mixed' using bold, underlined & red, exposing the style-mixing syntax
term.bold.underline.red("mixed");

// printf() style formatting everywhere:
// this will output 'My name is Jack, I'm 32.' in green
term.green("My name is %s, I'm %d.\n", "Jack", 32);

// Since v0.16.x, style markup are supported as a shorthand.
// Those two lines produce the same result.
term("My name is ")
  .red("Jack")(" and I'm ")
  .green("32\n");
term("My name is ^rJack^ and I'm ^g32\n");

// Width and height of the terminal
term("The terminal size is %dx%d", term.width, term.height);

// Move the cursor at the upper-left corner
term.moveTo(1, 1);

// We can always pass additional arguments that will be displayed...
term.moveTo(1, 1, "Upper-left corner");

// ... and formated
term.moveTo(1, 1, "My name is %s, I'm %d.\n", "Jack", 32);

// ... or even combined with other styles
term.moveTo.cyan(1, 1, "My name is %s, I'm %d.\n", "Jack", 32);

// Get some user input
term.magenta("Enter your name: ");
term.inputField((error: any, input: any) => {
github DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
}
);

const screen1 = new ScreenBuffer({ dst: term, noFill: true });

screen1.fill({
  attr: {
    // Both foreground and background must have the same color
    color: 0,
    bgColor: 0
  }
});

ScreenBuffer.loadImage(
  path_to_image,
  { terminal: term, shrink: { width: term.width, height: term.height * 2 } },
  (error: any, image: any) => {
    if (error) {
      throw error;
    } // Doh!

    image.draw({ dst: screen, blending: true });
    screen.draw();
  }
);