How to use the terminal-kit.terminal.grabInput 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
// 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 infinitered / ignite / src / lib / library / completeTemplate.js View on Github external
drawTemplate(workingContent)

    return {
      content, // Just the content
      workingContent: workingContent, // Content with cursor
      finished: finished, // Boolean about whether finished
      currentSite: nextSite, // Number of current site
      currentEntry: entry, // User input in current site
    }
  }

  const newTemplateState = await handleInput(templateState)
  Object.assign(templateState, newTemplateState)
  
  term.grabInput( );
  term.on( 'key' , async function( name , _matches , _data ) {
    const newTemplateState = await handleInput(templateState, name)
    
    if (newTemplateState.finished) {
      term.clear()
      terminate()
      onComplete(newTemplateState)
    }

    Object.assign(templateState, newTemplateState)
  } ) ;
}
github oodavid / puppeteer-scraper / app / hud / keyboard.js View on Github external
function start(){
  // Only start when inactive
  if(isActive){ return; }
  isActive = true;
  // Listen for input
  term.grabInput(true);
  term.on('key', function(keyName, matches, data){
    // Has that key been assigned?
    if(keys.hasOwnProperty(keyName)){
      keys[keyName].command();
    }
    // Manually handle the exit command
    if(keyName === 'CTRL_C'){
      terminate();
      return;
    }
  });
  // Render the keys to screen
  renderKeys();
}
github DefinitelyTyped / DefinitelyTyped / types / terminal-kit / terminal-kit-tests.ts View on Github external
function terminate() {
  term.grabInput(false);
  setTimeout(() => {}, 100);
}
github infinitered / ignite / src / lib / library / completeTemplate.js View on Github external
function terminate() {
    term.grabInput( false ) ;
    setTimeout( function() { process.exit() } , 100 ) ;
  }
github zamotany / react-slate / packages / core / src / renderFullscreen.ts View on Github external
export function exit(code: number = 0) {
  terminal.grabInput(false);
  terminal.hideCursor(false);
  terminal.fullscreen(false);
  flushConsole(terminal);
  terminal.processExit(code);
}
github oodavid / puppeteer-scraper / app / hud / keyboard.js View on Github external
function terminate(){
	term.grabInput(false);
	setTimeout(function(){
    process.exit();
  }, 100);
}
github AztecProtocol / loan-dapp-starter-kit / scripts / tasks / start.js View on Github external
const handleClose = async () => {
    terminal.grabInput(false);
    Object.keys(runningProcesses)
      .forEach((name) => {
        const cp = runningProcesses[name];
        if (!cp) return;

        log(`Stopping ${name}...`);
        runningProcesses[name] = null;
        if (typeof cp.clear === 'function') {
          cp.clear();
        } else {
          cp.kill();
        }
      });
  };
github AztecProtocol / AZTEC / packages / extension / scripts / tasks / setup.js View on Github external
const handleClose = async () => {
        terminal.grabInput(false);
        stopProcesses(runningProcesses, (name) => {
            runningProcesses[name] = null;
        });
    };