bound_terminal : unbound_terminal
173667
def p_bound_terminal(self, p):
        """"""
        if p[1][0].literal in ['*', '**']:
            p[0] = [_Segment(_BINDING, '$%d' % self.binding_var_count),
                    p[1][0],
                    _Segment(_END_BINDING, '')]
            self.binding_var_count += 1
        else:
            p[0] = p[1]
1141960
def _terminal_size(file=None):
    

    if file is None:
        file = _get_stdout()

    try:
        s = struct.pack(str("HHHH"), 0, 0, 0, 0)
        x = fcntl.ioctl(file, termios.TIOCGWINSZ, s)
        (lines, width, xpixels, ypixels) = struct.unpack(str("HHHH"), x)
        if lines > 12:
            lines -= 6
        if width > 10:
            width -= 1
        return (lines, width)
    except:
        try:
            # see if POSIX standard variables will work
            return (int(os.environ.get('LINES')),
                    int(os.environ.get('COLUMNS')))
        except TypeError:
            # fall back on configuration variables, or if not
            # set, (25, 80)
            lines = options.console.max_lines
            width = options.console.max_width
            if lines is None:
                lines = 25
            if width is None:
                width = 80
            return lines, width
755595
def terminal_width():
    """"""
    try:
        if os.name == 'nt':
            _WindowsCSBI.initialize()
            return _WindowsCSBI.get_info(_WindowsCSBI.HANDLE_STDOUT)['terminal_width']
        return struct.unpack('hhhh', fcntl.ioctl(0, termios.TIOCGWINSZ, '\000' * 8))[1]
    except IOError:
        return 80
346909
def prompt_terminal(path):
    """"""

    def rlinput(prompt_msg, prefill=''):
        """
        One line is read from standard input. Display `prompt_msg` on
        standard error. `prefill` is placed into the editing buffer
        before editing begins.
        """
        import readline
        readline.set_startup_hook(lambda: readline.insert_text(prefill))
        try:
            return input(prompt_msg)
        finally:
            readline.set_startup_hook()

    filepath, extension = os.path.splitext(path)
    basename = os.path.basename(filepath)
    dirname = os.path.dirname(filepath)

    # display filename prompt
    new_basename = rlinput('Filename: ', basename)

    # retry prompt if new filename already exists
    while os.path.exists(os.path.join(dirname, new_basename + extension)) and \
            new_basename != basename:
        new_basename = rlinput('Sorry, please try again... Filename: ',
                               basename)

    if new_basename == '':
        new_basename = basename

    return os.path.join(dirname, new_basename + extension)
