📄 modes.c
字号:
/*** Copyright (C) 1991, 1997 Free Software Foundation, Inc.** ** This file is part of TACK.** ** TACK is free software; you can redistribute it and/or modify** it under the terms of the GNU General Public License as published by** the Free Software Foundation; either version 2, or (at your option)** any later version.** ** TACK is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the** GNU General Public License for more details.** ** You should have received a copy of the GNU General Public License** along with TACK; see the file COPYING. If not, write to** the Free Software Foundation, Inc., 59 Temple Place - Suite 330,** Boston, MA 02111-1307, USA.*/#include <tack.h>MODULE_ID("$Id: modes.c,v 1.1 1998/01/10 00:29:53 tom Exp $")/* * Tests boolean flags and terminal modes. */static void subtest_os(struct test_list *, int *, int *);static void subtest_rmam(struct test_list *, int *, int *);static void subtest_smam(struct test_list *, int *, int *);static void subtest_am(struct test_list *, int *, int *);static void subtest_ul(struct test_list *, int *, int *);static void subtest_uc(struct test_list *, int *, int *);static void subtest_bw(struct test_list *, int *, int *);static void subtest_xenl(struct test_list *, int *, int *);static void subtest_eo(struct test_list *, int *, int *);static void subtest_xmc(struct test_list *, int *, int *);static void subtest_xhp(struct test_list *, int *, int *);static void subtest_mir(struct test_list *, int *, int *);static void subtest_msgr(struct test_list *, int *, int *);static void subtest_tbc(struct test_list *, int *, int *);static void subtest_xt(struct test_list *, int *, int *);static void subtest_hts(struct test_list *, int *, int *);static void subtest_cbt(struct test_list *, int *, int *);static void subtest_in(struct test_list *, int *, int *);static void subtest_dadb(struct test_list *, int *, int *);struct test_list mode_test_list[] = { {0, 0, 0, 0, "e) edit terminfo", 0, &edit_menu}, {MENU_NEXT, 3, "os", 0, 0, subtest_os, 0}, {MENU_NEXT, 1, "rmam", 0, 0, subtest_rmam, 0}, {MENU_NEXT, 1, "smam", 0, 0, subtest_smam, 0}, {MENU_NEXT, 1, "am", 0, 0, subtest_am, 0}, {MENU_NEXT, 3, "ul", 0, 0, subtest_ul, 0}, {MENU_NEXT, 3, "uc", 0, 0, subtest_uc, 0}, {MENU_NEXT, 3, "bw", 0, 0, subtest_bw, 0}, {MENU_NEXT, 4, "xenl", 0, 0, subtest_xenl, 0}, {MENU_NEXT, 3, "eo", 0, 0, subtest_eo, 0}, {MENU_NEXT, 3, "xmc", 0, 0, subtest_xmc, 0}, {MENU_NEXT, 3, "xhp", 0, 0, subtest_xhp, 0}, {MENU_NEXT, 6, "mir", 0, 0, subtest_mir, 0}, {MENU_NEXT, 6, "msgr", 0, 0, subtest_msgr, 0}, {MENU_NEXT | MENU_CLEAR, 0, "tbc", "it", 0, subtest_tbc, 0}, {MENU_NEXT | MENU_CLEAR, 0, "hts", "it", 0, subtest_hts, 0}, {MENU_NEXT, 4, "xt", "it", 0, subtest_xt, 0}, {MENU_NEXT, 1, "cbt", "it", 0, subtest_cbt, 0}, {MENU_NEXT, 6, "in", 0, 0, subtest_in, 0}, {MENU_NEXT, 1, "da) (db", 0, 0, subtest_dadb, 0}, {MENU_LAST, 0, 0, 0, 0, 0, 0}};/*** subtest_os(test_list, status, ch)**** test over strike mode (os)*/static voidsubtest_os( struct test_list *t, int *state, int *ch){ ptext("(os) should be true, not false."); put_cr(); ptextln("(os) should be false."); sprintf(temp, "(os) over-strike is %s in the data base. ", over_strike ? "true" : "false"); ptext(temp); generic_done_message(t, state, ch);}/*** subtest_rmam(test_list, status, ch)**** test exit automatic margins mode (rmam)*/static voidsubtest_rmam( struct test_list *t, int *state, int *ch){ int j; if (!exit_am_mode) { ptext("(rmam) not present. "); } else if (!can_go_home) { ptext("(rmam) not tested, no way to home cursor. "); } else if (over_strike) { put_clear(); go_home(); tc_putp(exit_am_mode); ptext("\n(rmam) will reset (am)"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(rmam) will not reset (am)"); go_home(); put_newlines(2); } else { put_clear(); go_home(); tc_putp(exit_am_mode); ptext("\n(rmam) will reset (am)"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(rmam) will not reset (am) "); go_home(); put_str(" "); go_home(); put_newlines(2); } ptext("Exit-automatic-margins "); generic_done_message(t, state, ch);}/*** subtest_smam(test_list, status, ch)**** test enter automatic margins mode (smam)*/static voidsubtest_smam( struct test_list *t, int *state, int *ch){ int i, j; if (!enter_am_mode) { ptext("(smam) not present. "); } else if (!can_go_home) { ptext("(smam) not tested, no way to home cursor. "); } else if (over_strike) { put_clear(); go_home(); tc_putp(enter_am_mode); ptext("\n(smam) will "); i = char_count; ptext("not set (am)"); go_home(); for (j = -i; j < columns; j++) put_this(' '); put_str("@@@"); put_newlines(2); } else { put_clear(); go_home(); tc_putp(enter_am_mode); ptext("\n(smam) will not set (am)"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(smam) will set (am) "); go_home(); put_str(" "); put_newlines(2); } ptext("Enter-automatic-margins "); generic_done_message(t, state, ch);}/*** subtest_am(test_list, status, ch)**** test automatic margins (am)*/static voidsubtest_am( struct test_list *t, int *state, int *ch){ int i, j; if (!can_go_home) { ptextln("(am) not tested, no way to home cursor. "); } else if (over_strike) { put_clear(); go_home(); ptext("\n(am) should "); i = char_count; ptext("not be set"); go_home(); for (j = -i; j < columns; j++) put_this(' '); put_str("@@@"); go_home(); put_newlines(2); sprintf(temp, "(am) is %s in the data base", auto_right_margin ? "true" : "false"); ptextln(temp); } else { put_clear(); go_home(); ptext("\n(am) should not be set"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(am) should be set "); go_home(); put_str(" \n\n"); sprintf(temp, "(am) is %s in the data base", auto_right_margin ? "true" : "false"); ptextln(temp); } ptext("Automatic-right-margin "); generic_done_message(t, state, ch);}/* Note: uprint() sends underscore back-space character, and ucprint() sends character back-space underscore. *//*** uprint(string)**** underline string for (ul) test*/static voiduprint(const char *s){ if (s) { while (*s) { put_str("_\b"); putchp(*s++); } }}/*** ucprint(string)**** underline string for (uc) test*/static voiducprint(const char *s){ if (s) { while (*s) { putchp(*s++); putchp('\b'); tc_putp(underline_char); } }}/*** subtest_ul(test_list, status, ch)**** test transparent underline (ul)*/static voidsubtest_ul( struct test_list *t, int *state, int *ch){ if (!over_strike) { /* (ul) is used only if (os) is reset */ put_crlf(); sprintf(temp, "This text should %sbe underlined.", transparent_underline ? "" : "not "); uprint(temp); put_crlf(); ptextln("If the above line is not underlined the (ul) should be false."); sprintf(temp, "(ul) Transparent-underline is %s in the data base", transparent_underline ? "true" : "false"); ptextln(temp); generic_done_message(t, state, ch); }}/*** subtest_uc(test_list, status, ch)**** test underline character (uc)*/static voidsubtest_uc( struct test_list *t, int *state, int *ch){ if (!over_strike) { if (underline_char) { ucprint("This text should be underlined."); put_crlf(); ptextln("If the above text is not underlined the (uc) has failed."); ptext("Underline-character "); } else { ptext("(uc) underline-character is not defined. "); } generic_done_message(t, state, ch); }}/*** subtest_bw(test_list, status, ch)**** test auto left margin (bw)*/static voidsubtest_bw( struct test_list *t, int *state, int *ch){ int i, j; if (over_strike) { /* test (bw) */ ptext("\n(bw) should "); i = char_count; ptextln("not be set."); for (j = i; j < columns; j++) put_str("\b"); put_str("@@@"); put_crlf(); sprintf(temp, "(bw) Auto-left-margin is %s in the data base", auto_left_margin ? "true" : "false"); ptextln(temp); } else { /* test (bw) */ ptextln("(bw) should not be set."); for (i = 12; i < columns; i++) put_str("\b"); if (delete_character) { for (i = 0; i < 4; i++) tc_putp(delete_character); } else { put_str(" "); } put_crlf(); sprintf(temp, "(bw) Auto-left-margin is %s in the data base", auto_left_margin ? "true" : "false"); ptextln(temp); } generic_done_message(t, state, ch);}/*** subtest_tbc(test_list, status, ch)**** test clear tabs (tbc)*/static voidsubtest_tbc( struct test_list *t, int *state, int *ch){ int tabat; /* the tab spacing we end up with */ int i; if (clear_all_tabs && !set_tab) { ptext("(tbc) Clear-all-tabs is defined but (hts) set-tab is not. "); ptext("Once the tabs are cleared there is no way to set them. "); } else if (clear_all_tabs) { tabat = set_tab ? 8 : init_tabs; tc_putp(clear_all_tabs); ptext("Clear tabs (tbc)"); go_home(); put_crlf(); putchp('\t'); putchp('T'); go_home(); put_newlines(2); for (i = 0; i < columns; i++) { if (i == tabat) { putchp('T'); } else { putchp('.'); } } go_home(); ptext("\n\n\nIf the above two lines have T's in the same column then (tbc) has failed. "); } else { ptext("(tbc) Clear-all-tabs is not defined. "); } generic_done_message(t, state, ch);}/*** subtest_hts(test_list, status, ch)**** (ht) and set tabs with (hts)*/static voidsubtest_hts( struct test_list *t, int *state, int *ch){ int tabat; /* the tab spacing we end up with */ int i; tabat = init_tabs; if (set_tab) { ptext("Tabs set with (hts)"); put_crlf(); for (i = 1; i < columns; i++) { if (i % 8 == 1) { tc_putp(set_tab); } putchp(' '); } tabat = 8; } else { sprintf(temp, "(hts) Set-tabs not defined. (it) Initial-tabs at %d", init_tabs); ptext(temp); } go_home(); put_newlines(2); if (tabat <= 0) { tabat = 8; } for (i = tabat; i < columns; i += tabat) { putchp('\t'); putchp('T'); } go_home(); put_newlines(3); for (i = 1; i < columns; i++) { putchp('.'); } go_home(); put_newlines(3); for (i = tabat; i < columns; i += tabat) { putchp('\t');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -