int distrib_buttons(int i, char **result, char *buffer, int *v) { if (buffer[0] == 10) return (-2); else if (buffer[0] == 27 && buffer[1] == 91) i = distrib_arrow(i, result, buffer, v); else if (buffer[0] == 127) *result = del_c(*result, &i); else if (buffer[0] == 9 && *result && i == ft_strlen(*result)) i = distrib_tab(i, result); else if (buffer[0] == 12) clear_and_prompt(); else if (buffer[0] == 1) i = ctrl_a(i, result); else if (buffer[0] == 5) i = ctrl_k(i, result); else if (buffer[0] == 21) { clear_line(i + 1, ft_strlen(*result)); *result = NULL; i = 0; } else if (buffer[0] == 4) ft_exit(NULL); else ft_putstr(tgetstr("le", NULL)); return (i); }
int main(int argc, char **argv) { switch(argv[1][0]) { case '0': out0(); break; case 'a': ctrl_a(); break; case 'n': makenonblock(); break; } return 0; }
void sbbs_t::mnemonics(char *str) { char *ctrl_a_codes; long l; if(!strchr(str,'~')) { mnestr=str; bputs(str); return; } ctrl_a_codes=strchr(str,1); if(!ctrl_a_codes) { if(str[0]=='@' && str[strlen(str)-1]=='@' && !strchr(str,' ')) { mnestr=str; bputs(str); return; } attr(cfg.color[clr_mnelow]); } l=0L; while(str[l]) { if(str[l]=='~' && str[l+1]!=0) { if(!term_supports(ANSI)) outchar('('); l++; if(!ctrl_a_codes) attr(cfg.color[clr_mnehigh]); outchar(str[l]); l++; if(!term_supports(ANSI)) outchar(')'); if(!ctrl_a_codes) attr(cfg.color[clr_mnelow]); } else { if(str[l]==CTRL_A /* ctrl-a */ && str[l+1]!=0) { /* valid */ ctrl_a(str[++l]); /* skip the ctrl-a */ l++; /* skip the attribute code */ } else outchar(str[l++]); } } if(!ctrl_a_codes) attr(cfg.color[clr_mnecmd]); }
int sbbs_t::bputs(const char *str) { int i; ulong l=0; if(online==ON_LOCAL && console&CON_L_ECHO) /* script running as event */ return(eprintf(LOG_INFO,"%s",str)); while(str[l] && online) { if(str[l]==CTRL_A && str[l+1]!=0) { l++; if(toupper(str[l])=='Z') /* EOF */ break; ctrl_a(str[l++]); continue; } if(str[l]=='@') { /* '@' */ if(str==mnestr /* Mnemonic string or */ || (str>=text[0] /* Straight out of TEXT.DAT */ && str<=text[TOTAL_TEXT-1])) { i=show_atcode(str+l); /* return 0 if not valid @ code */ l+=i; /* i is length of code string */ if(i) /* if valid string, go to top */ continue; } for(i=0;i<TOTAL_TEXT;i++) if(str==text[i]) break; if(i<TOTAL_TEXT) { /* Replacement text */ i=show_atcode(str+l); l+=i; if(i) continue; } } outchar(str[l++]); } return(l); }