1304050
function Terminal(options) {
	Terminal.super_.call(this, { decodeStrings: false });

	this.options = myUtil.extend({
		columns: 80,
		rows: 24,
		attributes: {}
	}, options || {});
	this.rows = ~~this.rows;
	this.columns = ~~this.columns;
	this.state = new TermState(this.options);
	this.oldChunk = null;
	this.on("pipe", this._pipe);
}
1008559
def get_unix_tput_terminal_size():
    
    import subprocess
    try:
        proc = subprocess.Popen(["tput", "cols"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
        output = proc.communicate(input=None)
        cols = int(output[0])
        proc = subprocess.Popen(["tput", "lines"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
        output = proc.communicate(input=None)
        rows = int(output[0])
        return cols, rows
    except (IOError, OSError):
        return None
303119
def call_unrar(params):
    """"""
    global rar_executable_cached
    if rar_executable_cached is None:
        for command in ('unrar', 'rar'):
            try:
                subprocess.Popen([command], stdout=subprocess.PIPE)
                rar_executable_cached = command
                break
            except OSError:
                pass
        if rar_executable_cached is None:
            raise UnpackerNotInstalled("No suitable RAR unpacker installed")

    assert type(params) == list, "params must be list"
    args = [rar_executable_cached] + params
    try:
        gc.disable()  # See http://bugs.python.org/issue1336
        return subprocess.Popen(args, stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
    finally:
        gc.enable()
203928
function(err, exit) {
    // Close the terminal
    if(terminal) terminal.close()

    // If there was an error throw it before exit
    if(err) throw err

    // process.stdin.resume() prevents node from exiting.
    // process.exit() overrides in more cases than stdin.pause() or stdin.end()
    // it also means we don't need to call process.stdin.setRawMode(false)
    if(exit === undefined || exit) {
      process.exit()
    }
    else {
      process.stdin.setRawMode(false)
      process.stdin.end()
    }
  }
658296
def get_terminal_size():
    ''''''
    def read_terminal_size_by_ioctl(fd):
        try:
            import struct, fcntl, termios
            cr = struct.unpack('hh', fcntl.ioctl(1, termios.TIOCGWINSZ,
                                                            '0000'))
        except ImportError:
            return None
        except IOError as e:
            return None
        return cr[1], cr[0]

    cr = read_terminal_size_by_ioctl(0) or \
            read_terminal_size_by_ioctl(1) or \
            read_terminal_size_by_ioctl(2)
    if not cr:
        try:
            import os
            fd = os.open(os.ctermid(), os.O_RDONLY)
            cr = read_terminal_size_by_ioctl(fd)
            os.close(fd)
        except:
            pass
    if not cr:
        import os
        cr = [80, 25] # 25 rows, 80 columns is the default value
        if os.getenv('ROWS'):
            cr[1] = int(os.getenv('ROWS'))
        if os.getenv('COLUMNS'):
            cr[0] = int(os.getenv('COLUMNS'))

    return cr[1], cr[0]
688898
def on_error
      yield
    rescue Github::Error::NotFound => e
      terminal.newline
      ui.error 'Resource Not Found'
      terminal.newline
      exit 15
    rescue GithubCLI::GithubCLIError => e
      GithubCLI.ui.error e.message
      GithubCLI.ui.debug e
      exit e.status_code
    rescue Interrupt => e
      GithubCLI.ui.error "\nQuitting..."
      GithubCLI.ui.debug e
      exit 1
    rescue SystemExit => e
      exit e.status
    rescue Exception => e
      GithubCLI.ui.error "\nFatal error has occurred. " + e.message.to_s
      GithubCLI.ui.debug e
      exit 1
    end
117071
function terminal(devicePath, exitCallback) {
  if (!args.quiet) log("Connecting to '"+devicePath+"'");
  var hadCtrlC = false;
  var hadCR = false;
  var ideServer = undefined;
  process.stdin.setRawMode(true);
  Espruino.Core.Serial.startListening(function(data) {
    data = new Uint8Array(data);
    var dataStr = String.fromCharCode.apply(null, data);
    if (ideServer) ideServer.write(dataStr);

    process.stdout.write(dataStr);
    /* If Espruino responds after a Ctrl-C with anything other
     than a blank prompt, make sure the next Ctrl-C will exit */
    for (var i=0;i<data.length;i++) {
      var ch = data[i];
      if (ch==8) hadCR = true;
      else {
        if (hadCtrlC && (ch!=62 /*>*/ || !hadCR)) {
          //process.stdout.write("\nCTRLC RESET BECAUSE OF "+JSON.stringify(String.fromCharCode.apply(null, data))+"  "+hadCR+" "+ch+"\n");
          hadCtrlC = false;
        }
        hadCR = false;
      }
    }
  });
  Espruino.Core.Serial.open(devicePath, function(status) {
    if (status === undefined) {
      console.error("Unable to connect!");
      return exitCallback();
    }
    if (!args.quiet) log("Connected");
    process.stdin.on('readable', function() {
      var chunk = process.stdin.read();
      if (chunk !== null) {
        chunk = chunk.toString();
        Espruino.Core.Serial.write(chunk);
        // Check for two Ctrl-C in a row (without Espruino doing anything inbetween)
        for (var i=0;i<chunk.length;i++) {
          var ch = chunk.charCodeAt(i);
          if (ch==3) {
            if (hadCtrlC) {
              process.stdout.write("\r\n");
              exitCallback();
            } else {
              // if we had ctrl-c, but didn't receive anything
              setTimeout(function() {
                if (hadCtrlC) process.stdout.write("\nPress Ctrl-C again to exit\n>");
              }, 200);
            }
            hadCtrlC = true;
          }
        }
      }
    });
    process.stdin.on('end', function() {
      console.log("STDIN ended. exiting...");
      exitCallback();
    });

    if (args.ideServer)
      ideServer = startWebIDEServer(function(data) {
        Espruino.Core.Serial.write(data);
      });

    // figure out what code we need to send (if any)
    sendCode(function() {
      if (args.watchFile) sendOnFileChanged();
    });

   }, function() {
     log("\nDisconnected.");
     exitCallback();
   });
}
17951
def generate_terminals(grammar)
      terminals = [:$EOF]

      grammar.terminals.each do |term|
        terminals << term.name.to_sym
      end

      return terminals
    end
1022707
def _unhandledInput(event, workbench, launcher):
    
    if event == "ctrl w":
        raise urwid.ExitMainLoop()
    elif event == "esc":
        workbench.clear()
        workbench.display(launcher)
        return True
892119
def terminal_unreserve(progress_obj, terminal_obj=None, verbose=0, identifier=None):
    

    if terminal_obj is None:
        terminal_obj = sys.stdout

    if identifier is None:
        identifier = ''
    else:
        identifier = identifier + ': '

    po = TERMINAL_RESERVATION.get(terminal_obj)
    if po is None:
        log.debug("terminal %s was not reserved, nothing happens", terminal_obj)
    else:
        if po is progress_obj:
            log.debug("terminal %s now unreserned", terminal_obj)
            del TERMINAL_RESERVATION[terminal_obj]
        else:
            log.debug("you %s can NOT unreserve terminal %s be cause it was reserved by %s", progress_obj, terminal_obj,
                      po)
664034
def unbounded(self):
        
        max = self.max
        if max is None:
            max = '1'
        if max.isdigit():
            return (int(max) > 1)
        else:
            return max == 'unbounded'
1227103
protected function verify_terminals()
    {
        foreach ($this->terminals as $name => $callback) {
            if (!has_privs('rah_terminal.'.$name) || !is_callable($callback)) {
                unset($this->terminal_labels[$name], $this->terminals[$name]);
            }
        }
    }
970512
async function unlink(args: Array<string>, ctx: ConfigT) {
  const packageName = args[0];

  const {[packageName]: dependency, ...otherDependencies} = ctx.dependencies;

  if (!dependency) {
    throw new CLIError(`
      Failed to unlink "${packageName}". It appears that the project is not linked yet.
    `);
  }

  const dependencies = values(otherDependencies);
  try {
    if (dependency.hooks.preulink) {
      await dependency.hooks.preulink();
    }
    unlinkDependency(
      ctx.platforms,
      ctx.project,
      dependency,
      packageName,
      dependencies,
    );
    if (dependency.hooks.postunlink) {
      await dependency.hooks.postunlink();
    }
  } catch (error) {
    throw new CLIError(
      `Something went wrong while unlinking. Reason ${error.message}`,
      error,
    );
  }

  // @todo move all these to above try/catch
  // @todo it is possible we could be unlinking some project assets in case of duplicate
  const assets = difference(
    dependency.assets,
    flatMap(dependencies, d => d.assets),
  );

  if (assets.length === 0) {
    return;
  }

  Object.keys(ctx.platforms || {}).forEach(platform => {
    const projectConfig = ctx.project[platform];
    const linkConfig =
      ctx.platforms[platform] &&
      ctx.platforms[platform].linkConfig &&
      ctx.platforms[platform].linkConfig();
    if (!linkConfig || !linkConfig.unlinkAssets || !projectConfig) {
      return;
    }

    logger.info(`Unlinking assets from ${platform} project`);
    // $FlowFixMe
    linkConfig.unlinkAssets(assets, projectConfig);
  });

  logger.info(
    `${packageName} assets has been successfully unlinked from your project`,
  );
}