MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / terminal_insertwrite

Function terminal_insertwrite

extern/editline/src/terminal.c:738–791  ·  view source on GitHub ↗

terminal_insertwrite(): * Puts terminal in insert character mode or inserts num * characters in the line * Assumes MB_FILL_CHARs are present to keep column count correct */

Source from the content-addressed store, hash-verified

736 * Assumes MB_FILL_CHARs are present to keep column count correct
737 */
738protected void
739terminal_insertwrite(EditLine *el, Char *cp, int num)
740{
741 if (num <= 0)
742 return;
743 if (!EL_CAN_INSERT) {
744#ifdef DEBUG_EDIT
745 (void) fprintf(el->el_errfile, " ERROR: cannot insert \n");
746#endif /* DEBUG_EDIT */
747 return;
748 }
749 if (num > el->el_terminal.t_size.h) {
750#ifdef DEBUG_SCREEN
751 (void) fprintf(el->el_errfile,
752 "StartInsert: num is riduculous: %d\r\n", num);
753#endif /* DEBUG_SCREEN */
754 return;
755 }
756 if (GoodStr(T_IC)) /* if I have multiple insert */
757 if ((num > 1) || !GoodStr(T_ic)) {
758 /* if ic would be more expensive */
759 terminal_tputs(el, tgoto(Str(T_IC), num, num), num);
760 terminal_overwrite(el, cp, (size_t)num);
761 /* this updates el_cursor.h */
762 return;
763 }
764 if (GoodStr(T_im) && GoodStr(T_ei)) { /* if I have insert mode */
765 terminal_tputs(el, Str(T_im), 1);
766
767 el->el_cursor.h += num;
768 do
769 terminal__putc(el, *cp++);
770 while (--num);
771
772 if (GoodStr(T_ip)) /* have to make num chars insert */
773 terminal_tputs(el, Str(T_ip), 1);
774
775 terminal_tputs(el, Str(T_ei), 1);
776 return;
777 }
778 do {
779 if (GoodStr(T_ic)) /* have to make num chars insert */
780 terminal_tputs(el, Str(T_ic), 1);
781
782 terminal__putc(el, *cp++);
783
784 el->el_cursor.h++;
785
786 if (GoodStr(T_ip)) /* have to make num chars insert */
787 terminal_tputs(el, Str(T_ip), 1);
788 /* pad the inserted char */
789
790 } while (--num);
791}
792
793
794/* terminal_clear_EOL():

Callers 1

re_update_lineFunction · 0.85

Calls 4

terminal_tputsFunction · 0.85
StrClass · 0.85
terminal_overwriteFunction · 0.85
terminal__putcFunction · 0.85

Tested by

no test coverage detected