text entry

funny little text-entry tool for user interfacing, with a cute flashing cursor
Author: Robert Schirmer
License: BSD
Github: rbrt/string/text entry.axo

Inlets

bool32.rising add a character

bool32.rising like delete but different

bool32.rising delete a character

bool32.rising up one character

bool32.rising down one character

bool32.rising clears the text

Outlets

bool32 trigger when 'disp' changes

charptr32 to display

charptr32 without the cursor

Attributes

spinner maximum length

spinner set character for flashing

combo enable flash

Declaration
char cout[attr_maxLength + 1];
char cdisp[attr_maxLength + 1];
uint8_t pos;
bool trig;
uint8_t c;
uint16_t count;
bool toggle;
bool disptrig;
bool init;
Init
memset(&cout[0], 32, 8);
c = 17;
init = 1;
Control Rate
disptrig = 0;
if ((inlet_add || inlet_inc || inlet_dec || init) && !trig) {
  if (inlet_add && (pos < (attr_maxLength - 1)))
    pos++;
  if (inlet_inc)
    c++;
  if (inlet_dec)
    c--;
  c = c % 43;
  cout[pos] = c + 48;
  cout[pos + 1] = '\0';
  strcpy(cdisp, cout);
  init = 0;
  trig = 1;
}

if ((inlet_delete || inlet_undoAdd) && !trig && (pos > 0)) {
  trig = 1;
  cout[pos] = '\0';
  pos--;
  if (!inlet_undoAdd)
    c = cout[pos] - 48;
  strcpy(cdisp, cout);
}

if (inlet_clear && !trig) {
  memset(&cout[0], 32, 8);
  c = 17;
  pos = 0;
  init = 1;
  trig = 1;
}

if (!inlet_add && !inlet_inc && !inlet_dec && !inlet_delete && !inlet_undoAdd &&
    !inlet_clear)
  trig = 0;

if (!count && attr_flash) {
  count = attr_flash;
  toggle = !toggle;
  cdisp[pos] = (toggle) ? attr_char : cout[pos];
  disptrig = 1;
}
count--;

outlet_trig = trig || disptrig;
outlet_disp = &cdisp[0];
outlet_out = &cout[0];

Privacy

© 2024 Zrna Research