requires the mode to have #done? and #value methods
421342
def spawn_modal title, mode, opts={}
    b = spawn title, mode, opts
    draw_screen

    until mode.done?
      c = Ncurses::CharCode.get
      next unless c.present? # getch timeout
      break if c.is_keycode? Ncurses::KEY_CANCEL
      begin
        mode.handle_input c
      rescue InputSequenceAborted # do nothing
      end
      draw_screen
      erase_flash
    end

    kill_buffer b
    mode.value
  end
420081
def method_missing(name, *args, &block)
      string_name = name.to_s

      if string_name =~ /can_(.+)\?/
        self.can?(name, *args)
      else
        super(name, *args, &block)
      end
    end
1289155
function compileModes() {

    function compileMode(mode, language, is_default) {
      if (mode.compiled)
        return;

      if (!is_default) {
        mode.beginRe = langRe(language, mode.begin ? mode.begin : '\\B|\\b');
        if (!mode.end && !mode.endsWithParent)
          mode.end = '\\B|\\b'
        if (mode.end)
          mode.endRe = langRe(language, mode.end);
      }
      if (mode.illegal)
        mode.illegalRe = langRe(language, mode.illegal);
      if (mode.relevance == undefined)
        mode.relevance = 1;
      if (mode.keywords)
        mode.lexemsRe = langRe(language, mode.lexems || hljs.IDENT_RE, true);
      for (var key in mode.keywords) {
        if (!mode.keywords.hasOwnProperty(key))
          continue;
        if (mode.keywords[key] instanceof Object)
          mode.keywordGroups = mode.keywords;
        else
          mode.keywordGroups = {'keyword': mode.keywords};
        break;
      }
      if (!mode.contains) {
        mode.contains = [];
      }
      // compiled flag is set before compiling submodes to avoid self-recursion
      // (see lisp where quoted_list contains quoted_list)
      mode.compiled = true;
      for (var i = 0; i < mode.contains.length; i++) {
        compileMode(mode.contains[i], language, false);
      }
      if (mode.starts) {
        compileMode(mode.starts, language, false);
      }
    }

    for (var i in languages) {
      if (!languages.hasOwnProperty(i))
        continue;
      compileMode(languages[i].defaultMode, languages[i], true);
    }
  }
947015
def method_missing(method, * args)
      value = with_file(method, * args)
      logger.debug "#{self}.method_missing(#{method.inspect}, #{args.inspect}) => #{value.inspect}"
      value
    end
387885
def _pv_respond_to(opts, key, method_name_list)
        value = _pv_opts_lookup(opts, key)
        unless value.nil?
          Array(method_name_list).each do |method_name|
            unless value.respond_to?(method_name)
              raise ValidationFailed, "Option #{key} must have a #{method_name} method!"
            end
          end
        end
      end
1215541
def ensure_call(value)
      @count += 1

      if value.nil? && expects_argument?
        if default_value
          @value = default_value
        elsif !suppress_errors?
          raise Slop::MissingArgument.new("missing argument for #{flag}", flags)
        end
      else
        @value = call(value)
      end

      block.call(@value) if block.respond_to?(:call)
    end
1096042
def method_missing(name, *args)
      name = name.to_s
      last_char = name[-1,1]
      super(name, *args) unless last_char == "=" || last_char == "?"
      attr_name = name[0..-2].to_sym # :foo for 'foo=' or 'foo?'
      if last_char == "="
        @options[attr_name] = args.at(0)
      else
        @options[attr_name]
      end
    end
618957
function(mod, modName, rawCode, done) {
  var resolveModule = function(requiredName) {
    return mod.getModuleIDByOrigin(requiredName);
  };
  try {
    var transformedCode = fixReactTransform(transform(rawCode, {harmony: true}));
    var modularizedCode =
      Modularizer.modularize(modName, transformedCode, resolveModule);
    originalSourceCache[modName] = rawCode;
    transformCache[modName] = modularizedCode;
    transformTimes[modName] = Date.now();
    done(null, transformCache[modName]);
  } catch (e) {
    // Original error only includes esprima trace!
    var parseError =
      new Error('Syntax Error: ' + mod.path + ' ' + e.toString());
    done(parseError);
  }
}
11890
def check(object, mode = @mode)
      checked = {}
      result = true
      errors = CheckFailed.new
      each do |message|
        begin
          message.check(object, checked)
        rescue CheckError => e
          case mode
          when :error
            errors << e
          when :warning
            warn e.to_s
            result = false
          when :none
            result = false
          end
        end
      end
      raise errors unless errors.empty?
      result
    end
870353
private void initModeSwitch(final EditMode current) {

        FormLayout modes = new FormLayout();
        modes.setHeight("100%");
        modes.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

        m_modeSelect = new ComboBox();
        m_modeSelect.setCaption(m_messages.key(Messages.GUI_VIEW_SWITCHER_LABEL_0));

        // add Modes
        m_modeSelect.addItem(CmsMessageBundleEditorTypes.EditMode.DEFAULT);
        m_modeSelect.setItemCaption(
            CmsMessageBundleEditorTypes.EditMode.DEFAULT,
            m_messages.key(Messages.GUI_VIEW_SWITCHER_EDITMODE_DEFAULT_0));
        m_modeSelect.addItem(CmsMessageBundleEditorTypes.EditMode.MASTER);
        m_modeSelect.setItemCaption(
            CmsMessageBundleEditorTypes.EditMode.MASTER,
            m_messages.key(Messages.GUI_VIEW_SWITCHER_EDITMODE_MASTER_0));

        // set current mode as selected
        m_modeSelect.setValue(current);

        m_modeSelect.setNewItemsAllowed(false);
        m_modeSelect.setTextInputAllowed(false);
        m_modeSelect.setNullSelectionAllowed(false);

        m_modeSelect.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {

                m_listener.handleModeChange((EditMode)event.getProperty().getValue());

            }
        });

        modes.addComponent(m_modeSelect);
        m_modeSwitch = modes;
    }
1374096
def with_each_mode
      begin
        orig = current_mode
      rescue
        orig = nil
      end
      modes.each do |_id, mode|
        self.current_mode = mode
        yield mode
      end
      self.current_mode = orig
    end
563582
def _checkMode(mode):
    

    if not isinstance(mode, str):
        raise TypeError('The {0} should be a string. Given: {1!r}'.format("mode", mode))

    if mode not in [MODE_RTU, MODE_ASCII]:
        raise ValueError("Unreconized Modbus mode given. Must be 'rtu' or 'ascii' but {0!r} was given.".format(mode))
755611
def parse_modes(params, mode_types=None, prefixes=''):
    
    # we don't accept bare strings because we don't want to try to do
    #   intelligent parameter splitting
    params = list(params)

    if params[0][0] not in '+-':
        raise Exception('first param must start with + or -')

    if mode_types is None:
        mode_types = ['', '', '', '']

    mode_string = params.pop(0)
    args = params

    assembled_modes = []
    direction = mode_string[0]
    for char in mode_string:
        if char in '+-':
            direction = char
            continue

        if (char in mode_types[0] or char in mode_types[1] or char in prefixes or
                (char in mode_types[2] and direction == '+') and len(args)):
            value = args.pop(0)
        else:
            value = None

        assembled_modes.append([direction, char, value])

    return assembled_modes
123325
def method_missing(name, *args, &blk)
      if name.to_s =~ /^default_(.*)=$/
        @default_options[$1.to_sym] = args.first
      elsif name.to_s =~ /=$/
        @dirty_options[$`.to_sym] = args.first
      elsif @default_options.key?(name)
        dirty_or_db_setting_or_default(name)
      else
        super
      end
    end
676933
function setRawMode (mode) {
  if (mode) {
    this.do.suppress_go_ahead()
    this.will.suppress_go_ahead()
    this.will.echo()
  } else {
    this.dont.suppress_go_ahead()
    this.wont.suppress_go_ahead()
    this.wont.echo()
  }
}
191548
def method_missing(m,*a,&b)
      m = m.to_s

      if (key = EXTRA_REGEX.match(m))
        if key['VAR'] == 'value'
          key = key['KEY'].to_i
          if VALID_EXTRA_KEY.include?(key)
            ivar = :"@#{m}"
            val = instance_variable_defined?(ivar) ? instance_variable_get(ivar) : nil
            tp = send("extra_#{key}_type")
            if tp == 'boolean'
              val = ((val === true) || (val == '1')) ? '1' : '0'
            end
            return val
          end
        end
      end

      super m, *a, &b
    end
1310521
function mode() {
      var value = (attr.mdMode || "").trim();
      if (value) {
        switch (value) {
          case MODE_DETERMINATE:
          case MODE_INDETERMINATE:
          case MODE_BUFFER:
          case MODE_QUERY:
            break;
          default:
            value = MODE_INDETERMINATE;
            break;
        }
      }
      return value;
    }