useful because some computer keyboards don't manage macrons, see => https://en.wikipedia.org/wiki/Macron
518757
static String hepburn(
        CharSequence text,
        int offset
    ) {

        StringBuilder sb = null;
        int n = Math.min(text.length(), offset + 32);

        for (int i = offset; i < n; i++) {
            final char c = text.charAt(i);
            char std;
            if (i == offset) { // capitalization
                std = ((c == '\u00D4') || (c == '\u00F4') || (c == '\u014D') ? '\u014C' : Character.toUpperCase(c));
                std = ((c == '\u00DB') || (c == '\u00FB') || (c == '\u016B') ? '\u016A' : std);
            } else {
                std = ((c == '\u00D4') || (c == '\u00F4') || (c == '\u014C') ? '\u014D' : Character.toLowerCase(c));
                std = ((c == '\u00DB') || (c == '\u00FB') || (c == '\u016A') ? '\u016B' : std);
            }
            std = ((c == '\'') ? '\u2019' : std); // use ’ as apostroph
            std = ((c == ' ') ? '-' : std); // use hyphen instead of space
            if ((sb != null) || (std != c)) {
                if (sb == null) {
                    sb = new StringBuilder(32);
                    sb.append(text.subSequence(offset, i));
                }
                sb.append(std);
            }
        }

        return ((sb == null) ? text.subSequence(offset, n).toString() : sb.toString());

    }
772660
function (macroName) {
            var res = this.macros[macroName];
            if (res == null) {
                res = {};
                this.macros[macroName] = res;
            }
            return res;
        }
1369122
function _keyIs(key, name) {
    return (key.name === name && !key.ctrl && !key.shift && !key.meta);
}
600353
def system(name):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': None,
           'comment': ''}
    if __salt__['keyboard.get_sys']() == name:
        ret['result'] = True
        ret['comment'] = 'System layout {0} already set'.format(name)
        return ret
    if __opts__['test']:
        ret['comment'] = 'System layout {0} needs to be set'.format(name)
        return ret
    if __salt__['keyboard.set_sys'](name):
        ret['changes'] = {'layout': name}
        ret['result'] = True
        ret['comment'] = 'Set system keyboard layout {0}'.format(name)
        return ret
    else:
        ret['result'] = False
        ret['comment'] = 'Failed to set system keyboard layout'
        return ret
708976
function addAnchors(text) {
        if(text.charAt(0) != '\x02')
            text = '\x02' + text;
        if(text.charAt(text.length - 1) != '\x03')
            text = text + '\x03';
        return text;
    }
481199
function keyEventEnum() {
  let modifiers = [
    '', 'CTRL_', 'ALT_', 'SHIFT_', 'CTRL_ALT_', 'CTRL_SHIFT_', 'ALT_SHIFT_',
    'CTRL_ALT_SHIFT_',
  ];
  let charKeys = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
    'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  ];
  let specialKeys = [
    'SPACE', 'RETURN', 'TAB', 'BACKSPACE', 'ESCAPE',
    'INSERT', 'DELETE', 'HOME', 'END', 'PAGEUP', 'PAGEDOWN',
    'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12',
  ];
  let symbolKeys = [
    'AMPERSAND', 'ASTERISK', 'AT', 'BACKSLASH', 'CARET', 'COLON', 'DOLLAR',
    'EQUALS', 'EXCLAIM', 'GREATER', 'HASH', 'LESS', 'PERCENT', 'PLUS',
    'SEMICOLON', 'SLASH', 'QUESTION', 'QUOTE',
    'QUOTEDBL', 'UNDERSCORE', 'LEFTPAREN', 'RIGHTPAREN',
    'LEFTBRACKET', 'RIGHTBRACKET', 'LEFTBRACE', 'RIGHTBRACE',
  ];
  let arrowKeys = [
    'LEFT', 'RIGHT', 'UP', 'DOWN',
  ];
  let keys = charKeys.concat(specialKeys).concat(symbolKeys).concat(arrowKeys);

  let eventNames = [];
  for (let modifier of modifiers) {
    for (let key of keys) {
      eventNames.push('K_' + modifier + key);
    }
  }
  return eventNames;
}
134395
def handle_key ch
      if !@current_menu.empty?
        cmenu = @current_menu.last
      else 
        cmenu = self
      end
      if !@@menus.empty?
       cmenu = @@menus.last
      else 
       cmenu = self
      end
      case ch
      when KEY_DOWN
        cmenu.select_next_item
        #return cmenu.fire # XXX 2010-10-16 21:39 trying out
        if cmenu.is_a? Canis::Menu 
          #alert "is a menu" # this gets triggered even when we are on items
        end
      when KEY_UP
        cmenu.select_prev_item
      when KEY_ENTER, 10, 13, 32 # added 32 2008-11-27 23:50 
        return cmenu.fire
      when KEY_LEFT
        if cmenu.parent.is_a? Canis::Menu 
       #$log.debug "LEFT IN MENU : #{cmenu.parent.class} len: #{cmenu.parent.current_menu.length}"
       #$log.debug "left IN MENU : #{cmenu.parent.class} len: #{cmenu.current_menu.length}"
        end
        ret = cmenu.select_left_item # 2011-09-24 V1.3.1 attempt to goto left item if columns
        if ret == :UNHANDLED
          if cmenu.parent.is_a? Canis::MenuBar #and !cmenu.parent.current_menu.empty?
            #$log.debug " ABOU TO DESTROY DUE TO LEFT"
            cmenu.current_menu.pop
            @@menus.pop ## NEW
            cmenu.destroy
            return :UNHANDLED
          end
          # LEFT on a menu list allows me to close and return to higher level
          if cmenu.parent.is_a? Canis::Menu #and !cmenu.parent.current_menu.empty?
            #$log.debug " ABOU TO DESTROY DUE TO LEFT"
            cmenu.current_menu.pop
            @@menus.pop ## NEW
            cmenu.destroy
            #return :UNHANDLED
          end
        end
      when KEY_RIGHT
       $log.debug "RIGHTIN MENU : #{text}  "
       if cmenu.active_index
        if cmenu.items[cmenu.active_index].is_a?  Canis::Menu 
          #alert "could fire here cmenu: #{cmenu.text}, par: #{cmenu.parent.text} "
          cmenu.fire
          return
       #$log.debug "right IN MENU : #{cmenu.parent.class} len: #{cmenu.parent.current_menu.length}"
       #$log.debug "right IN MENU : #{cmenu.parent.class} len: #{cmenu.current_menu.length}"
        end
       end
       # This introduces a bug if no open items
       ret = cmenu.select_right_item # 2011-09-24 V1.3.1 attempt to goto right item if columns
       #alert "attempting to select right #{ret} "
        if ret == :UNHANDLED
          #if cmenu.parent.is_a? Canis::Menu and !cmenu.parent.current_menu.empty?
          if cmenu.parent.is_a? Canis::MenuBar #and !cmenu.current_menu.empty?
            $log.debug " ABOU TO DESTROY DUE TO RIGHT"
            cmenu.current_menu.pop
            @@menus.pop
            cmenu.destroy
            return :UNHANDLED
          end
        end
      else
        ret = check_mnemonics cmenu, ch
        return ret
      end
    end
399539
def help(subcommand=None):
    

    if not subcommand:
        print("blurb version", __version__)
        print()
        print("Management tool for CPython Misc/NEWS and Misc/NEWS.d entries.")
        print()
        print("Usage:")
        print("    blurb [subcommand] [options...]")
        print()

        # print list of subcommands
        summaries = []
        longest_name_len = -1
        for name, fn in subcommands.items():
            if name.startswith('-'):
                continue
            longest_name_len = max(longest_name_len, len(name))
            if not fn.__doc__:
                error("help is broken, no docstring for " + fn.__name__)
            fields = fn.__doc__.lstrip().split("\n")
            if not fields:
                first_line = "(no help available)"
            else:
                first_line = fields[0]
            summaries.append((name, first_line))
        summaries.sort()

        print("Available subcommands:")
        print()
        for name, summary in summaries:
            print(" ", name.ljust(longest_name_len), " ", summary)

        print()
        print("If blurb is run without any arguments, this is equivalent to 'blurb add'.")

        sys.exit(0)

    fn = get_subcommand(subcommand)
    doc = fn.__doc__.strip()
    if not doc:
        error("help is broken, no docstring for " + subcommand)

    options = []
    positionals = []

    nesting = 0
    for name, p in inspect.signature(fn).parameters.items():
        if p.kind == inspect.Parameter.KEYWORD_ONLY:
            short_option = name[0]
            options.append(f(" [-{short_option}|--{name}]"))
        elif p.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD:
            positionals.append(" ")
            has_default = (p.default != inspect._empty)
            if has_default:
                positionals.append("[")
                nesting += 1
            positionals.append(f("<{name}>"))
    positionals.append("]" * nesting)


    parameters = "".join(options + positionals)
    print(f("blurb {subcommand}{parameters}"))
    print()
    print(doc)
    sys.exit(0)
73356
void insertMacros(TokenList tokens ) {
        TokenList.Token t = tokens.getFirst();
        while( t != null ) {
            if( t.getType() == Type.WORD ) {
                Macro v = lookupMacro(t.word);
                if (v != null) {
                    TokenList.Token before = t.previous;
                    List<TokenList.Token> inputs = new ArrayList<TokenList.Token>();
                    t = parseMacroInput(inputs,t.next);

                    TokenList sniplet = v.execute(inputs);
                    tokens.extractSubList(before.next,t);
                    tokens.insertAfter(before,sniplet);
                    t = sniplet.last;
                }
            }
            t = t.next;
        }
    }
1226656
function blockCmdArrowNavigation() {
        if (Env.mac) {
          editor.on('keydown', function (e) {
            if (VK.metaKeyPressed(e) && !e.shiftKey && (e.keyCode == 37 || e.keyCode == 39)) {
              e.preventDefault();
              editor.selection.getSel().modify('move', e.keyCode == 37 ? 'backward' : 'forward', 'lineboundary');
            }
          });
        }
      }
