diff --git a/edit/ChangeLog b/edit/ChangeLog index 55c550022..30e358240 100644 --- a/edit/ChangeLog +++ b/edit/ChangeLog @@ -1,5 +1,11 @@ 2001-09-07 Pavel Roskin + * bookmark.c: Eliminate all code disabled for the text edition. + * edit-widget.h: Likewise. + * editcmd.c: Likewise. + * editdraw.c: Likewise. + * editoptions.c: Likewise. + * edit.h: Eliminate all code disabled for the text edition. Reorder and simplify includes. * edit.c: Likewise. diff --git a/edit/bookmark.c b/edit/bookmark.c index 1ed660449..5ccd4b010 100644 --- a/edit/bookmark.c +++ b/edit/bookmark.c @@ -23,9 +23,6 @@ #include #include "edit.h" -#if defined (HAVE_MAD) && ! defined (MIDNIGHT) && ! defined (GTK) -#include "mad.h" -#endif /* note, if there is more than one bookmark on a line, then they are appended after each other and the last one is always the one found @@ -141,9 +138,6 @@ void book_mark_insert (WEdit * edit, int line, int c) if (p->next) p->next->prev = q; p->next = q; -#if !defined (GTK) && !defined (MIDNIGHT) - render_scrollbar (edit->widget->vert_scrollbar); -#endif } /* remove a bookmark if there is one at this line matching this colour - c of -1 clear all */ @@ -174,10 +168,6 @@ int book_mark_clear (WEdit * edit, int line, int c) free (edit->book_mark); edit->book_mark = 0; } -#if !defined (GTK) && !defined (MIDNIGHT) - if (rend) - render_scrollbar (edit->widget->vert_scrollbar); -#endif return r; } @@ -205,10 +195,6 @@ void book_mark_flush (WEdit * edit, int c) free (edit->book_mark); edit->book_mark = 0; } -#if !defined (GTK) && !defined (MIDNIGHT) - if (rend) - render_scrollbar (edit->widget->vert_scrollbar); -#endif } /* shift down bookmarks after this line */ @@ -223,10 +209,6 @@ void book_mark_inc (WEdit * edit, int line) rend = 1; } } -#if !defined (GTK) && !defined (MIDNIGHT) - if (rend) - render_scrollbar (edit->widget->vert_scrollbar); -#endif } /* shift up bookmarks after this line */ @@ -241,11 +223,4 @@ void book_mark_dec (WEdit * edit, int line) rend = 1; } } -#if !defined (GTK) && !defined (MIDNIGHT) - if (rend) - render_scrollbar (edit->widget->vert_scrollbar); -#endif } - - - diff --git a/edit/edit-widget.h b/edit/edit-widget.h index b72afe3a9..5a745e3fe 100644 --- a/edit/edit-widget.h +++ b/edit/edit-widget.h @@ -37,22 +37,12 @@ struct _book_mark { }; struct editor_widget { -#ifdef MIDNIGHT Widget widget; -#elif defined(GTK) - GtkEdit *widget; -#else - struct cool_widget *widget; -#endif #define from_here num_widget_lines int num_widget_lines; int num_widget_columns; -#ifdef MIDNIGHT int have_frame; -#else - int stopped; -#endif char *filename; /* Name of the file */ char *dir; /* current directory */ @@ -80,11 +70,9 @@ struct editor_widget { unsigned char modified; /*has the file been changed?: 1 if char inserted or deleted at all since last load or save */ unsigned char screen_modified; /* has the file been changed since the last screen draw? */ -#if defined(MIDNIGHT) || defined(GTK) int delete_file; /* has the file been created in edit_load_file? Delete it at end of editing when it hasn't been modified or saved */ -#endif unsigned char highlight; long prev_col; /*recent column position of the cursor - used when moving up or down past lines that are shorter than the current line */ @@ -141,4 +129,4 @@ typedef struct editor_widget WEdit; #define ERROR_FILE "/.cedit/cooledit.error" #define TEMP_FILE "/.cedit/cooledit.temp" -#endif +#endif /* !__EDIT_WIDGET_H */ diff --git a/edit/editcmd.c b/edit/editcmd.c index 8d5d82c4d..e89e8c251 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -26,23 +26,13 @@ /* #define PIPE_BLOCKS_SO_READ_BYTE_BY_BYTE */ #include -#ifdef NEEDS_IO_H -#include -#include -#endif #include + #include "edit.h" #include "editcmddef.h" -#ifndef MIDNIGHT -#include -#ifndef GTK -#include "loadfile.h" -#endif -#endif - #ifdef HAVE_CHARSET -#include "../src/charsets.h" +#include "src/charsets.h" #endif /* globals: */ @@ -58,17 +48,11 @@ int replace_backwards = 0; int search_create_bookmark = 0; /* queries on a save */ -#ifdef MIDNIGHT int edit_confirm_save = 1; -#else -int edit_confirm_save = 0; -#endif #define NUM_REPL_ARGS 64 #define MAX_REPL_LEN 1024 -#if defined(MIDNIGHT) || defined(GTK) - static inline int my_lower_case (int c) { return tolower(c & 0xFF); @@ -82,12 +66,6 @@ char *strcasechr (const unsigned char *s, int c) return (char *) s; } -#ifdef MIDNIGHT -#include "../src/mad.h" -#elif !defined (GTK) -#include "mad.h" -#endif - #ifndef HAVE_MEMMOVE /* for Christophe */ static void *memmove (void *dest, const void *src, size_t n) @@ -107,7 +85,7 @@ static void *memmove (void *dest, const void *src, size_t n) } return dest; } -#endif +#endif /* !HAVE_MEMMOVE */ /* #define itoa MY_itoa <---- this line is now in edit.h */ char *itoa (int i) @@ -163,9 +141,6 @@ char *catstrs (const char *first,...) return stacked[i]; } -#endif - -#ifdef MIDNIGHT void edit_help_cmd (WEdit * edit) { @@ -184,57 +159,11 @@ void edit_refresh_cmd (WEdit * edit) edit_get_syntax_color (edit, -1, &fg, &bg); } touchwin(stdscr); -#endif /* !HAVE_SLANG */ +#endif /* !HAVE_SLANG */ mc_refresh(); doupdate(); } -#else /* MIDNIGHT */ - -void edit_help_cmd (WEdit * edit) -{ -} - -void edit_refresh_cmd (WEdit * edit) -{ - int fg, bg; - edit_get_syntax_color (edit, -1, &fg, &bg); - edit->force |= REDRAW_COMPLETELY; -} - -void CRefreshEditor (WEdit * edit) -{ - edit_refresh_cmd (edit); -} - -#endif /* MIDNIGHT */ - -#ifndef MIDNIGHT -#ifndef GTK - -/* three argument open */ -int my_open (const char *pathname, int flags,...) -{ - int file; - va_list ap; - - file = open ((char *) pathname, O_RDONLY); - if (file < 0 && (flags & O_CREAT)) { /* must it be created ? */ - mode_t mode; - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - return creat ((char *) pathname, mode); - } - close (file); - return open ((char *) pathname, flags); -} - -#define open my_open - -#endif /* !GTK */ -#endif /* !MIDNIGHT */ - /* "Oleg Yu. Repin" added backup filenames ...thanks -paul */ @@ -371,7 +300,7 @@ int edit_save_file (WEdit * edit, const char *filename) } if (close (fd)) goto error_save; -#endif /* CR_LF_TRANSLATION */ +#endif /* !CR_LF_TRANSLATION */ } if (filelen != edit->last_byte) @@ -391,7 +320,6 @@ int edit_save_file (WEdit * edit, const char *filename) return 0; } -#ifdef MIDNIGHT /* I changed this from Oleg's original routine so that option_backup_ext works with coolwidgets as well. This @@ -478,83 +406,6 @@ void edit_split_filename (WEdit * edit, const char *f) edit->dir = (char *) strdup (""); } -#else /* MIDNIGHT */ - -#ifdef GTK - - -static char *edit_canonicalize_pathname (const char *p) -{ - char *q, *r; - char *t = NULL; - char *cwd; - - if (*p != '/') { - cwd = g_get_current_dir (); - t = g_malloc (strlen (cwd) + strlen (p) + 2); - strcpy (t, cwd); - strcat (t, "/"); - strcat (t, p); - g_free (cwd); - p = t; - } - - r = q = malloc (strlen (p) + 2); - while (*p) { - if (*p != '/') { - *q++ = *p++; - } else { - while (*p == '/') { - *q = '/'; - if (!strncmp (p, "/./", 3) || !strcmp (p, "/.")) - p++; - else if (!strncmp (p, "/../", 4) || !strcmp (p, "/..")) { - p += 2; - *q = ' '; - q = strrchr (r, '/'); - if (!q) { - q = r; - *q = '/'; - } - } - p++; - } - q++; - } - } - g_free (t); - *q = '\0'; -/* get rid of trailing / */ - if (r[0] && r[1]) - if (*--q == '/') - *q = '\0'; - return r; -} - -#endif /* GTK */ - - -void edit_split_filename (WEdit * edit, const char *longname) -{ - char *exp, *p; -#ifdef GTK - exp = edit_canonicalize_pathname (longname); -#else - exp = pathdup (longname); /* this ensures a full path */ -#endif - if (edit->filename) - free (edit->filename); - if (edit->dir) - free (edit->dir); - p = strrchr (exp, '/'); - edit->filename = (char *) strdup (++p); - *p = 0; - edit->dir = (char *) strdup (exp); - free (exp); -} - -#endif /* ! MIDNIGHT */ - /* here we want to warn the user of overwriting an existing file, but only if they have made a change to the filename */ /* returns 1 on success */ @@ -591,9 +442,7 @@ int edit_save_as_cmd (WEdit * edit) edit_split_filename (edit, exp); free (exp); edit->modified = 0; -#if defined(MIDNIGHT) || defined(GTK) edit->delete_file = 0; -#endif if (different_filename && !edit->explicit_syntax) edit_load_syntax (edit, 0, 0); edit->force |= REDRAW_COMPLETELY; @@ -612,7 +461,6 @@ int edit_save_as_cmd (WEdit * edit) /* {{{ Macro stuff starts here */ -#ifdef MIDNIGHT int raw_callback (struct Dlg_head *h, int key, int Msg) { switch (Msg) { @@ -661,20 +509,6 @@ int edit_raw_key_query (char *heading, char *query, int cancel) return w; } -#else /* MIDNIGHT */ - -int edit_raw_key_query (char *heading, char *query, int cancel) -{ -#ifdef GTK - /* *** */ - return 0; -#else - return CKeySymMod (CRawkeyQuery (0, 0, 0, heading, query)); -#endif -} - -#endif /* MIDNIGHT */ - /* creates a macro file if it doesn't exist */ static FILE *edit_open_macro_file (const char *r) { @@ -798,20 +632,8 @@ void edit_delete_macro_cmd (WEdit * edit) { int command; -#ifdef MIDNIGHT command = edit_raw_key_query (_ (" Delete Macro "), _ (" Press macro hotkey: "), 1); -#else -/* This heads the 'Delete Macro' dialog box */ -#ifdef GTK -/* *** */ - command = 0; -#else - command = CKeySymMod (CRawkeyQuery (0, 0, 0, _ (" Delete Macro "), -/* Input line for a single key press follows the ':' */ - _ (" Press macro hotkey: "))); -#endif -#endif if (!command) return; @@ -870,11 +692,7 @@ int edit_save_confirm_cmd (WEdit * edit) char *f; if (edit_confirm_save) { -#ifdef MIDNIGHT f = catstrs (_(" Confirm save file? : "), edit->filename, " ", 0); -#else - f = catstrs (_(" Confirm save file? : "), edit->dir, edit->filename, " ", 0); -#endif /* Buttons to 'Confirm save file' query */ if (edit_query_dialog2 (_(" Save file "), f, _("Save"), _("Cancel"))) return 0; @@ -890,9 +708,7 @@ int edit_save_cmd (WEdit * edit) return edit_save_as_cmd (edit); edit->force |= REDRAW_COMPLETELY; edit->modified = 0; -#if defined(MIDNIGHT) || defined(GTK) edit->delete_file = 0; -#endif return 1; } @@ -971,11 +787,7 @@ int eval_marks (WEdit * edit, long *start_mark, long *end_mark) /*Block copy, move and delete commands */ extern int column_highlighting; -#ifdef MIDNIGHT #define space_width 1 -#else -extern int space_width; -#endif void edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int width) { @@ -1211,8 +1023,6 @@ int edit_block_delete_cmd (WEdit * edit) } -#ifdef MIDNIGHT - #define INPUT_INDEX 9 #define SEARCH_DLG_WIDTH 58 #define SEARCH_DLG_HEIGHT 10 @@ -1242,16 +1052,16 @@ int edit_replace_prompt (WEdit * edit, char *replace_text, int xpos, int ypos) 0, 0, 0, 0, 0}, {0}}; -#ifndef HAVE_CHARSET - quick_widgets[5].text = catstrs (_ (" Replace with: "), replace_text, 0); -#else - char *msg; +#ifdef HAVE_CHARSET + char *msg; quick_widgets[5].text = catstrs (msg = _(" Replace with: "), replace_text, 0); if (*replace_text) convert_to_display (quick_widgets[5].text + strlen (msg)); -#endif +#else + quick_widgets[5].text = catstrs (_ (" Replace with: "), replace_text, 0); +#endif /* !HAVE_CHARSET */ { QuickDialog Quick_input = @@ -1422,324 +1232,8 @@ void edit_search_dialog (WEdit * edit, char **search_text) } } -#else -#undef B_ENTER -#undef B_CANCEL - -#define B_ENTER 0 -#define B_SKIP_REPLACE 1 -#define B_REPLACE_ALL 2 -#define B_REPLACE_ONE 3 -#define B_CANCEL 4 - -extern CWidget *wedit; - -#ifndef GTK - -void edit_search_replace_dialog (Window parent, int x, int y, char **search_text, char **replace_text, char **arg_order, char *heading, int option) -{ - Window win; - XEvent xev; - CEvent cev; - CState s; - int xh, yh, h, xb, ys, yc, yb, yr; - CWidget *m; - int text_input_width ; - - CBackupState (&s); - CDisable ("*"); - - win = CDrawHeadedDialog ("replace", parent, x, y, heading); - CGetHintPos (&xh, &h); -#ifdef NEXT_LOOK - xh += NEXT_SPACING ; -#endif - -/* NLS hotkey ? */ - CIdent ("replace")->position = WINDOW_ALWAYS_RAISED; -/* An input line comes after the ':' */ - (CDrawText ("replace.t1", win, xh, h, _(" Enter search text : ")))->hotkey = 'E'; - - CGetHintPos (0, &yh); - (m = CDrawTextInput ("replace.sinp", win, xh, yh, 10, AUTO_HEIGHT, 8192, *search_text))->hotkey = 'E'; - - if (replace_text) { - CGetHintPos (0, &yh); - (CDrawText ("replace.t2", win, xh, yh, _(" Enter replace text : ")))->hotkey = 'n'; - CGetHintPos (0, &yh); - (CDrawTextInput ("replace.rinp", win, xh, yh, 10, AUTO_HEIGHT, 8192, *replace_text))->hotkey = 'n'; - CSetToolHint ("replace.t2", _("You can enter regexp substrings with %s\n(not \\1, \\2 like sed) then use \"Enter...order\"")); - CSetToolHint ("replace.rinp", _("You can enter regexp substrings with %s\n(not \\1, \\2 like sed) then use \"Enter...order\"")); - CGetHintPos (0, &yh); - (CDrawText ("replace.t3", win, xh, yh, _(" Enter argument (or substring) order : ")))->hotkey = 'o'; - CGetHintPos (0, &yh); - (CDrawTextInput ("replace.ainp", win, xh, yh, 10, AUTO_HEIGHT, 256, *arg_order))->hotkey = 'o'; -/* Tool hint */ - CSetToolHint ("replace.ainp", _("Enter the order of replacement of your scanf\nformat specifiers or regexp substrings, eg 3,1,2")); - CSetToolHint ("replace.t3", _("Enter the order of replacement of your scanf\nformat specifiers or regexp substrings, eg 3,1,2")); - } - CGetHintPos (0, &yh); - ys = yh; -/* The following are check boxes */ - CDrawSwitch ("replace.ww", win, xh, yh, replace_whole, _(" Whole words only "), 0); - CGetHintPos (0, &yh); - CDrawSwitch ("replace.case", win, xh, yh, replace_case, _(" Case sensitive "), 0); - yc = yh; - CGetHintPos (0, &yh); - CDrawSwitch ("replace.reg", win, xh, yh, replace_regexp, _(" Regular expression "), 1); - CSetToolHint ("replace.reg", _("See the regex man page for how\nto compose a regular expression")); - CSetToolHint ("replace.reg.label", _("See the regex man page for how\nto compose a regular expression")); - yb = yh; - CGetHintPos (0, &yh); - CGetHintPos (&xb, 0); -#ifdef NEXT_LOOK - xb += NEXT_SPACING ; -#endif - if (option & SEARCH_DIALOG_OPTION_BACKWARDS) { - CDrawSwitch ("replace.bkwd", win, xh, yh, replace_backwards, _(" Backwards "), 0); -/* Tool hint */ - CSetToolHint ("replace.bkwd", _("Warning: Searching backward can be slow")); - CSetToolHint ("replace.bkwd.label", _("Warning: Searching backward can be slow")); - } - if (replace_text) { - yr = ys; - if (option & SEARCH_DIALOG_OPTION_BACKWARDS) - yr = yc; - } else { - if (option & SEARCH_DIALOG_OPTION_BACKWARDS) { - if (option & SEARCH_DIALOG_OPTION_BOOKMARK) - yr = yb; - else - yr = yh; - } else { - if (option & SEARCH_DIALOG_OPTION_BOOKMARK) - yr = yc; - else - yr = yb; - } - } - - if (replace_text) { - CDrawSwitch ("replace.pr", win, xb, yr, replace_prompt, _(" Prompt on replace "), 0); -/* Tool hint */ - CSetToolHint ("replace.pr", _("Ask before making each replacement")); - CGetHintPos (0, &yr); - CDrawSwitch ("replace.all", win, xb, yr, replace_all, _(" Replace all "), 0); -/* Tool hint */ - CSetToolHint ("replace.all", _("Replace repeatedly")); - CGetHintPos (0, &yr); - } - if (option & SEARCH_DIALOG_OPTION_BOOKMARK) { - CDrawSwitch ("replace.bkmk", win, xb, yr, search_create_bookmark, _(" Bookmarks "), 0); -/* Tool hint */ - CSetToolHint ("replace.bkmk", _("Create bookmarks at all lines found")); - CSetToolHint ("replace.bkmk.label", _("Create bookmarks at all lines found")); - CGetHintPos (0, &yr); - } - CDrawSwitch ("replace.scanf", win, xb, yr, replace_scanf, _(" Scanf expression "), 1); -/* Tool hint */ - CSetToolHint ("replace.scanf", _("Allows entering of a C format string,\nsee the scanf man page")); - - get_hint_limits (&x, &y); -#ifdef NEXT_LOOK - { - int btn_width, x, y ; - CGetHintPos (&x, &y); - - y += NEXT_SPACING * 2 ; - x += NEXT_SPACING * 2 ; - CTextSize (&btn_width, 0, " Cancel "); - btn_width += 4 + BUTTON_RELIEF * 2; - x -= (btn_width + NEXT_SPACING) * 2 + NEXT_SPACING; - - CDrawButton ("replace.ok", win, x+btn_width + NEXT_SPACING * 2, y, AUTO_WIDTH, AUTO_HEIGHT, " Ok "); - CDrawButton ("replace.cancel", win, x, y, AUTO_WIDTH, AUTO_HEIGHT, " Cancel "); - CGetHintPos (0, &y); - x += (btn_width + NEXT_SPACING) * 2 + NEXT_SPACING; - reset_hint_pos (x, y + NEXT_SPACING*2); - } -#else - CDrawPixmapButton ("replace.ok", win, x - WIDGET_SPACING - TICK_BUTTON_WIDTH, h, PIXMAP_BUTTON_TICK); - CDrawPixmapButton ("replace.cancel", win, x - WIDGET_SPACING - TICK_BUTTON_WIDTH, h + WIDGET_SPACING + TICK_BUTTON_WIDTH, PIXMAP_BUTTON_CROSS); -#endif -/* Tool hint */ - CSetToolHint ("replace.ok", _("Begin search, Enter")); - CSetToolHint ("replace.cancel", _("Abort this dialog, Esc")); - CSetSizeHintPos ("replace"); - CMapDialog ("replace"); - - m = CIdent ("replace"); -#ifdef NEXT_LOOK - text_input_width = m->width - WIDGET_SPACING * 3 - 4 - NEXT_SPACING*2 ; -#else - text_input_width = m->width - WIDGET_SPACING * 3 - 4 - TICK_BUTTON_WIDTH ; -#endif - CSetWidgetSize ("replace.sinp", text_input_width, (CIdent ("replace.sinp"))->height); - if (replace_text) { - CSetWidgetSize ("replace.rinp", text_input_width, (CIdent ("replace.rinp"))->height); - CSetWidgetSize ("replace.ainp", text_input_width, (CIdent ("replace.ainp"))->height); - } - CFocus (CIdent ("replace.sinp")); - - for (;;) { - CNextEvent (&xev, &cev); - if (!CIdent ("replace")) { - *search_text = 0; - break; - } - if (!strcmp (cev.ident, "replace.cancel") || cev.command == CK_Cancel) { - *search_text = 0; - break; - } - if (!strcmp (cev.ident, "replace.reg") || !strcmp (cev.ident, "replace.scanf")) { - if (CIdent ("replace.reg")->keypressed || CIdent ("replace.scanf")->keypressed) { - if (!(CIdent ("replace.case")->keypressed)) { - CIdent ("replace.case")->keypressed = 1; - CExpose ("replace.case"); - } - } - } - if (!strcmp (cev.ident, "replace.ok") || cev.command == CK_Enter) { - if (replace_text) { - replace_all = CIdent ("replace.all")->keypressed; - replace_prompt = CIdent ("replace.pr")->keypressed; - *replace_text = (char *) strdup (CIdent ("replace.rinp")->text); - *arg_order = (char *) strdup (CIdent ("replace.ainp")->text); - } - *search_text = (char *) strdup (CIdent ("replace.sinp")->text); - replace_whole = CIdent ("replace.ww")->keypressed; - replace_case = CIdent ("replace.case")->keypressed; - replace_scanf = CIdent ("replace.scanf")->keypressed; - replace_regexp = CIdent ("replace.reg")->keypressed; - - if (option & SEARCH_DIALOG_OPTION_BACKWARDS) { - replace_backwards = CIdent ("replace.bkwd")->keypressed; - } else { - replace_backwards = 0; - } - - if (option & SEARCH_DIALOG_OPTION_BOOKMARK) { - search_create_bookmark = CIdent ("replace.bkmk")->keypressed; - } else { - search_create_bookmark = 0; - } - - break; - } - } - CDestroyWidget ("replace"); - CRestoreState (&s); -} - -void edit_search_dialog (WEdit * edit, char **search_text) -{ -/* Heads the 'Search' dialog box */ - edit_search_replace_dialog (WIN_MESSAGES, search_text, 0, 0, _(" Search "), SEARCH_DIALOG_OPTION_BACKWARDS | SEARCH_DIALOG_OPTION_BOOKMARK); -} - -void edit_replace_dialog (WEdit * edit, char **search_text, char **replace_text, char **arg_order) -{ -/* Heads the 'Replace' dialog box */ - edit_search_replace_dialog (WIN_MESSAGES, search_text, replace_text, arg_order, _(" Replace "), SEARCH_DIALOG_OPTION_BACKWARDS); -} - -#else - -#include -#include - -void edit_search_dialog (WEdit * edit, char **search_text) -{ - char *s; - s = gtk_dialog_cauldron ( - "Search", GTK_CAULDRON_TOPLEVEL | GTK_CAULDRON_GRAB, - " ( (Enter search text)d | %Eogxf )xf / ( ( %Cd // %Cd // %Cd ) || ( %Cd // %Cd )xf )xf / ( %Bxfgrq || %Bxfgq )f", - search_text, "search", - "&Whole word", &replace_whole, - "Case &sensitive", &replace_case, - "&Regular expression", &replace_regexp, - "&Backwards", &replace_backwards, - "Scanf &expression", &replace_scanf, - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL - ); - if (s == GTK_CAULDRON_ESCAPE || !s || s == GNOME_STOCK_BUTTON_CANCEL) - *search_text = 0; - return; -} - -void edit_replace_dialog (WEdit * edit, char **search_text, char **replace_text, char **arg_order) -{ - char *s; - s = gtk_dialog_cauldron ( - "Search", GTK_CAULDRON_TOPLEVEL | GTK_CAULDRON_GRAB, - " ( (Enter search text)d | %Eogxf )xf / ( (Enter replace text)d | %Egxf )xf / ( (Enter argument order)d | %Egxf )xf / ( ( %Cd // %Cd // %Cd // %Cd ) || ( %Cd // %Cd // %Cd )xf )xf / ( %Bxfgrq || %Bxfgq )f", - search_text, "search", - replace_text, "replace", - arg_order, "arg_order", - "&Whole word", &replace_whole, - "Case &sensitive", &replace_case, - "&Regular expression", &replace_regexp, - "&Backwards", &replace_backwards, - "Pr&ompt on replace", &replace_prompt, - "Replace &all", &replace_all, - "Scanf &expression", &replace_scanf, - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL - ); - if (s == GTK_CAULDRON_ESCAPE || !s || s == GNOME_STOCK_BUTTON_CANCEL) - *search_text = 0; - return; -} - -#endif - -#ifdef GTK - -int edit_replace_prompt (WEdit * edit, char *replace_text, int xpos, int ypos) -{ - char *s; - s = gtk_dialog_cauldron ( - "Replace", GTK_CAULDRON_TOPLEVEL | GTK_CAULDRON_GRAB, - " ( (Replace with:)d %Ld )xf / ( %Bxfrq || %Bxfq || %Bxfq || %Bxfq || %Bxfgq )f", - replace_text, - "Replace", "Skip", "Replace all", "Replace one", - GNOME_STOCK_BUTTON_CANCEL - ); - if (s == GTK_CAULDRON_ESCAPE || !s || s == GNOME_STOCK_BUTTON_CANCEL) - return B_CANCEL; - if (!strcmp (s, "Replace all")) - return B_REPLACE_ALL; - if (!strcmp (s, "Replace one")) - return B_REPLACE_ONE; - if (!strcmp (s, "Skip")) - return B_SKIP_REPLACE; - if (!strcmp (s, "Replace")) - return B_ENTER; - /* Shouldn't ever reach this point */ - return B_CANCEL; -} - -#else - -int edit_replace_prompt (WEdit * edit, char *replace_text, int xpos, int ypos) -{ - int q, x[] = - { - B_CANCEL, B_ENTER, B_SKIP_REPLACE, B_REPLACE_ALL, B_REPLACE_ONE, B_CANCEL - }; - q = CQueryDialog (WIN_MESSAGES + (edit->curs_line < 8 ? edit->num_widget_lines / 2 * FONT_PIX_PER_LINE + CYof (edit->widget) : 0), - _ (" Replace "), catstrs (_ (" Replace with: "), replace_text, 0), _ ("Replace"), _ ("Skip"), _ ("Replace all"), _ ("Replace one"), _ ("Cancel"), 0); - edit->force |= REDRAW_COMPLETELY; - return x[q + 1]; -} - -#endif - -#endif - -long sargs[NUM_REPL_ARGS][256 / sizeof (long)]; +static long sargs[NUM_REPL_ARGS][256 / sizeof (long)]; #define SCANF_ARGS sargs[0], sargs[1], sargs[2], sargs[3], \ sargs[4], sargs[5], sargs[6], sargs[7], \ @@ -2148,7 +1642,7 @@ void edit_replace_cmd (WEdit * edit, int again) convert_to_display (exp1); if (exp2 && *exp2) convert_to_display (exp2); -#endif +#endif /* HAVE_CHARSET */ edit_replace_dialog (edit, &exp1, &exp2, &exp3); @@ -2157,7 +1651,7 @@ void edit_replace_cmd (WEdit * edit, int again) convert_from_input (exp1); if (exp2 && *exp2) convert_from_input (exp2); -#endif +#endif /* HAVE_CHARSET */ treplace_prompt = replace_prompt; } @@ -2243,12 +1737,9 @@ void edit_replace_cmd (WEdit * edit, int again) /*so that undo stops at each query */ edit_push_key_press (edit); - switch (edit_replace_prompt (edit, exp2, /*and prompt 2/3 down */ -#ifdef MIDNIGHT - (edit->num_widget_columns - CONFIRM_DLG_WIDTH)/2, edit->num_widget_lines * 2 / 3)) { -#else - edit->num_widget_columns / 2 - 33, edit->num_widget_lines * 2 / 3)) { -#endif + switch (edit_replace_prompt (edit, exp2, /* and prompt 2/3 down */ + (edit->num_widget_columns - CONFIRM_DLG_WIDTH)/2, + edit->num_widget_lines * 2 / 3)) { case B_ENTER: break; case B_SKIP_REPLACE: @@ -2359,14 +1850,14 @@ void edit_search_cmd (WEdit * edit, int again) #ifdef HAVE_CHARSET if (exp && *exp) convert_to_display (exp); -#endif +#endif /* HAVE_CHARSET */ edit_search_dialog (edit, &exp); #ifdef HAVE_CHARSET if (exp && *exp) convert_from_input (exp); -#endif +#endif /* HAVE_CHARSET */ edit_push_action (edit, KEY_PRESS + edit->start_display); } @@ -2446,36 +1937,9 @@ void edit_quit_cmd (WEdit * edit) { edit_push_action (edit, KEY_PRESS + edit->start_display); -#ifndef MIDNIGHT - if (edit->stopped) - return; -#endif - edit->force |= REDRAW_COMPLETELY; if (edit->modified) { -#ifdef GTK - char *r; - r = gtk_dialog_cauldron (_ (" Quit "), GTK_CAULDRON_TOPLEVEL | GTK_CAULDRON_GRAB, " [ ( %Lxf )xf ]xf / ( %Bgxfq || %Bgxfq || %Bgxfq ) ", - _ (" Current text was modified without a file save. \n Save with exit? "), GNOME_STOCK_BUTTON_CANCEL, GNOME_STOCK_BUTTON_YES, GNOME_STOCK_BUTTON_NO); - if (r == GNOME_STOCK_BUTTON_YES) { - edit_push_markers (edit); - edit_set_markers (edit, 0, 0, 0, 0); - if (!edit_save_cmd (edit)) - return; - } else if (r == GNOME_STOCK_BUTTON_NO) { - if (edit->delete_file) - unlink (catstrs (edit->dir, edit->filename, 0)); - } else { - return; - } -#else -#ifdef MIDNIGHT switch (edit_query_dialog3 (_ (" Quit "), _ (" File was modified, Save with exit? "), _ ("Cancel quit"), _ ("&Yes"), _ ("&No"))) { -#else -/* Confirm 'Quit' dialog box */ - switch (edit_query_dialog3 (_ (" Quit "), - _ (" Current text was modified without a file save. \n Save with exit? "), _ (" &Cancel quit "), _ (" &Yes "), _ (" &No "))) { -#endif case 1: edit_push_markers (edit); edit_set_markers (edit, 0, 0, 0, 0); @@ -2483,34 +1947,17 @@ void edit_quit_cmd (WEdit * edit) return; break; case 2: -#ifdef MIDNIGHT if (edit->delete_file) unlink (catstrs (edit->dir, edit->filename, 0)); -#endif break; case 0: case -1: return; } -#endif } -#if defined(MIDNIGHT) || defined(GTK) else if (edit->delete_file) unlink (catstrs (edit->dir, edit->filename, 0)); -#endif -#ifdef MIDNIGHT dlg_stop (edit->widget.parent); -#else -#ifdef GTK - { - extern char *edit_one_file; - - if (edit_one_file) - gtk_main_quit (); - } -#endif - edit->stopped = 1; -#endif } #define TEMP_BUF_LEN 1024 @@ -2588,188 +2035,6 @@ static int edit_save_block_to_clip_file (WEdit * edit, long start, long finish) return edit_save_block (edit, catstrs (home_dir, CLIP_FILE, 0), start, finish); } -#ifndef MIDNIGHT - -void paste_text (WEdit * edit, unsigned char *data, unsigned int nitems) -{ - if (data) { - data += nitems - 1; - while (nitems--) - edit_insert_ahead (edit, *data--); - } - edit->force |= REDRAW_COMPLETELY; -} - -char *selection_get_line (void *data, int line) -{ - static unsigned char t[1024]; - struct selection *s; - int i = 0; - s = (struct selection *) data; - line = (current_selection + line + 1) % NUM_SELECTION_HISTORY; - if (s[line].text) { - unsigned char *p = s[line].text; - int c, j; - for (j = 0; j < s[line].len; j++) { - c = *p++; - if (!isprint (c)) { - t[i++] = '_'; - t[i++] = '\b'; - t[i++] = '\\'; - t[i++] = '_'; - t[i++] = '\b'; - switch (c) { - case '\a': - t[i++] = 'a'; - break; - case '\b': - t[i++] = 'b'; - break; - case '\t': - t[i++] = 't'; - break; - case '\n': - t[i++] = 'n'; - break; - case '\v': - t[i++] = 'v'; - break; - case '\f': - t[i++] = 'f'; - break; - case '\r': - t[i++] = 'r'; - break; - default: - i -= 3; - t[i++] = '.'; - break; - } - } else - t[i++] = c; - if (i > 1000) - break; - } - } - t[i] = 0; - return (char *) t; -} - -void edit_paste_from_history (WEdit * edit) -{ - int i, c; - - edit_update_curs_col (edit); - edit_update_curs_row (edit); - - c = max (20, edit->num_widget_columns - 5); - -#ifdef GTK -#if 0 -/* *** */ - i = gtk_edit_list_box_dialog (c, 10, - 0, NUM_SELECTION_HISTORY - 10, NUM_SELECTION_HISTORY - 1, NUM_SELECTION_HISTORY, - selection_get_line, (void *) selection_history); -#else - i = -1; -#endif -#else - i = CListboxDialog (WIN_MESSAGES, c, 10, - 0, NUM_SELECTION_HISTORY - 10, NUM_SELECTION_HISTORY - 1, NUM_SELECTION_HISTORY, - selection_get_line, (void *) selection_history); -#endif - - if (i < 0) - return; - - i = (current_selection + i + 1) % NUM_SELECTION_HISTORY; - - paste_text (edit, selection_history[i].text, selection_history[i].len); - edit->force |= REDRAW_COMPLETELY; -} - -/* copies a block to the XWindows buffer */ -static int edit_XStore_block (WEdit * edit, long start, long finish) -{ - edit_get_selection (edit); - if (selection.len <= 512 * 1024) { /* we don't want to fill up the server */ - XStoreBytes (CDisplay, (char *) selection.text, (int) selection.len); - return 0; - } else - return 1; -} - -int edit_copy_to_X_buf_cmd (WEdit * edit) -{ - long start_mark, end_mark; - if (eval_marks (edit, &start_mark, &end_mark)) - return 0; - edit_XStore_block (edit, start_mark, end_mark); - if (!edit_save_block_to_clip_file (edit, start_mark, end_mark)) { - edit_error_dialog (_(" Copy to clipboard "), get_sys_error (_(" Unable to save to file. "))); - return 1; - } -#ifdef GTK - gtk_selection_owner_set (GTK_WIDGET (edit->widget), GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME); - edit->widget->editable.selection_start_pos = start_mark; - edit->widget->editable.selection_end_pos = end_mark; - edit->widget->editable.has_selection = TRUE; -#else - XSetSelectionOwner (CDisplay, XA_PRIMARY, CWindowOf (edit->widget), CurrentTime); -#endif - edit_mark_cmd (edit, 1); - return 0; -} - -int edit_cut_to_X_buf_cmd (WEdit * edit) -{ - long start_mark, end_mark; - if (eval_marks (edit, &start_mark, &end_mark)) - return 0; - edit_XStore_block (edit, start_mark, end_mark); - if (!edit_save_block_to_clip_file (edit, start_mark, end_mark)) { - edit_error_dialog (_(" Cut to clipboard "), _(" Unable to save to file. ")); - return 1; - } - edit_block_delete_cmd (edit); -#ifdef GTK - gtk_selection_owner_set (GTK_WIDGET (edit->widget), GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME); - edit->widget->editable.selection_start_pos = start_mark; - edit->widget->editable.selection_end_pos = end_mark; - edit->widget->editable.has_selection = TRUE; -#else - XSetSelectionOwner (CDisplay, XA_PRIMARY, CWindowOf (edit->widget), CurrentTime); -#endif - edit_mark_cmd (edit, 1); - return 0; -} - -void selection_paste (WEdit * edit, Window win, unsigned prop, int delete); - -void edit_paste_from_X_buf_cmd (WEdit * edit) -{ - if (selection.text) - paste_text (edit, selection.text, selection.len); - else if (!XGetSelectionOwner (CDisplay, XA_PRIMARY)) -#ifdef GTK -/* *** */ - ; -#else - selection_paste (edit, CRoot, XA_CUT_BUFFER0, False); -#endif - else -#ifdef GTK - gtk_selection_convert (GTK_WIDGET (edit->widget), GDK_SELECTION_PRIMARY, - gdk_atom_intern ("COMPOUND_TEXT", FALSE), GDK_CURRENT_TIME); -#else - XConvertSelection (CDisplay, XA_PRIMARY, XA_STRING, - XInternAtom (CDisplay, "VT_SELECTION", False), - CWindowOf (edit->widget), CurrentTime); -#endif - edit->force |= REDRAW_PAGE; -} - -#else /* MIDNIGHT */ void edit_paste_from_history (WEdit *edit) { @@ -2807,30 +2072,14 @@ void edit_paste_from_X_buf_cmd (WEdit * edit) edit_insert_file (edit, catstrs (home_dir, CLIP_FILE, 0)); } -#endif /* MIDNIGHT */ void edit_goto_cmd (WEdit *edit) { char *f; static int l = 0; -#ifdef MIDNIGHT char s[12]; sprintf (s, "%d", l); f = input_dialog (_(" Goto line "), _(" Enter line: "), l ? s : ""); -#else -#ifdef GTK -#if 0 - f = gtk_edit_dialog_input ("goto", 150, l ? itoa (l) : "", _(" Goto line "), _(" Enter line: ")); -#else - char s [12]; - - sprintf (s, "%d", l); - f = (char *) input_dialog (_(" Goto line "), _(" Enter line: "), l ? s : ""); -#endif -#else - f = CInputDialog ("goto", WIN_MESSAGES, 150, l ? itoa (l) : "", _(" Goto line "), _(" Enter line: ")); -#endif -#endif if (f) { if (*f) { l = atoi (f); @@ -2895,8 +2144,6 @@ int edit_insert_file_cmd (WEdit * edit) return 0; } -#ifdef MIDNIGHT - /* sorts a block, returns -1 on system fail, 1 on cancel and 0 on success */ int edit_sort_cmd (WEdit * edit) { @@ -3042,8 +2289,6 @@ void edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block) return; } -#endif /* MIDNIGHT */ - int edit_execute_cmd (WEdit * edit, int command, int char_for_insertion); /* prints at the cursor */ @@ -3070,8 +2315,6 @@ int edit_printf (WEdit * e, const char *fmt,...) return i; } -#ifdef MIDNIGHT - /* FIXME: does this function break NT_OS2 ? */ static void pipe_mail (WEdit *edit, char *to, char *subject, char *cc) @@ -3154,6 +2397,3 @@ void edit_mail_dialog (WEdit * edit) pipe_mail (edit, mail_to_last, mail_subject_last, mail_cc_last); } } - -#endif /* MIDNIGHT */ - diff --git a/edit/editdraw.c b/edit/editdraw.c index aad37632a..8446ad7d2 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -27,20 +27,12 @@ #define MAX_LINE_LEN 1024 -#if ! defined (MIDNIGHT) && ! defined (GTK) -#include "app_glob.c" -#include "coollocal.h" -#include "mad.h" -#endif - #ifdef HAVE_CHARSET -#include "../src/charsets.h" +#include "src/charsets.h" #endif extern int column_highlighting; -#if defined (MIDNIGHT) || defined (GTK) - static void status_string (WEdit * edit, char *s, int w, int fill, int font_width) { char byte_str[16]; @@ -79,10 +71,6 @@ static void status_string (WEdit * edit, char *s, int w, int fill, int font_widt byte_str); } -#endif /* MIDNIGHT || GTK */ - -#ifdef MIDNIGHT - /* how to get as much onto the status line as is numerically possible :) */ void edit_status (WEdit * edit) { @@ -113,94 +101,6 @@ void edit_status (WEdit * edit) free (s); } -#else - - -void render_status (CWidget * wdt, int expose); - -#ifdef GTK - -void edit_status (WEdit *edit) -{ - GtkEntry *entry; - int w, i, t; - char s[160]; - w = edit->num_widget_columns - 1; - if (w > 150) - w = 150; - if (w < 0) - w = 0; - memset (s, 0, w); - if (w > 1) { - i = w > 24 ? 18 : w - 6; - i = i < 13 ? 13 : i; - strcpy (s, (char *) name_trunc (edit->filename ? edit->filename : "", i)); - i = strlen (s); - s[i] = ' '; - s[i + 1] = ' '; - t = w - i - 2; - if (t < 0) - t = 0; - status_string (edit, s + i + 2, t, 0, FONT_MEAN_WIDTH); - } - s[w] = 0; - entry = GTK_ENTRY (edit->widget->status); - if (strcmp (s, gtk_entry_get_text (entry))) - gtk_entry_set_text (entry, s); -} - -#else - -void edit_status (WEdit * edit) -{ - long start_mark, end_mark; - CWidget *wdt; - mode_t m; - char *p; - char id[33]; - char s[256]; - if (eval_marks (edit, &start_mark, &end_mark)) - end_mark = start_mark = 0; - if ((COptionsOf (edit->widget) & EDITOR_NO_TEXT)) - return; - CPushFont ("editor", 0); - m = edit->stat.st_mode; - p = edit->filename ? edit->filename : ""; - sprintf (s, "\034%c%s\033\035 \034-%c%c%c%c%c%c%c%c%c\035 \034%s%s%s%c\035 \034\030%02ld\033\035 \034%-4ld+%2ld=\030%4ld\033/%3ld\035 \034*%-5ld/%5ldb=%c%3d\035%c \034\001%ld\033\035", - *p ? '\033' : '\003', *p ? (char *) name_trunc (p, max (edit->num_widget_lines / 3, 16)) : _ (""), - m & S_IRUSR ? 'r' : '-', - m & S_IWUSR ? 'w' : '-', - m & S_IXUSR ? 'x' : '-', - m & S_IRGRP ? 'r' : '-', - m & S_IWGRP ? 'w' : '-', - m & S_IXGRP ? 'x' : '-', - m & S_IROTH ? 'r' : '-', - m & S_IWOTH ? 'w' : '-', - m & S_IXOTH ? 'x' : '-', - end_mark - start_mark || (edit->mark2 == -1 && !edit->highlight) ? (column_highlighting ? "\032C\033" : "\001B\033") : "-", - edit->modified ? "\012M\033" : "-", edit->macro_i < 0 ? "-" : "\023R\033", - edit->overwrite == 0 ? '-' : 'O', - edit->curs_col / FONT_MEAN_WIDTH, edit->start_line + 1, edit->curs_row, - edit->curs_line + 1, edit->total_lines + 1, edit->curs1, - edit->last_byte, edit->curs1 == edit->last_byte ? '\014' : '\033', edit->curs1 < edit->last_byte - ? edit_get_byte (edit, edit->curs1) : -1, - end_mark - start_mark && !column_highlighting ? ' ' : '\0', - end_mark - start_mark); - strcpy (id, CIdentOf (edit->widget)); - strcat (id, ".text"); - wdt = CIdent (id); - free (wdt->text); - wdt->text = (char *) strdup (s); - CSetWidgetSize (id, CWidthOf (edit->widget), CHeightOf (wdt)); - render_status (wdt, 0); - CPopFont (); -} - -#endif /* GTK */ - -#endif /* !MIDNIGHT */ - - /* result is boolean */ int cursor_in_screen (WEdit * edit, long row) { @@ -230,10 +130,6 @@ int cursor_out_of_screen (WEdit * edit) return 0; } -#ifndef MIDNIGHT -int edit_width_of_long_printable (int c); -#endif - /* this scrolls the text so that cursor is on the screen */ void edit_scroll_screen_over_cursor (WEdit * edit) { @@ -262,18 +158,10 @@ void edit_scroll_screen_over_cursor (WEdit * edit) } p = edit_get_col (edit); edit_update_curs_row (edit); -#ifdef MIDNIGHT outby = p + edit->start_col - edit->num_widget_columns + 1 + (r_extreme + edit->found_len); -#else - outby = p + edit->start_col - CWidthOf (edit->widget) + 7 + (r_extreme + edit->found_len) * FONT_MEAN_WIDTH + edit_width_of_long_printable (edit_get_byte (edit, edit->curs1)); -#endif if (outby > 0) edit_scroll_right (edit, outby); -#ifdef MIDNIGHT outby = l_extreme - p - edit->start_col; -#else - outby = l_extreme * FONT_MEAN_WIDTH - p - edit->start_col; -#endif if (outby > 0) edit_scroll_left (edit, outby); p = edit->curs_row; @@ -286,53 +174,6 @@ void edit_scroll_screen_over_cursor (WEdit * edit) edit_update_curs_row (edit); } - -#ifndef MIDNIGHT - -#define CACHE_WIDTH 256 -#define CACHE_HEIGHT 128 - -int EditExposeRedraw = 0; -int EditClear = 0; - -/* - * background colors: marked is refers to mouse highlighting, - * highlighted refers to a found string. - */ -unsigned long edit_abnormal_color, edit_marked_abnormal_color; -unsigned long edit_highlighted_color, edit_marked_color; -unsigned long edit_normal_background_color; - -/* foreground colors */ -unsigned long edit_normal_foreground_color, edit_bold_color; -unsigned long edit_italic_color; - -/* cursor color */ -unsigned long edit_cursor_color; - -void edit_set_foreground_colors (unsigned long normal, unsigned long bold, unsigned long italic) -{ - edit_normal_foreground_color = normal; - edit_bold_color = bold; - edit_italic_color = italic; -} - -void edit_set_background_colors (unsigned long normal, unsigned long abnormal, unsigned long marked, unsigned long marked_abnormal, unsigned long highlighted) -{ - edit_abnormal_color = abnormal; - edit_marked_abnormal_color = marked_abnormal; - edit_marked_color = marked; - edit_highlighted_color = highlighted; - edit_normal_background_color = normal; -} - -void edit_set_cursor_color (unsigned long c) -{ - edit_cursor_color = c; -} - -#else - #define set_color(font) attrset (font) #define edit_move(x,y) widget_move(edit, y, x); @@ -470,49 +311,12 @@ static void edit_draw_this_line (WEdit * edit, long b, long row, long start_col, print_to_widget (edit, row, start_col, start_col_real, end_col, line); } -#endif - -#ifdef MIDNIGHT - #define key_pending(x) (!is_idle()) -#else - -#define edit_draw_this_line edit_draw_this_line_proportional - -int option_smooth_scrolling = 0; - -static int key_pending (WEdit * edit) -{ -#ifdef GTK - /* ******* */ -#else - static int flush = 0, line = 0; - if (!edit) { - flush = line = 0; - } else if (!(edit->force & REDRAW_COMPLETELY) && !EditExposeRedraw && !option_smooth_scrolling) { -/* this flushes the display in logarithmic intervals - so both fast and - slow machines will get good performance vs nice-refreshing */ - if ((1 << flush) == ++line) { - flush++; - return CKeyPending (); - } - } -#endif - return 0; -} - -#endif - - static void edit_draw_this_char (WEdit * edit, long curs, long row) { int b = edit_bol (edit, curs); -#ifdef MIDNIGHT edit_draw_this_line (edit, b, row, 0, edit->num_widget_columns - 1); -#else - edit_draw_this_line (edit, b, row, 0, CWidthOf (edit->widget)); -#endif } /* cursor must be in screen for other than REDRAW_PAGE passed in force */ @@ -525,95 +329,21 @@ void render_edit_text (WEdit * edit, long start_row, long start_column, long end static long prev_curs = 0; static long prev_start = -1; -#ifndef MIDNIGHT - static unsigned long prev_win = 0; -#endif - int force = edit->force; long b; CPushFont ("editor", 0); -#ifndef MIDNIGHT - key_pending (0); -#endif - /* * If the position of the page has not moved then we can draw the cursor * character only. This will prevent line flicker when using arrow keys. */ - if ((!(force & REDRAW_CHAR_ONLY)) || (force & REDRAW_PAGE) -#ifndef MIDNIGHT -#ifdef GTK - || prev_win != ((GdkWindowPrivate *) CWindowOf (edit->widget)->text_area)->xwindow -#else - || prev_win != CWindowOf (edit->widget) -#endif -#endif - ) { -#if !defined(MIDNIGHT) && !defined(GTK) - int time_division = 5; -#if 0 - if (CPending ()) - time_division--; -#endif - if (prev_start < 0) - prev_start = edit->start_line; - if (option_smooth_scrolling && prev_win == CWindowOf (edit->widget) && !edit->screen_modified) { - int i, t; - int pos1, pos2; - i = edit->start_line - prev_start; - if (i <= time_division && i > 0) { - edit_draw_proportional (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - for (pos2 = 0, t = 0; t < time_division; t++) { - int move; - pos1 = FONT_PIX_PER_LINE * i * (t + 1) / time_division; - move = pos1 - pos2; - pos2 += move; - XCopyArea (CDisplay, edit->widget->winid, edit->widget->winid, CGC, - EDIT_TEXT_HORIZONTAL_OFFSET, - EDIT_TEXT_VERTICAL_OFFSET + move, - edit->widget->width - EDIT_FRAME_W, - edit->widget->height - EDIT_FRAME_H - move, - EDIT_TEXT_HORIZONTAL_OFFSET, EDIT_TEXT_VERTICAL_OFFSET); - XClearArea (CDisplay, edit->widget->winid, EDIT_TEXT_HORIZONTAL_OFFSET, - edit->widget->height - EDIT_FRAME_H + - EDIT_TEXT_VERTICAL_OFFSET - move, - edit->widget->width - EDIT_FRAME_W, move, 0); - XFlush (CDisplay); - pause (); - } - } else if (i >= -time_division && i < 0) { - edit_draw_proportional (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - i = -i; - for (pos2 = 0, t = 0; t < time_division; t++) { - int move; - pos1 = FONT_PIX_PER_LINE * i * (t + 1) / time_division; - move = pos1 - pos2; - pos2 += move; - XCopyArea (CDisplay, edit->widget->winid, edit->widget->winid, CGC, - EDIT_TEXT_HORIZONTAL_OFFSET, EDIT_TEXT_VERTICAL_OFFSET, - edit->widget->width - EDIT_FRAME_W, - edit->widget->height - EDIT_FRAME_H - - move, EDIT_TEXT_HORIZONTAL_OFFSET, EDIT_TEXT_VERTICAL_OFFSET + move); - XClearArea (CDisplay, edit->widget->winid, EDIT_TEXT_HORIZONTAL_OFFSET, - EDIT_TEXT_VERTICAL_OFFSET, - edit->widget->width - EDIT_FRAME_W, move, 0); - XFlush (CDisplay); - pause (); - } - } - } -#endif + if ((!(force & REDRAW_CHAR_ONLY)) || (force & REDRAW_PAGE)) { if (!(force & REDRAW_IN_BOUNDS)) { /* !REDRAW_IN_BOUNDS means to ignore bounds and redraw whole rows */ start_row = 0; end_row = edit->num_widget_lines - 1; start_column = 0; -#ifdef MIDNIGHT end_column = edit->num_widget_columns - 1; -#else - end_column = CWidthOf (edit->widget); -#endif } if (force & REDRAW_PAGE) { row = start_row; @@ -696,13 +426,6 @@ void render_edit_text (WEdit * edit, long start_row, long start_column, long end prev_curs_row = edit->curs_row; prev_curs = edit->curs1; prev_start_col = edit->start_col; -#ifndef MIDNIGHT -#ifdef GTK - prev_win = ((GdkWindowPrivate *) CWindowOf (edit->widget)->text_area)->xwindow; -#else - prev_win = CWindowOf (edit->widget); -#endif -#endif exit_render: edit->screen_modified = 0; prev_start = edit->start_line; @@ -710,99 +433,18 @@ void render_edit_text (WEdit * edit, long start_row, long start_column, long end return; } - - -#ifndef MIDNIGHT - -void edit_convert_expose_to_area (XExposeEvent * xexpose, int *row1, int *col1, int *row2, int *col2) -{ - *col1 = xexpose->x - EDIT_TEXT_HORIZONTAL_OFFSET; - *row1 = (xexpose->y - EDIT_TEXT_VERTICAL_OFFSET) / FONT_PIX_PER_LINE; - *col2 = xexpose->x + xexpose->width + EDIT_TEXT_HORIZONTAL_OFFSET + 3; - *row2 = (xexpose->y + xexpose->height - EDIT_TEXT_VERTICAL_OFFSET) / FONT_PIX_PER_LINE; -} - -#ifdef GTK - -void edit_render_tidbits (GtkEdit * edit) -{ - gtk_widget_draw_focus (GTK_WIDGET (edit)); -} - -#else - -void edit_render_tidbits (CWidget * wdt) -{ - int isfocussed; - int w = wdt->width, h = wdt->height; - Window win; - - win = wdt->winid; - isfocussed = (win == CGetFocus ()); - CSetColor (COLOR_FLAT); -#ifdef NEXT_LOOK - render_bevel (win, 0, 0, w - 1, h - 1, 1, 1); /*most outer border bevel */ -#else - if (isfocussed) { - render_bevel (win, 0, 0, w - 1, h - 1, 3, 1); /*most outer border bevel */ - } else { - render_bevel (win, 2, 2, w - 3, h - 3, 1, 1); /*border bevel */ - render_bevel (win, 0, 0, w - 1, h - 1, 2, 0); /*most outer border bevel */ - } -#endif -} - -#endif - void edit_set_space_width (int s); extern int option_long_whitespace; -#endif - void edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end, int col_end) { int f = 0; -#ifdef GTK - GtkEdit *win; -#endif if (page) /* if it was an expose event, 'page' would be set */ edit->force |= REDRAW_PAGE | REDRAW_IN_BOUNDS; f = edit->force & (REDRAW_PAGE | REDRAW_COMPLETELY); -#ifdef MIDNIGHT if (edit->force & REDRAW_COMPLETELY) redraw_labels (edit->widget.parent, (Widget *) edit); -#else - if (option_long_whitespace) - edit_set_space_width (FONT_PER_CHAR[' '] * 2); - else - edit_set_space_width (FONT_PER_CHAR[' ']); -#ifdef GTK - win = (GtkEdit *) edit->widget; -#endif - edit_set_foreground_colors ( - color_palette (option_editor_fg_normal), - color_palette (option_editor_fg_bold), - color_palette (option_editor_fg_italic) - ); - edit_set_background_colors ( - color_palette (option_editor_bg_normal), - color_palette (option_editor_bg_abnormal), - color_palette (option_editor_bg_marked), - color_palette (option_editor_bg_marked_abnormal), - color_palette (option_editor_bg_highlighted) - ); - edit_set_cursor_color ( - color_palette (option_editor_fg_cursor) - ); - -#ifdef GTK - /* *********** */ -#else - if (!EditExposeRedraw) - set_cursor_position (0, 0, 0, 0, 0, 0, 0, 0, 0); -#endif -#endif render_edit_text (edit, row_start, col_start, row_end, col_end); /* * edit->force != 0 means a key was pending and the redraw @@ -811,52 +453,9 @@ void edit_render (WEdit * edit, int page, int row_start, int col_start, int row_ */ if (edit->force) edit->force |= REDRAW_PAGE; -#ifndef MIDNIGHT - if (f) { - edit_render_tidbits (edit->widget); -#ifdef GTK - /* ***************** */ -#else -#ifndef NEXT_LOOK - CSetColor (edit_normal_background_color); - CLine (CWindowOf (edit->widget), 3, 3, 3, CHeightOf (edit->widget) - 4); -#endif -#endif - } -#endif } -#ifndef MIDNIGHT -void edit_render_expose (WEdit * edit, XExposeEvent * xexpose) -{ - int row_start, col_start, row_end, col_end; - CPushFont ("editor", 0); - EditExposeRedraw = 1; - edit->num_widget_lines = (CHeightOf (edit->widget) - EDIT_FRAME_H) / FONT_PIX_PER_LINE; - edit->num_widget_columns = (CWidthOf (edit->widget) - EDIT_FRAME_W) / FONT_MEAN_WIDTH; - if (edit->force & (REDRAW_PAGE | REDRAW_COMPLETELY)) { - edit->force |= REDRAW_PAGE | REDRAW_COMPLETELY; - edit_render_keypress (edit); - } else { - edit_convert_expose_to_area (xexpose, &row_start, &col_start, &row_end, &col_end); - edit_render (edit, 1, row_start, col_start, row_end, col_end); - } - CPopFont (); - EditExposeRedraw = 0; -} - -void edit_render_keypress (WEdit * edit) -{ - CPushFont ("editor", 0); - edit_render (edit, 0, 0, 0, 0, 0); - CPopFont (); -} - -#else - void edit_render_keypress (WEdit * edit) { edit_render (edit, 0, 0, 0, 0, 0); } - -#endif diff --git a/edit/editoptions.c b/edit/editoptions.c index bacb11fa1..a76c6e3cd 100644 --- a/edit/editoptions.c +++ b/edit/editoptions.c @@ -30,7 +30,7 @@ #define USE_INTERNAL_EDIT 1 #endif -#include "../src/main.h" /* extern int option_this_and_that ... */ +#include "src/main.h" /* extern int option_this_and_that ... */ char *key_emu_str[] = {N_("Intuitive"), N_("Emacs"), NULL}; @@ -81,13 +81,13 @@ void edit_options_dialog (void) {quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 5, OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0, "edit-tab-spacing"}, /*6 */ -#if !defined(MIDNIGHT) || defined(HAVE_SYNTAXH) +#ifdef HAVE_SYNTAXH #define OA 1 {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, N_("synta&X highlighting"), 8, 0, 0, 0, NULL}, #else #define OA 0 -#endif +#endif /* !HAVE_SYNTAXH */ /*7 */ {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 8, OPT_DLG_H, N_("confir&M before saving"), 6, 0, 0, 0, NULL}, @@ -170,10 +170,6 @@ void edit_options_dialog (void) option_tab_spacing = atoi (q); if (option_tab_spacing < 0) option_tab_spacing = 2; -#if 0 - /* Only allow even numbers */ - option_tab_spacing += option_tab_spacing & 1; -#endif free (q); } option_syntax_highlighting = *quick_widgets[5 + OA].result;