📄 main.c
字号:
message = buff; } SAVE_LINE( line ); set_prompt( message, line ); getkey( ); RESTORE_LINE( line ); if (g_status.wrapped) { g_status.wrapped = FALSE; show_search_message( CLR_SEARCH ); }}/* * Name: terminate * Purpose: To free all dynamic structures and unload anything we loaded * Date: June 5, 1991 */void terminate( void ){register TDE_WIN *wp; /* register for scanning windows */TDE_WIN *w; /* free window */register file_infos *fp; /* register for scanning files */file_infos *f; /* free files */int i; /* * free the file structures, if not already free. */ fp = g_status.file_list; while (fp != NULL) { f = fp; fp = fp->next; free( f ); } /* * free the window structures, if not already free. */ wp = g_status.window_list; while (wp != NULL) { w = wp; wp = wp->next; free( w ); } /* * free any character classes in the nfa's. */ for (i=0; i < REGX_SIZE; i++) { if (sas_nfa.class[i] == nfa.class[i] && nfa.class[i] != NULL) free( nfa.class[i] ); else if (sas_nfa.class[i] != NULL) free( sas_nfa.class[i] ); else if (nfa.class[i] != NULL) free( nfa.class[i] ); } /* * free all the memory allocations. */ if (g_status.memory != NULL) { for (i = g_status.mem_num; --i >= 0;) free( g_status.memory[i].base ); free( g_status.memory ); }#if defined( __MSDOS__ ) /* * jmh 021021: restore the initial cwd if tracking paths. */ if (mode.track_path) set_current_directory( init_wd );#endif /* * restore the overscan (border) color */ if (g_display.adapter != MDA) set_overscan_color( g_display.old_overscan ); console_exit( );}/* * Name: initialize * Purpose: To initialize all the screen status info that is not hardware * dependent, and call the hardware initialization routine to * pick up the hardware dependent stuff. * Date: June 5, 1991 * Returns: [g_status and g_display]: all set up ready to go * Notes: It is assumed that g_status and g_display are all \0's to begin * with (the default if they use static storage). If this may * not be the case, then clear them explicitly here. */int initialize( void ){int i;char file[PATH_MAX]; /* * jmh 030331: check these assertions once here, instead of every time. */ /* * 15 for the minimum window width, 2 each side for EOF character and space */ assert( strlen( eof_text[0] ) <= 15-4 ); assert( strlen( eof_text[1] ) <= 15-4 ); assert( strlen( EOL_TEXT ) == 3 ); /* * see if there's enough memory (jmh 011202) */ if (init_memory( ) == ERROR) return( ERROR ); /* * do the hardware initialization first. */ hw_initialize( ); /* * now, initialize the editor modes, pointers, and counters. */ bm.search_defined = ERROR; sas_bm.search_defined = ERROR; g_status.sas_defined = ERROR; g_status.sas_search_type = ERROR; regx.search_defined = ERROR; sas_regx.search_defined = ERROR; g_status.marked_file = NULL; g_status.current_window = NULL; g_status.current_file = NULL; g_status.window_list = NULL; g_status.file_list = NULL; g_status.language_list = NULL; g_status.buff_node = NULL; g_status.mstack = NULL; g_status.rec_macro = NULL; g_status.window_count = 0; g_status.file_count = 0; g_status.scratch_count = 0; g_status.line_buff_len = 0; g_status.tabout_buff_len = 0; g_status.jump_to = 0; g_status.jump_col = 1; g_status.jump_off = 0; g_status.viewer_key = FALSE; g_status.command = 0; g_status.key_pressed = 0; g_status.sas_rcol = 0; g_status.sas_rline = 0; g_status.recording_key = 0; g_status.copied = FALSE; g_status.wrapped = FALSE; g_status.marked = FALSE; g_status.macro_executing = FALSE; g_status.replace_defined = FALSE; g_status.screen_display = TRUE; g_status.sas_tokens[0] = '\0'; g_status.rw_name[0] = '\0'; g_status.subst[0] = '\0'; /* * set the number of lines from one page that should still be visible * on the next page after page up or page down. */ g_status.overlap = 1; /* * Set the previous command and command count. */ g_status.last_command = ERROR; g_status.command_count = 0; g_status.errmsg = NULL; /* jmh 010528 */ g_option = g_option_all; /* jmh 031026: for tabs if no files */ ruler_win.rline = -1; /* jmh 050720: no popup ruler */ /* * initialize the nodes in the nfa. */ for (i=0; i < REGX_SIZE; i++) { sas_nfa.node_type[i] = nfa.node_type[i] = 0; sas_nfa.term_type[i] = nfa.term_type[i] = 0; sas_nfa.c[i] = nfa.c[i] = 0; sas_nfa.next1[i] = nfa.next1[i] = 0; sas_nfa.next2[i] = nfa.next2[i] = 0; sas_nfa.class[i] = nfa.class[i] = NULL; } /* * set up default history lists (jmh 990425) */ add_to_history( mode.stamp, &h_stamp ); /* * create the default two-key assignments (jmh 980727) */ default_twokeys( ); /* * clear the screen and show the authors' names */#if defined( __UNIX__ ) bkgdset( tde_color_table[Color( Text )] );#endif cls( ); show_credits( ); tdecfgfile( NULL ); /* * jmh 990404: set the right cursor size, if need to prompt for file name. */ set_cursor_size( mode.insert ? g_display.insert_cursor : g_display.overw_cursor ); /* * jmh 021021: remember the initial cwd, for correct command line names. */ get_current_directory( init_wd ); /* * jmh 050711: check for the existence of the default help file. */ if (file_exists( mode.helpfile ) != ERROR) get_full_path( mode.helpfile, mode.helpfile ); else { join_strings( file, g_status.argv[0], mode.helpfile ); if (file_exists( file ) != ERROR) strcpy( mode.helpfile, file ); } return( OK );}/* * Name: hw_initialize * Purpose: To initialize the display ready for editor use. * Date: June 5, 1991 * * jmh 980727: moved tdecfgfile to initialize(). * jmh 990409: restructured. * jmh 991024: moved a bit more stuff into video_config(). * jmh 020813: moved redirection testing from initialize(). */void hw_initialize( void ){struct vcfg cfg; /* defined in tdestr.h */ g_status.input_redir = !isatty( fileno( stdin ) ); g_status.output_redir = !isatty( fileno( stdout ) ); console_init( &cfg ); /* * Use an integer pointer to go thru the color array for setting up the * various color fields. */ g_display.color = colour[(cfg.color != FALSE)]; if (g_display.adapter != MDA) set_overscan_color( Color( Overscan ) ); /* * set up screen size */ g_display.ncols = cfg.cols; g_display.nlines = cfg.rows; g_display.mode_line = g_display.nlines - 1; g_display.end_line = g_display.mode_line - 1; /* * jmh 990213: set default cursor sizes. * jmh 990404: modified due to new medium size. */ g_display.insert_cursor = g_display.cursor[mode.cursor_size & 3]; g_display.overw_cursor = g_display.cursor[mode.cursor_size >> 2]; /* * jmh 991022: set default frame style and shadow. */#if defined( __UNIX__ ) && !defined( PC_CHARS ) g_display.frame_style = 0; /* ASCII */#else g_display.frame_style = 3; /* Double line outside, single line inside */#endif g_display.frame_space = TRUE; /* Draw a space around frame */ g_display.output_space = FALSE; /* but not yet */ g_display.shadow = TRUE; /* shadow_width is set in video_config() */}/* * Name: get_help * Purpose: save the screen and display key definitions * Date: June 5, 1991 * Notes: This routine is dependent on the length of the strings in the * help screen. To make it easy to load in a new help screen, * the strings are assumed to be 80 characters long followed by * the '\0' character. It is assumed that each string contains * exactly 81 characters. * * jmh 990430: modified the help screen to be two dimensional array of char, * rather than one dimensional array of pointers; this was done * to prevent the compiler merging duplicate strings. * added the viewer help screen. * jmh 991022: made it a special case in show_help(). * jmh 991110: also used for CharacterSet. * jmh 050710: process the normal help after viewer help here. */int get_help( TDE_WIN *window ){ if (show_help( ) == 1) { g_status.current_file->read_only = FALSE; show_help( ); g_status.current_file->read_only = TRUE; } return( OK );}/* * Name: show_credits * Purpose: display authors * Date: June 5, 1991 * * jmh 991020: used the help colour, added shadow. * jmh 991022: only display if no arguments given; * moved it to show_help(). * jmh 991101: no arguments or redirection. * jmh 021028: no workspace. */void show_credits( void ){ if (g_status.arg >= g_status.argc && !g_status.input_redir && !g_status.output_redir && file_exists( wksp_file ) == ERROR) show_help( );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -