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

Function terminal_set

extern/editline/src/terminal.c:857–939  ·  view source on GitHub ↗

terminal_set(): * Read in the terminal capabilities from the requested terminal */

Source from the content-addressed store, hash-verified

855 * Read in the terminal capabilities from the requested terminal
856 */
857protected int
858terminal_set(EditLine *el, const char *term)
859{
860 int i;
861 char buf[TC_BUFSIZE];
862 char *area;
863 const struct termcapstr *t;
864 sigset_t oset, nset;
865 int lins, cols;
866
867 (void) sigemptyset(&nset);
868 (void) sigaddset(&nset, SIGWINCH);
869 (void) sigprocmask(SIG_BLOCK, &nset, &oset);
870
871 area = buf;
872
873
874 if (term == NULL)
875 term = getenv("TERM");
876
877 if (!term || !term[0])
878 term = "dumb";
879
880 if (strcmp(term, "emacs") == 0)
881 el->el_flags |= EDIT_DISABLED;
882
883 (void) memset(el->el_terminal.t_cap, 0, TC_BUFSIZE);
884
885 i = tgetent(el->el_terminal.t_cap, term);
886
887 if (i <= 0) {
888 if (i == -1)
889 (void) fprintf(el->el_errfile,
890 "Cannot read termcap database;\n");
891 else if (i == 0)
892 (void) fprintf(el->el_errfile,
893 "No entry for terminal type \"%s\";\n", term);
894 (void) fprintf(el->el_errfile,
895 "using dumb terminal settings.\n");
896 Val(T_co) = 80; /* do a dumb terminal */
897 Val(T_pt) = Val(T_km) = Val(T_li) = 0;
898 Val(T_xt) = Val(T_MT);
899 for (t = tstr; t->name != NULL; t++)
900 terminal_alloc(el, t, NULL);
901 } else {
902 /* auto/magic margins */
903 Val(T_am) = tgetflag("am");
904 Val(T_xn) = tgetflag("xn");
905 /* Can we tab */
906 Val(T_pt) = tgetflag("pt");
907 Val(T_xt) = tgetflag("xt");
908 /* do we have a meta? */
909 Val(T_km) = tgetflag("km");
910 Val(T_MT) = tgetflag("MT");
911 /* Get the size */
912 Val(T_co) = tgetnum("co");
913 Val(T_li) = tgetnum("li");
914 for (t = tstr; t->name != NULL; t++) {

Callers 2

FUN(el,set)Function · 0.85
terminal_initFunction · 0.85

Calls 5

terminal_allocFunction · 0.85
terminal_setflagsFunction · 0.85
terminal_get_sizeFunction · 0.85
terminal_change_sizeFunction · 0.85
terminal_bind_arrowFunction · 0.85

Tested by

no test coverage detected