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

📄 cooledit.c

📁 具有IDE功能的编辑器
💻 C
📖 第 1 页 / 共 5 页
字号:
	    "-half, --fake-half-tabs                  emulate half tabs with spaces (default)\n" \	    "-no-half, --no-fake-half-tabs            turn off half tabbing\n" \	    "-toolbar                                 edit windows have a toolbar\n" \	    "-no-toolbar                              disabled\n" \	    "--no-xim                                 disable XIM support\n" \	    "-utf8, --utf8-interpretation             interpret UTF-8 encoding\n" \	    "-no-fontset, --no-fontset                use raw fonts\n" \	    "--anti-aliasing                          depreciated, use <fontname>/3\n" \	    "--red-first                              R-G-B LCD sub-pixel order aliasing\n" \	    "--blue-first                             B-G-R LCD sub-pixel order aliasing\n" \	    "--interchar-spacing <n>                  extra spacing between chars in pixels\n" \	    "                                         (anti-aliased fonts only)\n" \	    "--interwidget-spacing <n>                spacing between widgets in pixels\n" \	    "--look [gtk|cool|next]                   look emulation. defaults to gtk\n" \	    "--[no-]bright-invert                     invert the brightness of all colours\n" \            "                                         (useful for white backgrounds)\n" \	    "--[no-]chromin-invert                    invert the chrominance of all colours\n" \	    "--[no-]swap-red-green                    swap red with green\n" \	    "--[no-]swap-green-blue                   swap green with blue\n" \	    "--[no-]swap-red-blue                     swap red with blue\n" \	    "-A, -save-setup                          save setup on exit\n" \	    "-P, -no-save-setup                       don't save setup on exit\n" \	    "-W, --whole-chars-search <chars>         characters that constitute a whole word\n" \	    "                            when searching, default: 0-9a-z_ (typed out in full)\n" \	    "-w, --whole-chars-move <chars>           characters that constitute a whole word\n" \	    "         when moving and deleting, default: 0-9a-z_; ,[](){} (typed out in full)\n" \	    "-verbose                                 print details of initialisation\n" \	    "-h, -H, -?, --help                       print this message to stdout\n" \	    "-V, -v, --version                        print versiom info\n" \	    "\n"));}void version (void){    printf (_("Cooledit version %s\n"), VERSION);}#if 0struct prog_options {    char char_opt;    char *short_opt;    char *long_opt;    int type;			/* one of the #define's above */    char **str;			/* pointer to a single string */    char **strs;		/* pointer to an array of strings */    void *option;		/* an integer or double */#if 0    char *dummy_opt;		/* for the help text */    char *help;			/* help line */#endif};#endifstruct prog_options cooledit_options[] ={    {' ', "", "", ARG_STRINGS, 0, 0, 0},    {0, "-bg", "--background-color", ARG_STRING, &option_background_color, 0, 0},    {0, "", "--mad", ARG_IGNORE, 0, 0, 0},#ifdef GUESS_VISUAL    {0, "-vis", "--visual", ARG_STRING, &option_preferred_visual, 0, 0},    {'C', "-cmap", "--own-colormap",  ARG_SET, 0, 0, &option_force_own_colormap},    {0, "-defcmap", "--default-colormap",  ARG_SET, 0, 0, &option_force_default_colormap},#endif    {0, "", "-toolbar", ARG_SET, 0, 0, &option_toolbar},    {0, "", "-no-toolbar", ARG_CLEAR, 0, 0, &option_toolbar},    {'R', "", "--foreground-red", ARG_STRING, &option_foreground_red, 0, 0},    {'G', "", "--foreground-green", ARG_STRING, &option_foreground_green, 0, 0},    {'B', "", "--foreground-blue", ARG_STRING, &option_foreground_blue, 0, 0},    {'f', "-fn", "-font", ARG_STRING, &option_font, 0, 0},    {0, "", "--widget-font", ARG_STRING, &option_widget_font, 0, 0},    {'S', "", "--suppress-load-files", ARG_SET, 0, 0, &option_suppress_load_files_cmdline},    {'U', "", "--suppress-load-options", ARG_SET, 0, 0, &option_suppress_load_options},    {'E', "-no-override", "", ARG_SET, 0, 0, &option_command_line_doesnt_override},    {'I', "", "--use-initialisation-file", ARG_STRING, &editor_options_file, 0, 0},    {'i', "", "--all-characters", ARG_SET, 0, 0, &option_international_characters},    {0, "-wordwrap", "--word-wrap", ARG_INT, 0, 0, &option_word_wrap_line_length},    {0, "-typew", "--type-writer", ARG_SET, 0, 0, &option_typewriter_wrap},    {0, "-autop", "--auto-paragraph", ARG_SET, 0, 0, &option_auto_para_formatting},    {'t', "-tab", "--tab-spacing", ARG_INT, 0, 0, &option_tab_spacing},    {'s', "-space", "--space-filled-tabs", ARG_SET, 0, 0, &option_fill_tabs_with_spaces},    {0, "-nospace", "--no-space-filled-tabs", ARG_CLEAR, 0, 0, &option_fill_tabs_with_spaces},    {'a', "-autoi", "--auto-indent", ARG_SET, 0, 0, &option_return_does_auto_indent},    {0, "-noautoi", "--no-auto-indent", ARG_CLEAR, 0, 0, &option_return_does_auto_indent},    {'b', "", "--backspace-through-tabs", ARG_SET, 0, 0, &option_backspace_through_tabs},    {0, "-noback", "--no-backspace-through-tabs", ARG_CLEAR, 0, 0, &option_backspace_through_tabs},    {0, "-half", "--fake-half-tabs", ARG_SET, 0, 0, &option_fake_half_tabs},    {0, "-no-half", "--no-fake-half-tabs", ARG_CLEAR, 0, 0, &option_fake_half_tabs},    {'A', "-save-setup", "", ARG_SET, 0, 0, &option_save_setup_on_exit},    {'P', "-no-save-setup", "", ARG_CLEAR, 0, 0, &option_save_setup_on_exit},    {'W', "", "--whole-chars-search", ARG_STRING, &option_whole_chars_search, 0, 0},    {'w', "", "--whole-chars-move", ARG_STRING, &option_chars_move_whole_word, 0, 0},    {'h', "-?", "--help", ARG_SET, 0, 0, &get_help},    {'H', "-help", "--help", ARG_SET, 0, 0, &get_help},    {'V', "-v", "--version", ARG_SET, 0, 0, &get_version},    {0, "", "-verbose", ARG_SET, 0, 0, &option_verbose},    {'d', "", "-display", ARG_STRING, &option_display, 0, 0},    {'g', "-geom", "-geometry", ARG_STRING, &option_geometry, 0, 0},    {0, "-lines", "", ARG_INT, 0, 0, &start_height},    {0, "-columns", "", ARG_INT, 0, 0, &start_width},    {'m', "--minimal-main-window", "", ARG_SET, 0, 0, &option_minimal_main_window},    {0, "", "--no-xim", ARG_CLEAR, 0, 0, &option_use_xim},    {0, "-utf8", "--utf8-interpretation", ARG_SET, 0, 0, &option_utf_interpretation},    {0, "-no-fontset", "--no-fontset", ARG_SET, 0, 0, &option_no_font_set},    {0, "", "--red-first", ARG_CLEAR, 0, 0, &option_rgb_order},    {0, "", "--blue-first", ARG_SET, 0, 0, &option_rgb_order},    {0, "", "--anti-aliasing", ARG_SET, 0, 0, &option_aa_font},    {0, "", "--no-anti-aliasing", ARG_CLEAR, 0, 0, &option_aa_font},    {0, "", "--interchar-spacing", ARG_INT, 0, 0, &option_interchar_spacing},    {0, "", "--edit-bg", ARG_INT, 0, 0, &option_editor_bg_normal},    {0, "", "--interwidget-spacing", ARG_INT, 0, 0, &option_interwidget_spacing},    {0, "", "--look", ARG_STRING, &option_look, 0, 0},    {0, "", "--bright-invert", ARG_SET, 0, 0, &option_invert_colors},    {0, "", "--no-bright-invert", ARG_CLEAR, 0, 0, &option_invert_colors},    {0, "", "--chromin-invert", ARG_SET, 0, 0, &option_invert_crome},    {0, "", "--no-chromin-invert", ARG_CLEAR, 0, 0, &option_invert_crome},    {0, "", "--swap-red-green", ARG_SET, 0, 0, &option_invert_red_green},    {0, "", "--no-swap-red-green", ARG_CLEAR, 0, 0, &option_invert_red_green},    {0, "", "--swap-green-blue", ARG_SET, 0, 0, &option_invert_green_blue},    {0, "", "--no-swap-green-blue", ARG_CLEAR, 0, 0, &option_invert_green_blue},    {0, "", "--swap-red-blue", ARG_SET, 0, 0, &option_invert_red_blue},    {0, "", "--no-swap-red-blue", ARG_CLEAR, 0, 0, &option_invert_red_blue},    {0, 0, 0, 0, 0, 0, 0}};static void process_command_line (int argc, char **argv){    int error;    error = get_cmdline_options (argc, argv, cooledit_options);    if (error) {	fprintf (stderr, _("%s: error processing commandline argument %d\n"), argv[0], error);	usage();	exit (1);    }    if (get_help)	usage();    if (get_version)	version();    if (get_help || get_version)	exit (0);}/* }}}	command-line options *//* {{{  multiple edit windows *//* maximum number of edit windows: */#define N_EDIT 50/* the editors (a stack of sorts) */CWidget *edit[N_EDIT] = {0, 0};int current_edit = 0;		/* containing the focus */int last_edit = 0;		/* number of editors open *//* }}}  multiple edit windows *//* from menu.c: */void destroy_menu (CWidget * w);void render_menu (CWidget * w);/* local: */void update_wlist (void);void wlist_callback (unsigned long ignored);int new_editor (int number, int x, int y, int columns, int lines, char *f, char *d,...);int write_config (int clean);void current_to_top (void);/* {{{ process make (and other shell) error message *//* returns -1 on not found and line numbner = -1. Could return only one as -1 */int get_file_and_line_from_error (char *message, int *line_number, char **new_file){    int i, l;    char *p;    if (!last_edit)	return 0;    *line_number = -1;    for (i = 0; message[i]; i++)	if ((l = strspn (message + i, "0123456789")))	    if (message[i + l] == ':' && message[i - 1] == ':') {		*line_number = atoi (message + i);		break;	    }    for (i = 0; message[i]; i++)	if ((l = strspn (message + i, "0123456789")))	    if (strchr (":;\",\n ", message[i + l]) && message[i - 1] == ':') {		*line_number = atoi (message + i);		break;	    }    for (i = 0; message[i]; i++)	if ((l = strspn (message + i, "0123456789")))	    if (strchr (":;\",\n ", message[i + l]) && strchr (":;\", ", message[i - 1])) {		*line_number = atoi (message + i);		break;	    }    if (!strncmp (message, "/", 1) || !strncmp (message, "./", 2))	goto try_new;    p = strrchr (message, ' ');    if (p) {	p++;	if (!strncmp (p, "/", 1) || !strncmp (p, "./", 2)) {	    char m[MAX_PATH_LEN], *c;	    message = p;	  try_new:	    memset (m, 0, MAX_PATH_LEN);	    if (!strncmp (message, "./", 2)) {		get_current_wd (m, MAX_PATH_LEN - 1);		c = strchr (message, ':');		if (!c)		    c = message + strlen (message);		strncpy (m + strlen (m), message + 1, (unsigned long) c - (unsigned long) (message + 1));	    } else {		c = strchr (message, ':');		if (c) {		    if ((unsigned long) c > (unsigned long) message) {			if (*(c - 1) == ')') {			    char *q;			    for (q = c - 2; (unsigned long) q > (unsigned long) message; q--)				if (*q == '(') {				    c = q;				    break;				}			}		    }		} else {		    c = message + strlen (message);		}		strncpy (m, message, (unsigned long) c - (unsigned long) message);	    }	    c = pathdup (m);	    for (i = 0; i < last_edit; i++)		if (edit[i]->editor->filename)		    if (*(edit[i]->editor->filename)) {			char q[MAX_PATH_LEN];			strcpy (q, edit[i]->editor->dir);			if (q[strlen (q) - 1] == '/')			    q[strlen (q) - 1] = '\0';			strcat (q, "/");			strcat (q, edit[i]->editor->filename);			if (!strcmp (c, q)) {			    free (c);			    return i;			}		    }	    if (new_file)		*new_file = c;	    return -1;	}    }    for (i = 0; i < last_edit; i++)	if (edit[i]->editor->filename)	    if (*(edit[i]->editor->filename)) {		p = strstr (message, edit[i]->editor->filename);		if (!p)		    continue;/* now test if this is a whole word */		if ((unsigned long) p > (unsigned long) message)		    if (strchr ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_0123456789.", *(p - 1)))			continue;		if (strchr ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_0123456789.", p[strlen (edit[i]->editor->filename)]))		    continue;		return i;	    }    return -1;}int new_file_callback (char *full_file_name,...);void edit_move_to_line_easy (WEdit *e, int l){    edit_move_to_line (e, l - 1);    if (edit_count_lines (e, e->start_display, e->curs1) < e->num_widget_lines / 4)	edit_move_display (e, l - e->num_widget_lines / 4 - 1);    else if (edit_count_lines (e, e->start_display, e->curs1) > e->num_widget_lines * 3 / 4)	edit_move_display (e, l - e->num_widget_lines * 3 / 4 - 1);    e->force |= REDRAW_PAGE;}int goto_error (char *message, int raise_wm_window){    int ed, l;    char *new_file = 0;    ed = get_file_and_line_from_error (message, &l, &new_file);    if (new_file) {	if (!new_file_callback (new_file)) {	    edit_move_to_line_easy (edit[current_edit]->editor, l);	    if (raise_wm_window)		CRaiseWMWindow ("cooledit");	    free (new_file);	    return 0;	}	free (new_file);	return 1;    } else if (ed >= 0 && l >= 0) {	current_edit = ed;	edit_move_to_line_easy (edit[current_edit]->editor, l);	edit[ed]->editor->force |= REDRAW_COMPLETELY;	CFocus (edit[ed]);	XRaiseWindow (CDisplay, edit[current_edit]->parentid);	CRaiseWindows ();	if (raise_wm_window)	    CRaiseWMWindow ("cooledit");	current_to_top ();    }    return 0;}static int bookmarks_select_callback (CWidget * w, XEvent * x, CEvent * c){    if (c->double_click || (c->command == CK_Enter && !c->handled)) {	int width;	char *q;	CPushFont ("editor", 0);	width = w->options & TEXTBOX_WRAP ? (w->width - TEXTBOX_BDR) / FONT_MEAN_WIDTH : 32000;	q = strline (w->text, strmovelines (w->text, w->current, w->cursor - w->firstline, width));	CPopFont ();	CDestroyWidget ("bookmarks");	edit[current_edit]->editor->force |= REDRAW_COMPLETELY;	goto_error (q, 1);    }    if (c->command == CK_Cancel) {	CDestroyWidget ("bookmarks");	edit[current_edit]->editor->force |= REDRAW_COMPLETELY;    }    return 0;}static int bookmarks_done_callback (CWidget * w, XEvent * x, CEvent * c){    CDestroyWidget ("bookmarks");    return 1;}void goto_file_dialog (char *heading, char *tool_hint, char *text){    int x, y;    Window win;    CWidget *w;    if (CIdent ("bookmarks"))	return;    win = CDrawHeadedDialog ("bookmarks", main_window, 20, 20, heading);    CIdent ("bookmarks")->position = WINDOW_ALWAYS_RAISED;    CGetHintPos (&x, &y);    CPushFont ("editor", 0);    w = CDrawTextbox ("bookmarks.text", win, x, y, 70 * FONT_MEAN_WIDTH + EDIT_FRAME_W, 20 * FONT_PIX_PER_LINE + EDIT_FRAME_H, 0, 0, text, TEXTBOX_NO_STRDUP);    if (tool_hint)	CSetToolHint ("bookmarks.text", tool_hint);    w->position |= POSITION_HEIGHT | POSITION_WIDTH;    (CIdent ("bookmarks.text.vsc"))->position |= POSITION_HEIGHT | POSITION_RIGHT;    CGetHintPos (0, &y);    (CDrawPixmapButton ("bookmarks.done", win, 0, y, PIXMAP_BUTTON_CROSS))->position = POSITION_BOTTOM | POSITION_CENTRE;    CCentre ("bookmarks.done");    CSetSizeHintPos ("bookmarks");    CSetWindowResizable ("bookmarks", FONT_MEAN_WIDTH * 15, FONT_PIX_PER_LINE * 15, 1600, 1200);    CPopFont ();    CMapDialog ("bookmarks");    CAddCallback ("bookmarks.text", bookmarks_select_callback);    CAddCallback ("bookmarks.done", bookmarks_done_callback);    CFocus (CIdent ("bookmarks.text"));}void bookmark_select (void){    int i;    POOL *p;    p = pool_init ();/* get all bookmarks */    for (i = 0; i < last_edit; i++) {	struct _book_mark *b;	if (!edit[i]->editor->book_mark)	    continue;	for (b = edit[i]->editor->book_mark; b->prev; b = b->prev);	/* rewind */	for (; b; b = b->next)	    if (b->line >= 0)		pool_printf (p, "%s%s:%d\n", edit[i]->editor->dir, edit[i]->editor->filename, b->line + 1);    }    pool_null (p);    goto_file_dialog (_ (" Select Bookmark "), _ ("Double click on a bookmark to goto the file and line number"), (char *) pool_break (p));}/* }}} process make (and other shell) error message *//* {{{  window stack manipulation *//* moves the current editor to the top of the stack */void current_to_top (void){    CWidget *w = edit[current_edit];    memmove (&(edit[1]), &(edit[0]), current_edit * sizeof (CWidget *));    edit[0] = w;    current_edit = 0;    CSetEditMenu (w->ident);	/* sets the editor to which the menu will send commands */    update_wlist ();}int extents_width = 0, extents_height = 0;

⌨️ 快捷键说明

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