Exemplo n.º 1
0
 void operator()(Mint& interp, bool is_active, const MintArgList& args) {
     bool found;
     const MintString& formName = args[1].getValue();
     const MintForm& frm = interp.getForm(formName, &found);
     if (found) {
         const MintString& arg2 = args[2].getValue();
         MintString::const_iterator s = frm.begin() + frm.getPos();
         MintString::const_iterator f = arg2.empty() ? frm.end() : std::search(s, frm.end(), arg2.begin(), arg2.end());
         if (f != frm.end()) {
             interp.setFormPos(formName, (f - frm.begin()) + arg2.size());
             interp.returnString(is_active, MintString(s, f));
         } else {
             interp.returnString(true, args[3].getValue());
         } // else
     } else {
         interp.returnNull(is_active);
     } // else
 } // operator()
Exemplo n.º 2
0
MintString getStringIntPrefix(const MintString& s, int base) {
    // Max base uses all digits + letters
    base = std::max(2, std::min(base, 36));
    mintchar_t end_number = '0' + std::min(10, base);
    mintchar_t end_letter = 'A' + std::max(0, base - 10);
    MintString::const_iterator plast = s.end();
    while (plast != s.begin()) {
        --plast;
        mintchar_t ch = std::toupper(*plast);
        if ((ch >= '0' && ch < end_number) || (ch >= 'A' && ch < end_letter)) {
            // This digit is OK, get another one
        } else {
            // Skip the minus sign if we have one
            if (ch != '-') {
                ++plast;
            } // if
            break;
        } // else
    } // for
    return MintString(s.begin(), plast);
} // getStringIntPrefix
Exemplo n.º 3
0
EmacsWindowWin32::EmacsWindowWin32()
    : _overwriting(false), _ovy(0), _ovx(0),
      _curr_colour_pair(0),
      _fore(15), _back(0),
      _wsp_fore(15), _show_wsp(false),
      _ctrl_fore(11),
      _old_fore(-1), _old_back(-1),
      _botScrollPercent(0), _topScrollPercent(0) {
    hStdIn = ::GetStdHandle(STD_INPUT_HANDLE);
    if (hStdIn != INVALID_HANDLE_VALUE)
        ::SetConsoleMode(hStdIn, ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT);
    hStdOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
    if (hStdOut != INVALID_HANDLE_VALUE) {
        ::SetConsoleMode(hStdOut, 0);
        _has_colours = true;
    } else {
        _has_colours = false;
    }
    clearConsole();

    // Fill out the defaults
    _decode_key[0x00] = MintString("C-@");
    for (mintchar_t i = 1; i < 32; ++i) {
        MintString key("C-");
        key.append(1, static_cast<mintchar_t>(i+'a'-1));
        _decode_key[i] = key;
    } // for
    for (mintchar_t i = 32; i < 127; ++i) {
        _decode_key[i] = MintString(1, i);
    } // for
    // Now fill in the specials
    _decode_key['\b'] = MintString("Back Space");
    _decode_key['\t'] = MintString("Tab");
    _decode_key['\n'] = MintString("Return");
    _decode_key['\r'] = MintString("Return");
    _decode_key[0x1B] = MintString("Escape");
    // ASCII keys that are inconvenient to do in ASCII
    _decode_key[','] = MintString("Comma");
    _decode_key['('] = MintString("LPar");
    _decode_key[')'] = MintString("RPar");
    // NCURSES decodes
    _decode_key[VK_DOWN     ] = MintString("Down Arrow");
    _decode_key[KEY_UP       ] = MintString("Up Arrow");
    _decode_key[KEY_LEFT     ] = MintString("Left Arrow");
    _decode_key[KEY_RIGHT    ] = MintString("Right Arrow");
    _decode_key[KEY_HOME     ] = MintString("Home");
    _decode_key[KEY_BACKSPACE] = MintString("Back Space");
    _decode_key[KEY_F(1)     ] = MintString("F1");
    _decode_key[KEY_F(2)     ] = MintString("F2");
    _decode_key[KEY_F(3)     ] = MintString("F3");
    _decode_key[KEY_F(4)     ] = MintString("F4");
    _decode_key[KEY_F(5)     ] = MintString("F5");
    _decode_key[KEY_F(6)     ] = MintString("F6");
    _decode_key[KEY_F(7)     ] = MintString("F7");
    _decode_key[KEY_F(8)     ] = MintString("F8");
    _decode_key[KEY_F(9)     ] = MintString("F9");
    _decode_key[KEY_F(10)    ] = MintString("F10");
    _decode_key[KEY_F(11)    ] = MintString("F11");
    _decode_key[KEY_F(12)    ] = MintString("F12");
    _decode_key[KEY_F(13)    ] = MintString("S-F1");
    _decode_key[KEY_F(14)    ] = MintString("S-F2");
    _decode_key[KEY_F(15)    ] = MintString("S-F3");
    _decode_key[KEY_F(16)    ] = MintString("S-F4");
    _decode_key[KEY_F(17)    ] = MintString("S-F5");
    _decode_key[KEY_F(18)    ] = MintString("S-F6");
    _decode_key[KEY_F(19)    ] = MintString("S-F7");
    _decode_key[KEY_F(20)    ] = MintString("S-F8");
    _decode_key[KEY_F(21)    ] = MintString("S-F9");
    _decode_key[KEY_F(22)    ] = MintString("S-F10");
    _decode_key[KEY_F(23)    ] = MintString("S-F11");
    _decode_key[KEY_F(24)    ] = MintString("S-F12");
    _decode_key[KEY_DC       ] = MintString("Del");
    _decode_key[KEY_IC       ] = MintString("Ins");
    _decode_key[KEY_NPAGE    ] = MintString("Pg Dn");
    _decode_key[KEY_PPAGE    ] = MintString("Pg Up");
    _decode_key[KEY_END      ] = MintString("End");
} // EmacsWindow