⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smgtest.c

📁 一个C格式的脚本处理函数库源代码,可让你的C程序具有执行C格式的脚本文件
💻 C
📖 第 1 页 / 共 2 页
字号:
	SLsmg_set_color (color); color++; color = color % NUM_COLORS;	SLsmg_fill_region (r0, c0, dr0, dc0, ' ');	SLsmg_set_color (color); color++; color = color % NUM_COLORS;	SLsmg_fill_region (r0, c1, dr0, dc1, ' ');	SLsmg_set_color (color); color++; color = color % NUM_COLORS;	SLsmg_fill_region (r1, c0, dr1, dc0, ' ');	SLsmg_set_color (color); color++; color = color % NUM_COLORS;	SLsmg_fill_region (r1, c1, dr1, dc1, ' ');		SLsmg_refresh ();     }   while (0 == SLang_input_pending (30));   SLsmg_set_color (0);   post_test ();}static void alt_char_test (void){   int row, col;   int ch;      pre_test ("Alternate Charset Test");      row = SLtt_Screen_Rows / 2 - 2;   col = 0;   for (ch = 32; ch < 128; ch++)     {	SLsmg_gotorc (row, col);	SLsmg_write_char (ch);	SLsmg_gotorc (row + 1, col);	SLsmg_set_char_set (1);	SLsmg_write_char (ch);	SLsmg_set_char_set (0);	col++;		if (col > 40)	  {	     col = 0;	     row += 4;	  }     }      post_test ();}typedef struct {   char *name;   unsigned char value;}Draw_Symbols_Type;static Draw_Symbols_Type Draw_Symbols [] = {     {"SLSMG_HLINE_CHAR",		SLSMG_HLINE_CHAR},     {"SLSMG_VLINE_CHAR",		SLSMG_VLINE_CHAR},     {"SLSMG_ULCORN_CHAR",		SLSMG_ULCORN_CHAR},     {"SLSMG_URCORN_CHAR",		SLSMG_URCORN_CHAR},     {"SLSMG_LLCORN_CHAR",		SLSMG_LLCORN_CHAR},     {"SLSMG_LRCORN_CHAR",		SLSMG_LRCORN_CHAR},     {"SLSMG_RTEE_CHAR",		SLSMG_RTEE_CHAR},     {"SLSMG_LTEE_CHAR",		SLSMG_LTEE_CHAR},     {"SLSMG_UTEE_CHAR",		SLSMG_UTEE_CHAR},     {"SLSMG_DTEE_CHAR",		SLSMG_DTEE_CHAR},     {"SLSMG_PLUS_CHAR",		SLSMG_PLUS_CHAR},     {"SLSMG_CKBRD_CHAR",		SLSMG_CKBRD_CHAR},     {"SLSMG_DIAMOND_CHAR",		SLSMG_DIAMOND_CHAR},     {"SLSMG_DEGREE_CHAR",		SLSMG_DEGREE_CHAR},     {"SLSMG_PLMINUS_CHAR",		SLSMG_PLMINUS_CHAR},     {"SLSMG_BULLET_CHAR",		SLSMG_BULLET_CHAR},     {"SLSMG_LARROW_CHAR",		SLSMG_LARROW_CHAR},     {"SLSMG_RARROW_CHAR",		SLSMG_RARROW_CHAR},     {"SLSMG_DARROW_CHAR",		SLSMG_DARROW_CHAR},     {"SLSMG_UARROW_CHAR",		SLSMG_UARROW_CHAR},     {"SLSMG_BOARD_CHAR",		SLSMG_BOARD_CHAR},     {"SLSMG_BLOCK_CHAR",		SLSMG_BLOCK_CHAR},     {NULL}};static void draw_symbols_test (void){   int row, col;   Draw_Symbols_Type *d;      pre_test ("Alternate Charset Test");      row = 3;   col = 3;   d = Draw_Symbols;   while (d->name != NULL)     {	SLsmg_gotorc (row, col);	SLsmg_set_char_set (1);	SLsmg_write_char ((char) d->value);	SLsmg_set_char_set (0);	SLsmg_printf (":%s", d->name);	col += 40;	if (col >= 80)	  {	     col = 3;	     row++;	  }	d++;     }   post_test ();}static void line_test (void){   int row, col;   pre_test ("Line Test");      row = 4;   col = 2;   SLsmg_gotorc (row, col);   SLsmg_draw_hline (10);   SLsmg_write_string ("Result of SLsmg_draw_hline(10)");   SLsmg_draw_vline (5);   SLsmg_write_string ("Result of SLsmg_draw_vline(5)");   post_test ();}static void do_esc_seq_test (char *testname){   int row;   unsigned char ch;   unsigned char buf[80], *b;      pre_test (testname);   while (1)     {	row = SLtt_Screen_Rows / 2;   	SLsmg_gotorc (row, 0);	SLsmg_write_string ("Press key: (RETURN quits)");	SLsmg_refresh ();   	ch = SLang_getkey ();	SLang_ungetkey (ch);	if (ch == '\r')	  break;	SLsmg_gotorc (row+1, 0);	SLsmg_write_string ("Key returned \"");	b = buf;	do	  {	     ch = SLang_getkey ();	     if (ch < ' ')	       {		  *b++ = '^';		  ch += '@';		  *b++ = ch;	       }	     else if (ch >= 127)	       {		  sprintf ((char *) b, "\\x%02X", ch);		  b += strlen ((char *) b);	       }	     else if ((ch == '"') || (ch == '\\'))	       {		  *b++ = '\\';		  *b++ = ch;	       }	     else *b++ = ch;	  }	while (SLang_input_pending (3) > 0);	*b++ = '"';	*b = 0;	SLsmg_write_string ((char *) buf);	SLsmg_erase_eol ();	SLsmg_refresh ();     }      post_test ();}static void esc_seq_test (void){#ifdef IBMPC_SYSTEM   SLgetkey_map_to_ansi (0);#endif   do_esc_seq_test ("Escape Sequence Report");}#ifdef IBMPC_SYSTEMstatic void ansi_esc_seq_test (void){   SLgetkey_map_to_ansi (1);   do_esc_seq_test ("ANSI Escape Sequence Report");}#endifstatic void mouse_test (void){   int row;   int b, x, y;   pre_test ("Mouse Test");      row = SLtt_Screen_Rows / 2;      SLsmg_gotorc (row, 0);   SLsmg_write_string ("Click Mouse: ");   SLsmg_refresh ();   if ((27 != SLang_getkey ())       || ('[' != SLang_getkey ())       || ('M' != SLang_getkey ()))     {	SLsmg_gotorc (row, 0);	SLsmg_write_string ("That did not appear to be a mouse escape sequence");	post_test ();	return;     }      b = SLang_getkey () - ' ';   x = SLang_getkey () - ' ';   y = SLang_getkey () - ' ';      SLsmg_gotorc (row, 0);      SLsmg_printf ("Button: %d     ", b);   SLsmg_gotorc (row + 1, 0);  SLsmg_printf ("Column: %d", x);   SLsmg_gotorc (row + 2, 0);  SLsmg_printf ("   Row: %d", y);   post_test ();}static void mono_test (void){   int row;   int c;   c = SLtt_Use_Ansi_Colors;   SLtt_Use_Ansi_Colors = 0;   SLsmg_normal_video ();   SLsmg_cls ();   pre_test ("Mono Test");   row = SLtt_Screen_Rows / 2;   SLsmg_set_color(1);   SLsmg_gotorc (row, 0);      /* Make a gap for testing erase_eol in bw mode */   SLsmg_write_string ("This line");   SLsmg_set_color (2);   SLsmg_erase_eol ();   SLsmg_gotorc (row, 30);   SLsmg_write_string ("should be in reverse video");   SLsmg_refresh ();   (void) SLkp_getkey ();   SLsmg_gotorc (row, 20);   SLsmg_write_string ("xxxxx");   SLsmg_refresh ();   post_test ();   SLtt_Use_Ansi_Colors = c;}static void low_level_test (void){   int mid, bot;   int r;   if (SLtt_Term_Cannot_Scroll)     {	pre_test ("Sorry!  Your terminal lacks scrolling capability.");	post_test ();	return;     }   if (-1 == SLsmg_suspend_smg ())     SLang_exit_error ("SLsmg_suspend_smg failed");      if (-1 == SLtt_init_video ())     SLang_exit_error ("SLang_init_video failed");   SLtt_get_screen_size ();   mid = SLtt_Screen_Rows/2;   bot = SLtt_Screen_Rows - 1;   SLtt_cls ();   SLtt_goto_rc (0, 0);   SLtt_write_string ("The following set of tests are designed to test the display system.");   SLtt_goto_rc (1, 0);   SLtt_write_string ("There should be a line of text in the middle and one at the bottom.");   SLtt_goto_rc (mid, 0);   SLtt_write_string ("This line is in the middle.");   SLtt_goto_rc (bot, 0);   SLtt_write_string ("This line is at the bottom.");      SLtt_goto_rc (2, 0);    SLtt_write_string ("Press return now.");   SLtt_flush_output ();   SLang_flush_input ();   (void) SLang_getkey ();      SLtt_goto_rc (2, 0);   SLtt_write_string ("The middle row should slowly move down next the bottom and then back up.");   SLtt_goto_rc (mid - 1, 0);   SLtt_write_string ("This line should not move.");   SLtt_goto_rc (mid + 1, 0);   SLtt_write_string ("This line should vanish at the bottom");   SLtt_goto_rc (mid + 1, SLtt_Screen_Cols - 5);   SLtt_write_string ("End->");   SLtt_flush_output ();   SLtt_set_scroll_region (mid, bot - 1);      r = (bot - mid) - 1;   while (r > 0)     {	(void) SLang_input_pending (2); /* 3/10 sec delay */	SLtt_goto_rc (0,0);		       /* relative to scroll region */	SLtt_reverse_index (1);	SLtt_flush_output ();	r--;     }      r = (bot - mid) - 1;   while (r > 0)     {	(void) SLang_input_pending (2); /* 3/10 sec delay */	SLtt_goto_rc (0,0);		       /* relative to scroll region */	SLtt_delete_nlines (1);	SLtt_flush_output ();	r--;     }      SLtt_reset_scroll_region ();   SLtt_goto_rc (mid - 1, 0);   SLtt_write_string ("Now the bottom will come up and clear the lines below");      SLtt_set_scroll_region (mid, bot);   r = (bot - mid) + 1;   while (r > 0)     {	(void) SLang_input_pending (2); /* 3/10 sec delay */	SLtt_goto_rc (0,0);		       /* relative to scroll region */	SLtt_delete_nlines (1);	SLtt_flush_output ();	r--;     }   SLtt_reset_scroll_region ();   SLtt_goto_rc (3,0);   SLtt_write_string ("This line will go down and vanish");   SLtt_set_scroll_region (3, mid - 2);   r = ((mid - 2) - 3) + 1;   while (r > 0)     {	(void) SLang_input_pending (3); /* 3/10 sec delay */	SLtt_goto_rc (0,0);		       /* relative to scroll region */	SLtt_reverse_index (1);	SLtt_flush_output ();	r--;     }         SLtt_reset_scroll_region ();   SLtt_set_scroll_region (1,1); SLtt_goto_rc (0,0);   SLtt_delete_nlines (1);   SLtt_reset_scroll_region ();   SLtt_set_scroll_region (2,2); SLtt_goto_rc (0,0);   SLtt_reverse_index (1);   SLtt_reset_scroll_region ();   SLtt_goto_rc (1, 10);   SLtt_write_string ("Press Any Key To Continue.");   SLtt_flush_output ();   r = 15;   if (0 == SLtt_Term_Cannot_Insert) while (r)     {	r--;	SLtt_goto_rc (1, 0);	SLtt_begin_insert ();	SLtt_putchar (' ');	SLtt_end_insert ();	SLtt_flush_output ();	SLang_input_pending (2);     }      SLang_flush_input ();   (void) SLang_getkey ();         SLtt_reset_video ();   SLsmg_resume_smg ();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -