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

📄 getline.c

📁 BCAST Implementation for NS2
💻 C
📖 第 1 页 / 共 5 页
字号:
 */static int gl_copy_find(GetLine *gl, int count, char c, int forward, int onto);/* * Return the line index of the parenthesis that either matches the one under * the cursor, or not over a parenthesis character, the index of the next * close parenthesis. Return -1 if not found. */static int gl_index_of_matching_paren(GetLine *gl);/* * Replace a malloc'd string (or NULL), with another malloc'd copy of * a string (or NULL). */static int gl_record_string(char **sptr, const char *string);/* * Enumerate text display attributes as powers of two, suitable for * use in a bit-mask. */typedef enum {  GL_TXT_STANDOUT=1,   /* Display text highlighted */  GL_TXT_UNDERLINE=2,  /* Display text underlined */  GL_TXT_REVERSE=4,    /* Display text with reverse video */  GL_TXT_BLINK=8,      /* Display blinking text */  GL_TXT_DIM=16,       /* Display text in a dim font */  GL_TXT_BOLD=32       /* Display text using a bold font */} GlTextAttr;/* * Display the prompt regardless of the current visibility mode. */static int gl_display_prompt(GetLine *gl);/* * Return the number of characters used by the prompt on the terminal. */static int gl_displayed_prompt_width(GetLine *gl);/* * Prepare the return the current input line to the caller of gl_get_line(). */static int gl_line_ended(GetLine *gl, int newline_char, int archive);/* * Set the maximum length of a line in a user's tecla configuration * file (not counting comments). */#define GL_CONF_BUFLEN 100/* * Set the maximum number of arguments supported by individual commands * in tecla configuration files. */#define GL_CONF_MAXARG 10/* * Prototype the available action functions. */static KT_KEY_FN(gl_user_interrupt);static KT_KEY_FN(gl_abort);static KT_KEY_FN(gl_suspend);static KT_KEY_FN(gl_stop_output);static KT_KEY_FN(gl_start_output);static KT_KEY_FN(gl_literal_next);static KT_KEY_FN(gl_cursor_left);static KT_KEY_FN(gl_cursor_right);static KT_KEY_FN(gl_insert_mode);static KT_KEY_FN(gl_beginning_of_line);static KT_KEY_FN(gl_end_of_line);static KT_KEY_FN(gl_delete_line);static KT_KEY_FN(gl_kill_line);static KT_KEY_FN(gl_forward_word);static KT_KEY_FN(gl_backward_word);static KT_KEY_FN(gl_forward_delete_char);static KT_KEY_FN(gl_backward_delete_char);static KT_KEY_FN(gl_forward_delete_word);static KT_KEY_FN(gl_backward_delete_word);static KT_KEY_FN(gl_delete_refind);static KT_KEY_FN(gl_delete_invert_refind);static KT_KEY_FN(gl_delete_to_column);static KT_KEY_FN(gl_delete_to_parenthesis);static KT_KEY_FN(gl_forward_delete_find);static KT_KEY_FN(gl_backward_delete_find);static KT_KEY_FN(gl_forward_delete_to);static KT_KEY_FN(gl_backward_delete_to);static KT_KEY_FN(gl_upcase_word);static KT_KEY_FN(gl_downcase_word);static KT_KEY_FN(gl_capitalize_word);static KT_KEY_FN(gl_redisplay);static KT_KEY_FN(gl_clear_screen);static KT_KEY_FN(gl_transpose_chars);static KT_KEY_FN(gl_set_mark);static KT_KEY_FN(gl_exchange_point_and_mark);static KT_KEY_FN(gl_kill_region);static KT_KEY_FN(gl_copy_region_as_kill);static KT_KEY_FN(gl_yank);static KT_KEY_FN(gl_up_history);static KT_KEY_FN(gl_down_history);static KT_KEY_FN(gl_history_search_backward);static KT_KEY_FN(gl_history_re_search_backward);static KT_KEY_FN(gl_history_search_forward);static KT_KEY_FN(gl_history_re_search_forward);static KT_KEY_FN(gl_complete_word);static KT_KEY_FN(gl_expand_filename);static KT_KEY_FN(gl_del_char_or_list_or_eof);static KT_KEY_FN(gl_list_or_eof);static KT_KEY_FN(gl_read_from_file);static KT_KEY_FN(gl_beginning_of_history);static KT_KEY_FN(gl_end_of_history);static KT_KEY_FN(gl_digit_argument);static KT_KEY_FN(gl_newline);static KT_KEY_FN(gl_repeat_history);static KT_KEY_FN(gl_vi_insert);static KT_KEY_FN(gl_vi_overwrite);static KT_KEY_FN(gl_change_case);static KT_KEY_FN(gl_vi_insert_at_bol);static KT_KEY_FN(gl_vi_append_at_eol);static KT_KEY_FN(gl_vi_append);static KT_KEY_FN(gl_list_glob);static KT_KEY_FN(gl_backward_kill_line);static KT_KEY_FN(gl_goto_column);static KT_KEY_FN(gl_forward_to_word);static KT_KEY_FN(gl_vi_replace_char);static KT_KEY_FN(gl_vi_change_rest_of_line);static KT_KEY_FN(gl_vi_change_line);static KT_KEY_FN(gl_vi_change_to_bol);static KT_KEY_FN(gl_vi_change_refind);static KT_KEY_FN(gl_vi_change_invert_refind);static KT_KEY_FN(gl_vi_change_to_column);static KT_KEY_FN(gl_vi_change_to_parenthesis);static KT_KEY_FN(gl_vi_forward_change_word);static KT_KEY_FN(gl_vi_backward_change_word);static KT_KEY_FN(gl_vi_forward_change_find);static KT_KEY_FN(gl_vi_backward_change_find);static KT_KEY_FN(gl_vi_forward_change_to);static KT_KEY_FN(gl_vi_backward_change_to);static KT_KEY_FN(gl_vi_forward_change_char);static KT_KEY_FN(gl_vi_backward_change_char);static KT_KEY_FN(gl_forward_copy_char);static KT_KEY_FN(gl_backward_copy_char);static KT_KEY_FN(gl_forward_find_char);static KT_KEY_FN(gl_backward_find_char);static KT_KEY_FN(gl_forward_to_char);static KT_KEY_FN(gl_backward_to_char);static KT_KEY_FN(gl_repeat_find_char);static KT_KEY_FN(gl_invert_refind_char);static KT_KEY_FN(gl_append_yank);static KT_KEY_FN(gl_backward_copy_word);static KT_KEY_FN(gl_forward_copy_word);static KT_KEY_FN(gl_copy_to_bol);static KT_KEY_FN(gl_copy_refind);static KT_KEY_FN(gl_copy_invert_refind);static KT_KEY_FN(gl_copy_to_column);static KT_KEY_FN(gl_copy_to_parenthesis);static KT_KEY_FN(gl_copy_rest_of_line);static KT_KEY_FN(gl_copy_line);static KT_KEY_FN(gl_backward_copy_find);static KT_KEY_FN(gl_forward_copy_find);static KT_KEY_FN(gl_backward_copy_to);static KT_KEY_FN(gl_forward_copy_to);static KT_KEY_FN(gl_vi_undo);static KT_KEY_FN(gl_emacs_editing_mode);static KT_KEY_FN(gl_vi_editing_mode);static KT_KEY_FN(gl_ring_bell);static KT_KEY_FN(gl_vi_repeat_change);static KT_KEY_FN(gl_find_parenthesis);static KT_KEY_FN(gl_read_init_files);static KT_KEY_FN(gl_list_history);static KT_KEY_FN(gl_user_event1);static KT_KEY_FN(gl_user_event2);static KT_KEY_FN(gl_user_event3);static KT_KEY_FN(gl_user_event4);/* * Name the available action functions. */static const struct {const char *name; KT_KEY_FN(*fn);} gl_actions[] = {  {"user-interrupt",             gl_user_interrupt},  {"abort",                      gl_abort},  {"suspend",                    gl_suspend},  {"stop-output",                gl_stop_output},  {"start-output",               gl_start_output},  {"literal-next",               gl_literal_next},  {"cursor-right",               gl_cursor_right},  {"cursor-left",                gl_cursor_left},  {"insert-mode",                gl_insert_mode},  {"beginning-of-line",          gl_beginning_of_line},  {"end-of-line",                gl_end_of_line},  {"delete-line",                gl_delete_line},  {"kill-line",                  gl_kill_line},  {"forward-word",               gl_forward_word},  {"backward-word",              gl_backward_word},  {"forward-delete-char",        gl_forward_delete_char},  {"backward-delete-char",       gl_backward_delete_char},  {"forward-delete-word",        gl_forward_delete_word},  {"backward-delete-word",       gl_backward_delete_word},  {"delete-refind",              gl_delete_refind},  {"delete-invert-refind",       gl_delete_invert_refind},  {"delete-to-column",           gl_delete_to_column},  {"delete-to-parenthesis",      gl_delete_to_parenthesis},  {"forward-delete-find",        gl_forward_delete_find},  {"backward-delete-find",       gl_backward_delete_find},  {"forward-delete-to",          gl_forward_delete_to},  {"backward-delete-to",         gl_backward_delete_to},  {"upcase-word",                gl_upcase_word},  {"downcase-word",              gl_downcase_word},  {"capitalize-word",            gl_capitalize_word},  {"redisplay",                  gl_redisplay},  {"clear-screen",               gl_clear_screen},  {"transpose-chars",            gl_transpose_chars},  {"set-mark",                   gl_set_mark},  {"exchange-point-and-mark",    gl_exchange_point_and_mark},  {"kill-region",                gl_kill_region},  {"copy-region-as-kill",        gl_copy_region_as_kill},  {"yank",                       gl_yank},  {"up-history",                 gl_up_history},  {"down-history",               gl_down_history},  {"history-search-backward",    gl_history_search_backward},  {"history-re-search-backward", gl_history_re_search_backward},  {"history-search-forward",     gl_history_search_forward},  {"history-re-search-forward",  gl_history_re_search_forward},  {"complete-word",              gl_complete_word},  {"expand-filename",            gl_expand_filename},  {"del-char-or-list-or-eof",    gl_del_char_or_list_or_eof},  {"read-from-file",             gl_read_from_file},  {"beginning-of-history",       gl_beginning_of_history},  {"end-of-history",             gl_end_of_history},  {"digit-argument",             gl_digit_argument},  {"newline",                    gl_newline},  {"repeat-history",             gl_repeat_history},  {"vi-insert",                  gl_vi_insert},  {"vi-overwrite",               gl_vi_overwrite},  {"vi-insert-at-bol",           gl_vi_insert_at_bol},  {"vi-append-at-eol",           gl_vi_append_at_eol},  {"vi-append",                  gl_vi_append},  {"change-case",                gl_change_case},  {"list-glob",                  gl_list_glob},  {"backward-kill-line",         gl_backward_kill_line},  {"goto-column",                gl_goto_column},  {"forward-to-word",            gl_forward_to_word},  {"vi-replace-char",            gl_vi_replace_char},  {"vi-change-rest-of-line",     gl_vi_change_rest_of_line},  {"vi-change-line",             gl_vi_change_line},  {"vi-change-to-bol",           gl_vi_change_to_bol},  {"vi-change-refind",           gl_vi_change_refind},  {"vi-change-invert-refind",    gl_vi_change_invert_refind},  {"vi-change-to-column",        gl_vi_change_to_column},  {"vi-change-to-parenthesis",   gl_vi_change_to_parenthesis},  {"forward-copy-char",          gl_forward_copy_char},  {"backward-copy-char",         gl_backward_copy_char},  {"forward-find-char",          gl_forward_find_char},  {"backward-find-char",         gl_backward_find_char},  {"forward-to-char",            gl_forward_to_char},  {"backward-to-char",           gl_backward_to_char},  {"repeat-find-char",           gl_repeat_find_char},  {"invert-refind-char",         gl_invert_refind_char},  {"append-yank",                gl_append_yank},  {"backward-copy-word",         gl_backward_copy_word},  {"forward-copy-word",          gl_forward_copy_word},  {"copy-to-bol",                gl_copy_to_bol},  {"copy-refind",                gl_copy_refind},  {"copy-invert-refind",         gl_copy_invert_refind},  {"copy-to-column",             gl_copy_to_column},  {"copy-to-parenthesis",        gl_copy_to_parenthesis},  {"copy-rest-of-line",          gl_copy_rest_of_line},  {"copy-line",                  gl_copy_line},  {"backward-copy-find",         gl_backward_copy_find},  {"forward-copy-find",          gl_forward_copy_find},  {"backward-copy-to",           gl_backward_copy_to},  {"forward-copy-to",            gl_forward_copy_to},  {"list-or-eof",                gl_list_or_eof},  {"vi-undo",                    gl_vi_undo},  {"vi-backward-change-word",    gl_vi_backward_change_word},  {"vi-forward-change-word",     gl_vi_forward_change_word},  {"vi-backward-change-find",    gl_vi_backward_change_find},  {"vi-forward-change-find",     gl_vi_forward_change_find},  {"vi-backward-change-to",      gl_vi_backward_change_to},  {"vi-forward-change-to",       gl_vi_forward_change_to},  {"vi-backward-change-char",    gl_vi_backward_change_char},  {"vi-forward-change-char",     gl_vi_forward_change_char},  {"emacs-mode",                 gl_emacs_editing_mode},  {"vi-mode",                    gl_vi_editing_mode},  {"ring-bell",                  gl_ring_bell},  {"vi-repeat-change",           gl_vi_repeat_change},  {"find-parenthesis",           gl_find_parenthesis},  {"read-init-files",            gl_read_init_files},  {"list-history",               gl_list_history},  {"user-event1",                gl_user_event1},  {"user-event2",                gl_user_event2},  {"user-event3",                gl_user_event3},  {"user-event4",                gl_user_event4},};/* * Define the default key-bindings in emacs mode. */static const KtKeyBinding gl_emacs_bindings[] = {  {"right",        "cursor-right"},  {"^F",           "cursor-right"},  {"left",         "cursor-left"},  {"^B",           "cursor-left"},  {"M-i",          "insert-mode"},  {"M-I",          "insert-mode"},  {"^A",           "beginning-of-line"},  {"^E",           "end-of-line"},  {"^U",           "delete-line"},  {"^K",           "kill-line"},  {"M-f",          "forward-word"},  {"M-F",          "forward-word"},  {"M-b",          "backward-word"},  {"M-B",          "backward-word"},  {"^D",           "del-char-or-list-or-eof"},  {"^H",           "backward-delete-char"},  {"^?",           "backward-delete-char"},  {"M-d",          "forward-delete-word"},  {"M-D",          "forward-delete-word"},  {"M-^H",         "backward-delete-word"},  {"M-^?",         "backward-delete-word"},  {"M-u",          "upcase-word"},  {"M-U",          "upcase-word"},  {"M-l",          "downcase-word"},  {"M-L",          "downcase-word"},  {"M-c",          "capitalize-word"},  {"M-C",          "capitalize-word"},  {"^R",           "redisplay"},  {"^L",           "clear-screen"},  {"^T",           "transpose-chars"},  {"^@",           "set-mark"},  {"^X^X",         "exchange-point-and-mark"},  {"^W",           "kill-region"},  {"M-w",          "copy-region-as-kill"},  {"M-W",          "copy-region-as-kill"},  {"^Y",           "yank"},  {"^P",           "up-history"},  {"up",           "up-history"},  {"^N",           "down-history"},  {"down",         "down-history"},  {"M-p",          "history-search-backward"},  {"M-P",          "history-search-backward"},  {"M-n",          "history-search-forward"},  {"M-N",          "history-search-forward"},  {"\t",           "complete-word"},  {"^X*",          "expand-filename"},  {"^X^F",         "read-from-file"},  {"^X^R",         "read-init-files"},  {"^Xg",          "list-glob"},  {"^XG",          "list-glob"},  {"^Xh",          "list-history"},  {"^XH",          "list-history"},  {"M-<",          "beginning-of-history"},  {"M->",          "end-of-history"},  {"M-0",          "digit-argument"},  {"M-1",          "digit-argument"},  {"M-2",          "digit-argument"},  {"M-3",          "digit-argument"},  {"M-4",          "digit-argument"},  {"M-5",          "digit-argument"},  {"M-6",          "digit-argument"},  {"M-7",          "digit-argument"},  {"M-8",          "digit-argument"},  {"M-9",          "digit-argument"},  {"\r",           "newline"},  {"\n",           "newline"},  {"M-o",          "repeat-history"},  {"M-C-v",        "vi-mode"},};/* * Define the default key-bindings in vi mode. Note that in vi-mode * meta-key bindings are command-mode bindings. For example M-i first * switches to command mode if not already in that mode, then moves * the cursor one position right, as in vi. */

⌨️ 快捷键说明

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