804494
def ok(self, event=None):
        
        if not self.validate():
            self.initial_focus.focus_set()  # put focus back
            return

        # NOTE(amin): Using self.withdraw() here causes the
        # ui to hang until the window loses and regains
        # focus. There must be some blocking operation going
        # on, but after some digging, I haven't been able to
        # get any leads.

        # NOTE(amin): We must clear the main window's entry
        # before returning focus to it. Otherwise, rapid
        # pressing of the enter key will open multiple dialogs.
        self.entry_to_clear.delete(0, 'end')

        self.update_idletasks()

        try:
            self.apply()
        finally:
            self.cancel()
869176
function () {
            // Shortcuts
            var words = this.words;
            var sigBytes = this.sigBytes;

            // Clamp
            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
            words.length = Math.ceil(sigBytes / 4);
        }
1375020
@SuppressWarnings("deprecation")
    void findItemsWithShortcutForKey(List<MenuItem> items, int keyCode, KeyEvent event) {
        final boolean qwerty = isQwertyMode();
        final int metaState = event.getMetaState();
        final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
        // Get the chars associated with the keyCode (i.e using any chording combo)
        final boolean isKeyCodeMapped = event.getKeyData(possibleChars);
        // The delete key is not mapped to '\b' so we treat it specially
        if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) {
            return;
        }

        // Look for an item whose shortcut is this key.
        final int N = mItems.size();
        for (int i = 0; i < N; i++) {
            MenuItem item = mItems.get(i);
            if (item.hasSubMenu()) {
                ((Menu) item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event);
            }
            final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut();
            if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) &&
                    (shortcutChar != 0) &&
                    (shortcutChar == possibleChars.meta[0]
                            || shortcutChar == possibleChars.meta[2]
                            || (qwerty && shortcutChar == '\b' &&
                            keyCode == KeyEvent.KEYCODE_DEL)) &&
                    item.isEnabled()) {
                items.add(item);
            }
        }
    }
986767
function med(fn) {
    return function(e, k) {
      if (!self.keyboard.mediaKeysAreFKeys) {
        // Block Back, Forward, and Reload keys to avoid navigating away from
        // the current page.
        return (e.keyCode == 166 || e.keyCode == 167 || e.keyCode == 168) ?
            hterm.Keyboard.KeyActions.CANCEL :
            hterm.Keyboard.KeyActions.PASS;
      }
      return resolve(fn, e, k);
    };
  }
292887
def get_keyboard() -> types.InlineKeyboardMarkup:
    
    markup = types.InlineKeyboardMarkup()
    for post_id, post in POSTS.items():
        markup.add(
            types.InlineKeyboardButton(
                post['title'],
                callback_data=posts_cb.new(id=post_id, action='view'))
        )
    return markup
550090
function shortcutHandler(e) {
      if (e.keyCode == self.settings.shortcut.modifier) { isMod = true } // check for modifier press(default is alt key), save to var
      if (e.keyCode == 17) { isCtrl = true } // check for ctrl/cmnd press, in order to catch ctrl/cmnd + s
      if (e.keyCode == 18) { isCtrl = false }

      // Check for alt+p and make sure were not in fullscreen - default shortcut to switch to preview
      if (isMod === true && e.keyCode == self.settings.shortcut.preview && !self.is('fullscreen')) {
        e.preventDefault();
        if (self.is('edit') && self._previewEnabled) {
          self.preview();
        }
        else if (self._editEnabled) {
          self.edit();
        }
      }
      // Check for alt+f - default shortcut to make editor fullscreen
      if (isMod === true && e.keyCode == self.settings.shortcut.fullscreen && self._fullscreenEnabled) {
        e.preventDefault();
        self._goFullscreen(fsElement);
      }

      // Set the modifier key to false once *any* key combo is completed
      // or else, on Windows, hitting the alt key will lock the isMod state to true (ticket #133)
      if (isMod === true && e.keyCode !== self.settings.shortcut.modifier) {
        isMod = false;
      }

      // When a user presses "esc", revert everything!
      if (e.keyCode == 27 && self.is('fullscreen')) {
        self._exitFullscreen(fsElement);
      }

      // Check for ctrl + s (since a lot of people do it out of habit) and make it do nothing
      if (isCtrl === true && e.keyCode == 83) {
        self.save();
        e.preventDefault();
        isCtrl = false;
      }

      // Do the same for Mac now (metaKey == cmd).
      if (e.metaKey && e.keyCode == 83) {
        self.save();
        e.preventDefault();
      }

    }
927684
def column_keymap(self):
        
        keystates = set()

        shortcuts = self.cp.items('column_keymap')
        keymap_dict = dict(shortcuts)

        for combo, action in shortcuts:
            # add all possible prefixes to keystates
            combo_as_list = re.split('(<[A-Z].+?>|.)', combo)[1::2]
            if len(combo_as_list) > 1:
                keystates |= set(accumulate(combo_as_list[:-1]))

            if action in ['pri', 'postpone', 'postpone_s']:
                keystates.add(combo)

            if action == 'pri':
                for c in ascii_lowercase:
                    keymap_dict[combo + c] = 'cmd pri {} ' + c

        return (keymap_dict, keystates)