/* * ex_map -- :map[!] [input] [replacement] * Map a key/string or display mapped keys. * * Historical note: * Historic vi maps were fairly bizarre, and likely to differ in * very subtle and strange ways from this implementation. Two * things worth noting are that vi would often hang or drop core * if the map was strange enough (ex: map X "xy$@x^V), or, simply * not work. One trick worth remembering is that if you put a * mark at the start of the map, e.g. map X mx"xy ...), or if you * put the map in a .exrc file, things would often work much better. * No clue why. * * PUBLIC: int ex_map __P((SCR *, EXCMD *)); */ int ex_map(SCR *sp, EXCMD *cmdp) { seq_t stype; CHAR_T *input, *p; stype = FL_ISSET(cmdp->iflags, E_C_FORCE) ? SEQ_INPUT : SEQ_COMMAND; switch (cmdp->argc) { case 0: if (seq_dump(sp, stype, 1) == 0) msgq(sp, M_INFO, stype == SEQ_INPUT ? "132|No input map entries" : "133|No command map entries"); return (0); case 2: input = cmdp->argv[0]->bp; break; default: abort(); } /* * If the mapped string is #[0-9]* (and wasn't quoted) then store the * function key mapping. If the screen specific routine has been set, * call it as well. Note, the SEQ_FUNCMAP type is persistent across * screen types, maybe the next screen type will get it right. */ if (input[0] == '#' && ISDIGIT((UCHAR_T)input[1])) { for (p = input + 2; ISDIGIT((UCHAR_T)*p); ++p); if (p[0] != '\0') goto nofunc; if (seq_set(sp, NULL, 0, input, cmdp->argv[0]->len, cmdp->argv[1]->bp, cmdp->argv[1]->len, stype, SEQ_FUNCMAP | SEQ_USERDEF)) return (1); return (sp->gp->scr_fmap == NULL ? 0 : sp->gp->scr_fmap(sp, stype, input, cmdp->argv[0]->len, cmdp->argv[1]->bp, cmdp->argv[1]->len)); } /* Some single keys may not be remapped in command mode. */ nofunc: if (stype == SEQ_COMMAND && input[1] == '\0') switch (KEY_VAL(sp, input[0])) { case K_COLON: case K_ESCAPE: case K_NL: msgq(sp, M_ERR, "134|The %s character may not be remapped", KEY_NAME(sp, input[0])); return (1); default: break; } return (seq_set(sp, NULL, 0, input, cmdp->argv[0]->len, cmdp->argv[1]->bp, cmdp->argv[1]->len, stype, SEQ_USERDEF)); }
void buttons_set_on(void) { // Only check state if writing gates or setting preset // This allows us to hold set to clear many notes at once or set a range of CV if (!state_set || active_mode == 0 || active_mode == 2) { state_set = !state_set; start_debounce(); if (active_pattern > 0) { switch (active_mode) { case 0: case 1: seq_set(active_pattern-1, active_mode); break; case 2: seq_set_cv(active_pattern-1, inputs_get(LVL)); break; case 3: seq_next_preset(active_pattern-1); break; } } else { // Set global gate length clock_set_gate_length(inputs_get(LVL)); } } }
/* * ex_abbr -- :abbreviate [key replacement] * Create an abbreviation or display abbreviations. * * PUBLIC: int ex_abbr __P((SCR *, EXCMD *)); */ int ex_abbr(SCR *sp, EXCMD *cmdp) { CHAR_T *p; size_t len; switch (cmdp->argc) { case 0: if (seq_dump(sp, SEQ_ABBREV, 0) == 0) msgq(sp, M_INFO, "105|No abbreviations to display"); return (0); case 2: break; default: abort(); } /* * Check for illegal characters. * * !!! * Another fun one, historically. See vi/v_ntext.c:txt_abbrev() for * details. The bottom line is that all abbreviations have to end * with a "word" character, because it's the transition from word to * non-word characters that triggers the test for an abbreviation. In * addition, because of the way the test is done, there can't be any * transitions from word to non-word character (or vice-versa) other * than between the next-to-last and last characters of the string, * and there can't be any <blank> characters. Warn the user. */ if (!inword(cmdp->argv[0]->bp[cmdp->argv[0]->len - 1])) { msgq(sp, M_ERR, "106|Abbreviations must end with a \"word\" character"); return (1); } for (p = cmdp->argv[0]->bp; *p != '\0'; ++p) if (ISBLANK((UCHAR_T)p[0])) { msgq(sp, M_ERR, "107|Abbreviations may not contain tabs or spaces"); return (1); } if (cmdp->argv[0]->len > 2) for (p = cmdp->argv[0]->bp, len = cmdp->argv[0]->len - 2; len; --len, ++p) if (inword(p[0]) != inword(p[1])) { msgq(sp, M_ERR, "108|Abbreviations may not mix word/non-word characters, except at the end"); return (1); } if (seq_set(sp, NULL, 0, cmdp->argv[0]->bp, cmdp->argv[0]->len, cmdp->argv[1]->bp, cmdp->argv[1]->len, SEQ_ABBREV, SEQ_USERDEF)) return (1); F_SET(sp->gp, G_ABBREV); return (0); }
static int handle_seq_set (seqhash_t *s, JSON in, JSON *outp) { const char *name; int64_t old, v; if (!Jget_str (in, "name", &name) || !Jget_int64 (in, "value", &v)) { errno = EPROTO; return (-1); } if ((Jget_int64 (in, "oldvalue", &old) && (seq_cmp_and_set (s, name, old, v) < 0)) || (seq_set (s, name, v) < 0)) return (-1); *outp = Jnew (); Jadd_str (*outp, "name", name); Jadd_bool (*outp, "set", true); Jadd_int64 (*outp, "value", v); return (0); }
void c_seq::push(char* data, int n, wisdom_IOStream& io, uint32 idelay) { SEQ_INIT(); c_wlock lock(&m_lock); leveldb::WriteOptions op; leveldb::WriteBatch bh; uint32 count = m_seq_head.g_count(); uint32 index = m_seq_head.g_index(); uint32 uptime = m_seq_head.g_uptime(); uint32 delay = m_seq_head.g_delay(); leveldb::Slice value(data, n); seq_set(bh, value); if (idelay > 0) m_seq_head.s_delay(idelay); seq_update(bh); if (c_base::write(op, bh)) { io->push(ZRESULT_OK); io->push(itostr(m_seq_head.g_index())); } else { m_seq_head.s_count(count); m_seq_head.s_index(index); m_seq_head.s_uptime(uptime); m_seq_head.s_delay(delay); io->push(ZRESULT_ERROR); io->push("write error."); } }