mc/gtkedit/edit.h

785 lines
23 KiB
C
Raw Normal View History

1998-10-27 22:53:38 +03:00
/* edit.h - main include file
Copyright (C) 1996, 1997 the Free Software Foundation
Authors: 1996, 1997 Paul Sheer
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307, USA.
*/
1998-10-27 22:53:38 +03:00
1998-09-15 00:18:54 +04:00
#ifndef __EDIT_H
#define __EDIT_H
#ifdef MIDNIGHT
#ifdef HAVE_SLANG
#define HAVE_SYNTAXH 1
#endif
# include <stdio.h>
# include <stdarg.h>
# include <sys/types.h>
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
# include <string.h>
# include <ctype.h>
# include <errno.h>
1998-09-15 00:18:54 +04:00
# include "src/tty.h"
# include <sys/stat.h>
# include <errno.h>
# include <fcntl.h>
1998-09-15 00:18:54 +04:00
# include <stdlib.h>
# ifdef HAVE_MALLOC_H
# include <malloc.h>
# endif
1998-09-15 00:18:54 +04:00
#else /* ! MIDNIGHT */
# include "global.h"
# include <stdio.h>
# include <stdarg.h>
# include <sys/types.h>
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
#ifdef GTK
# include <string.h>
#else
# include <my_string.h>
#endif
# include <ctype.h>
# include <errno.h>
1998-09-15 00:18:54 +04:00
# include <sys/stat.h>
# ifdef HAVE_FCNTL_H
# include <fcntl.h>
# endif
# include <stdlib.h>
# include <stdarg.h>
# if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
# else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
# endif
# include "regex.h"
1998-09-15 00:18:54 +04:00
#endif
#ifndef MIDNIGHT
# include <signal.h>
# include <X11/Xlib.h>
# include <X11/Xutil.h>
# include <X11/Xresource.h>
# include "lkeysym.h"
#ifndef GTK
# include "coolwidget.h"
# include "app_glob.c"
# include "coollocal.h"
# include "stringtools.h"
#else
# include "gtk/gtk.h"
# include "gdk/gdkprivate.h"
# include "gdk/gdk.h"
# include "gtkedit.h"
# include "editcmddef.h"
# ifndef _
1998-09-15 00:18:54 +04:00
# define _(x) x
# define N_(x) x
# endif
#endif
#else
1999-09-19 Andrew V. Samoilov <sav@bcs.zp.ua> * src/user.c (check_patterns): char* is used instead of char [] in sizeof * src/util.c (string_perm): prefix named pipes by 'p' and not by `s' 1999-09-19 David Martin <dmartina@usa.net> * gtkedit/editcmd.c (edit_print_string): Use unsigned char so that 8 bit chars from strftime get displayed when inserting date. * lib/mc.ext.in: Add entries for bzip2 compressed pages as used in Mandrake 6.0. The generic entry for bzip2 moved to the end of the file to avoid interferences. In this one I changed the extension check to a type check (as used for gzip) which might give problems in some systems. * configure.in: Use -Tlatin1 to format man pages when available and "view" 8 bit chars. 1999-09-19 Norbert Warmuth <nwarmuth@privat.circular.de> * gtkedit/edit.h: Include files reordered in order to make it compile with --with-debug * gtkedit/editcmd.c (menu_save_mode_cmd): calculate dialog width dependent on lenght of translated strings to display. * src/mad.c, mad.h, util.c, util.h: Move mad-functions from util.[ch] to mad.[ch] * src/option.c: Include files reordered in order to make it compile with --with-debug * src/mad.c (mad_init): New function. Initialize debug FILE pointer to stderr (moved to a function because not on every system stderr is a constant). (mad_set_debug): added const qualifier * src/main.c (main): call mad_init * po/*.po: s/defination/definition/ * gnome/Makefile.in ($(MAGICDEV_GENERATED)): Make it compile with $buildir != $srcdir. * vfs/ftpfs.c (ftpfs_set_debug), vfs.h: added const qualifier. * vfs/mcserv.c: removed definition of mad_strconcat which is also in mad.c.
1999-09-20 03:09:07 +04:00
# include "src/global.h"
1998-09-15 00:18:54 +04:00
# include "src/main.h" /* for char *shell */
# include "src/mad.h"
1998-09-15 00:18:54 +04:00
# include "src/dlg.h"
# include "src/widget.h"
# include "src/color.h"
# include "src/dialog.h"
# include "src/mouse.h"
# include "src/help.h"
# include "src/key.h"
# include "src/wtools.h" /* for QuickWidgets */
# include "src/win.h"
# include "vfs/vfs.h"
# include "src/menu.h"
1999-01-27 02:46:11 +03:00
# include <regex.h>
1998-09-15 00:18:54 +04:00
# define WANT_WIDGETS
# define WIDGET_COMMAND (WIDGET_USER + 10)
# define N_menus 5
#endif
#ifdef GTK
/* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */
#if defined(HAVE_DIRENT_H) || defined(_POSIX_VERSION)
# include <dirent.h>
# define NLENGTH(dirent) (strlen ((dirent)->d_name))
#else
# define dirent direct
# define NLENGTH(dirent) ((dirent)->d_namlen)
# ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H
# include <ndir.h>
# endif /* HAVE_NDIR_H */
#endif /* not (HAVE_DIRENT_H or _POSIX_VERSION) */
# ifndef _
# define _(x) x
# define N_(x) x
# endif
1998-09-15 00:18:54 +04:00
#include "vfs/vfs.h"
# define CDisplay gdk_display
# define CRoot gdk_root_parent
# define Window GtkEdit *
#endif
#define SEARCH_DIALOG_OPTION_NO_SCANF 1
#define SEARCH_DIALOG_OPTION_NO_REGEX 2
#define SEARCH_DIALOG_OPTION_NO_CASE 4
#define SEARCH_DIALOG_OPTION_BACKWARDS 8
#define SEARCH_DIALOG_OPTION_BOOKMARK 16
1998-09-15 00:18:54 +04:00
#define EDIT_KEY_EMULATION_NORMAL 0
#define EDIT_KEY_EMULATION_EMACS 1
#define REDRAW_LINE (1 << 0)
#define REDRAW_LINE_ABOVE (1 << 1)
#define REDRAW_LINE_BELOW (1 << 2)
#define REDRAW_AFTER_CURSOR (1 << 3)
#define REDRAW_BEFORE_CURSOR (1 << 4)
#define REDRAW_PAGE (1 << 5)
#define REDRAW_IN_BOUNDS (1 << 6)
#define REDRAW_CHAR_ONLY (1 << 7)
#define REDRAW_COMPLETELY (1 << 8)
#define MOD_ABNORMAL (1 << 0)
#define MOD_UNDERLINED (1 << 1)
#define MOD_BOLD (1 << 2)
#define MOD_HIGHLIGHTED (1 << 3)
#define MOD_MARKED (1 << 4)
#define MOD_ITALIC (1 << 5)
#define MOD_CURSOR (1 << 6)
#define MOD_INVERSE (1 << 7)
#ifndef MIDNIGHT
# ifdef GTK
# define EDIT_TEXT_HORIZONTAL_OFFSET 0
# define EDIT_TEXT_VERTICAL_OFFSET 0
# else
# define EDIT_TEXT_HORIZONTAL_OFFSET 4
# define EDIT_TEXT_VERTICAL_OFFSET 3
# endif
#else
# define EDIT_TEXT_HORIZONTAL_OFFSET 0
# define EDIT_TEXT_VERTICAL_OFFSET 1
# define FONT_OFFSET_X 0
# define FONT_OFFSET_Y 0
#endif
#define EDIT_RIGHT_EXTREME option_edit_right_extreme
#define EDIT_LEFT_EXTREME option_edit_left_extreme
#define EDIT_TOP_EXTREME option_edit_top_extreme
#define EDIT_BOTTOM_EXTREME option_edit_bottom_extreme
/*there are a maximum of ... */
/*... edit buffers, each of which is ... */
#define EDIT_BUF_SIZE 0x10000
/* ...bytes in size. */
/*x / EDIT_BUF_SIZE equals x >> ... */
#define S_EDIT_BUF_SIZE 16
/* x % EDIT_BUF_SIZE is equal to x && ... */
#define M_EDIT_BUF_SIZE 0xFFFF
#define SIZE_LIMIT (EDIT_BUF_SIZE * (MAXBUFF - 2))
/* Note a 16k stack is 64k of data and enough to hold (usually) around 10
pages of undo info. */
/* undo stack */
#define START_STACK_SIZE 32
/*some codes that may be pushed onto or returned from the undo stack: */
#define CURS_LEFT 601
#define CURS_RIGHT 602
#define DELETE 603
#define BACKSPACE 604
#define STACK_BOTTOM 605
#define CURS_LEFT_LOTS 606
#define CURS_RIGHT_LOTS 607
#define COLUMN_ON 608
#define COLUMN_OFF 609
#define MARK_1 1000
#define MARK_2 700000000
#define KEY_PRESS 1400000000
/*Tabs spaces: (sofar only HALF_TAB_SIZE is used: */
#define TAB_SIZE option_tab_spacing
#define HALF_TAB_SIZE ((int) option_tab_spacing / 2)
struct selection {
unsigned char * text;
int len;
};
#define MAX_WORDS_PER_CONTEXT 1024
#define MAX_CONTEXTS 128
1998-09-15 00:18:54 +04:00
struct key_word {
char *keyword;
unsigned char first;
1998-09-15 00:18:54 +04:00
char *whole_word_chars_left;
char *whole_word_chars_right;
time_t time;
#define NO_COLOR 0x7FFFFFFF
#define SPELLING_ERROR 0x7EFEFEFE
1998-09-15 00:18:54 +04:00
int line_start;
int bg;
int fg;
};
struct context_rule {
char *left;
unsigned char first_left;
1998-09-15 00:18:54 +04:00
char *right;
unsigned char first_right;
char line_start_left;
1998-09-15 00:18:54 +04:00
char line_start_right;
int single_char;
int between_delimiters;
char *whole_word_chars_left;
char *whole_word_chars_right;
char *keyword_first_chars;
int spelling;
1998-09-15 00:18:54 +04:00
/* first word is word[1] */
struct key_word **keyword;
};
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> * src/user.c: Add macro %k it is block file name Add macro %e it is error file name Add macro %i it is cursor column indent of spaces, only for edit Add macro %y, it is syntax of current file in editor, only for edit Add condition y , it is syntax pattern of current file in edit Add macro %x it is extension of current file Add macro %m it is current menu filename 2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> * gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) . Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc, edit.ispell.rc, etc. Remove leading and trailing spaces into _(""), (the message of David H. Martin <dmartina@usa.net>) 2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> * src/user.c: Add condition (x filename) into mc.menu . for "Open next a free console" and like. 2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> src/user.c: fix segfault in chunk_alloc of glibc, when into condition of .mnu we have quoted space. (~.mc/menu: + f \.\ test$). 2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> * gtkedit/edit.c: Add ability user edit menus: system: /usr/lib/mc/cedit.menu, * gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu Marked block is access now from an user edit menu Access ~/.cedit/cooledit.block for insert to cursor place from user edit menu. Created system cedit.menu 2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> * gtkedit/editdraw.c: Improved a status string of cool editor for best understand, and to add char,hex view. 2000-05-04 Richard Hestilow <hestgray@ionet.net> * gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
#include "edit-widget.h"
1998-09-15 00:18:54 +04:00
#ifndef MIDNIGHT
void edit_render_expose (WEdit * edit, XExposeEvent * xexpose);
#ifndef GTK
void edit_render_tidbits (struct cool_widget *w);
int eh_editor (CWidget * w, XEvent * xevent, CEvent * cwevent);
#endif
void edit_draw_menus (Window parent, int x, int y);
void edit_run_make (void);
void edit_change_directory (void);
int edit_man_page_cmd (WEdit * edit);
void edit_search_replace_dialog (Window parent, int x, int y, char **search_text, char **replace_text, char **arg_order, char *heading, int option);
void edit_search_dialog (WEdit * edit, char **search_text);
long edit_find (long search_start, unsigned char *expr, int *len, long last_byte, int (*get_byte) (void *, long), void *data, void *d);
1998-09-15 00:18:54 +04:00
void edit_set_foreground_colors (unsigned long normal, unsigned long bold, unsigned long italic);
void edit_set_background_colors (unsigned long normal, unsigned long abnormal, unsigned long marked, unsigned long marked_abnormal, unsigned long highlighted);
void edit_set_cursor_color (unsigned long c);
void draw_options_dialog (Window parent, int x, int y);
void CRefreshEditor (WEdit * edit);
void edit_set_user_command (void (*func) (WEdit *, int));
void edit_draw_this_line_proportional (WEdit * edit, long b, int curs_row, int start_column, int end_column);
unsigned char get_international_character (unsigned char key_press);
void edit_set_user_key_function (int (*user_def_key_func) (unsigned int, unsigned int, KeySym keysym));
#else
int edit_drop_hotkey_menu (WEdit * e, int key);
void edit_menu_cmd (WEdit * e);
void edit_init_menu_emacs (void);
void edit_init_menu_normal (void);
void edit_done_menu (void);
int edit_raw_key_query (char *heading, char *query, int cancel);
char *strcasechr (const unsigned char *s, int c);
int edit (const char *_file, int line);
int edit_translate_key (WEdit * edit, unsigned int x_keycode, long x_key, int x_state, int *cmd, int *ch);
#endif
#ifndef NO_INLINE_GETBYTE
int edit_get_byte (WEdit * edit, long byte_index);
#else
static inline int edit_get_byte (WEdit * edit, long byte_index)
{
unsigned long p;
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
return '\n';
if (byte_index >= edit->curs1) {
p = edit->curs1 + edit->curs2 - byte_index - 1;
return edit->buffers2[p >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - (p & M_EDIT_BUF_SIZE) - 1];
} else {
return edit->buffers1[byte_index >> S_EDIT_BUF_SIZE][byte_index & M_EDIT_BUF_SIZE];
}
}
#endif
char *edit_get_buffer_as_text (WEdit * edit);
int edit_count_lines (WEdit * edit, long current, int upto);
long edit_move_forward (WEdit * edit, long current, int lines, long upto);
long edit_move_forward3 (WEdit * edit, long current, int cols, long upto);
long edit_move_backward (WEdit * edit, long current, int lines);
void edit_scroll_screen_over_cursor (WEdit * edit);
void edit_render_keypress (WEdit * edit);
void edit_scroll_upward (WEdit * edit, unsigned long i);
void edit_scroll_downward (WEdit * edit, int i);
void edit_scroll_right (WEdit * edit, int i);
void edit_scroll_left (WEdit * edit, int i);
int edit_get_col (WEdit * edit);
long edit_bol (WEdit * edit, long current);
long edit_eol (WEdit * edit, long current);
void edit_update_curs_row (WEdit * edit);
void edit_update_curs_col (WEdit * edit);
void edit_block_copy_cmd (WEdit * edit);
void edit_block_move_cmd (WEdit * edit);
int edit_block_delete_cmd (WEdit * edit);
int edit_block_delete (WEdit * edit);
void edit_delete_line (WEdit * edit);
int edit_delete (WEdit * edit);
void edit_insert (WEdit * edit, int c);
int edit_cursor_move (WEdit * edit, long increment);
void edit_push_action (WEdit * edit, long c,...);
void edit_push_key_press (WEdit * edit);
void edit_insert_ahead (WEdit * edit, int c);
int edit_save_file (WEdit * edit, const char *filename);
long edit_write_stream (WEdit * edit, FILE * f);
char *edit_get_write_filter (char *writename, const char *filename);
1998-09-15 00:18:54 +04:00
int edit_save_cmd (WEdit * edit);
int edit_save_confirm_cmd (WEdit * edit);
int edit_save_as_cmd (WEdit * edit);
WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, const char *text, const char *dir, unsigned long text_size);
int edit_clean (WEdit * edit);
int edit_renew (WEdit * edit);
int edit_new_cmd (WEdit * edit);
int edit_reload (WEdit * edit, const char *filename, const char *text, const char *dir, unsigned long text_size);
int edit_load_cmd (WEdit * edit);
void edit_mark_cmd (WEdit * edit, int unmark);
void edit_set_markers (WEdit * edit, long m1, long m2, int c1, int c2);
void edit_push_markers (WEdit * edit);
void edit_quit_cmd (WEdit * edit);
void edit_replace_cmd (WEdit * edit, int again);
void edit_search_cmd (WEdit * edit, int again);
int edit_save_block (WEdit * edit, const char *filename, long start, long finish);
1998-09-15 00:18:54 +04:00
int edit_save_block_cmd (WEdit * edit);
int edit_insert_file_cmd (WEdit * edit);
int edit_insert_file (WEdit * edit, const char *filename);
void edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block);
char *catstrs (const char *first,...);
void edit_refresh_cmd (WEdit * edit);
void edit_date_cmd (WEdit * edit);
void edit_goto_cmd (WEdit * edit);
int eval_marks (WEdit * edit, long *start_mark, long *end_mark);
void edit_status (WEdit * edit);
int edit_execute_command (WEdit * edit, int command, int char_for_insertion);
int edit_execute_key_command (WEdit * edit, int command, int char_for_insertion);
void edit_update_screen (WEdit * edit);
int edit_printf (WEdit * e, const char *fmt,...);
int edit_print_string (WEdit * e, const char *s);
void edit_move_to_line (WEdit * e, long line);
void edit_move_display (WEdit * e, long line);
void edit_word_wrap (WEdit * edit);
unsigned char *edit_get_block (WEdit * edit, long start, long finish, int *l);
int edit_sort_cmd (WEdit * edit);
void edit_help_cmd (WEdit * edit);
void edit_left_word_move (WEdit * edit, int s);
void edit_right_word_move (WEdit * edit, int s);
1998-09-15 00:18:54 +04:00
void edit_get_selection (WEdit * edit);
int edit_save_macro_cmd (WEdit * edit, struct macro macro[], int n);
int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k);
void edit_delete_macro_cmd (WEdit * edit);
int edit_copy_to_X_buf_cmd (WEdit * edit);
int edit_cut_to_X_buf_cmd (WEdit * edit);
void edit_paste_from_X_buf_cmd (WEdit * edit);
void edit_paste_from_history (WEdit *edit);
void edit_split_filename (WEdit * edit, const char *name);
1998-09-15 00:18:54 +04:00
#ifdef MIDNIGHT
#define CWidget Widget
#elif defined(GTK)
#define CWidget GtkEdit
#endif
void edit_set_syntax_change_callback (void (*callback) (CWidget *));
void edit_load_syntax (WEdit * edit, char **names, char *type);
void edit_free_syntax_rules (WEdit * edit);
void edit_get_syntax_color (WEdit * edit, long byte_index, int *fg, int *bg);
int edit_check_spelling (WEdit * edit);
1998-09-15 00:18:54 +04:00
void book_mark_insert (WEdit * edit, int line, int c);
int book_mark_query_color (WEdit * edit, int line, int c);
int book_mark_query_all (WEdit * edit, int line, int *c);
struct _book_mark *book_mark_find (WEdit * edit, int line);
int book_mark_clear (WEdit * edit, int line, int c);
void book_mark_flush (WEdit * edit, int c);
void book_mark_inc (WEdit * edit, int line);
void book_mark_dec (WEdit * edit, int line);
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> * src/user.c: Add macro %k it is block file name Add macro %e it is error file name Add macro %i it is cursor column indent of spaces, only for edit Add macro %y, it is syntax of current file in editor, only for edit Add condition y , it is syntax pattern of current file in edit Add macro %x it is extension of current file Add macro %m it is current menu filename 2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> * gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) . Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc, edit.ispell.rc, etc. Remove leading and trailing spaces into _(""), (the message of David H. Martin <dmartina@usa.net>) 2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> * src/user.c: Add condition (x filename) into mc.menu . for "Open next a free console" and like. 2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> src/user.c: fix segfault in chunk_alloc of glibc, when into condition of .mnu we have quoted space. (~.mc/menu: + f \.\ test$). 2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> * gtkedit/edit.c: Add ability user edit menus: system: /usr/lib/mc/cedit.menu, * gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu Marked block is access now from an user edit menu Access ~/.cedit/cooledit.block for insert to cursor place from user edit menu. Created system cedit.menu 2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su> * gtkedit/editdraw.c: Improved a status string of cool editor for best understand, and to add char,hex view. 2000-05-04 Richard Hestilow <hestgray@ionet.net> * gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
void user_menu (WEdit *edit);
void edit_init_file();
1998-09-15 00:18:54 +04:00
#ifdef MIDNIGHT
#define CPushFont(x,y)
#define CPopFont()
#define FIXED_FONT 1
1998-09-15 00:18:54 +04:00
/* put OS2/NT/WIN95 defines here */
# ifdef USE_O_TEXT
1998-09-15 00:18:54 +04:00
# define MY_O_TEXT O_TEXT
# else
# define MY_O_TEXT 0
# endif
# define FONT_PIX_PER_LINE 1
# define FONT_MEAN_WIDTH 1
# define get_sys_error(s) (s)
# define open mc_open
# define close(f) mc_close(f)
# define read(f,b,c) mc_read(f,b,c)
# define write(f,b,c) mc_write(f,b,c)
# define stat(f,s) mc_stat(f,s)
# define mkdir(s,m) mc_mkdir(s,m)
# define itoa MY_itoa
# define edit_get_load_file(d,f,h) input_dialog (h, " Enter file name: ", f)
# define edit_get_save_file(d,f,h) input_dialog (h, " Enter file name: ", f)
# define CMalloc(x) malloc(x)
# define set_error_msg(s) edit_init_error_msg = strdup(s)
# ifdef _EDIT_C
# define edit_error_dialog(h,s) set_error_msg(s)
char *edit_init_error_msg = NULL;
# else /* ! _EDIT_C */
# define edit_error_dialog(h,s) query_dialog (h, s, 0, 1, _("&Dismiss"))
# define edit_message_dialog(h,s) query_dialog (h, s, 0, 1, _("&Ok"))
extern char *edit_init_error_msg;
# endif /* ! _EDIT_C */
# define get_error_msg(s) edit_init_error_msg
# define edit_query_dialog2(h,t,a,b) query_dialog(h,t,0,2,a,b)
# define edit_query_dialog3(h,t,a,b,c) query_dialog(h,t,0,3,a,b,c)
# define edit_query_dialog4(h,t,a,b,c,d) query_dialog(h,t,0,4,a,b,c,d)
#else /* ! MIDNIGHT */
# ifdef GTK
# define CPushFont(x,y)
# define CPopFont()
# define FIXED_FONT gtk_edit_fixed_font
1998-09-15 00:18:54 +04:00
# define get_sys_error(s) (s)
# define open mc_open
# define close(f) mc_close(f)
# define read(f,b,c) mc_read(f,b,c)
# define write(f,b,c) mc_write(f,b,c)
# define stat(f,s) mc_stat(f,s)
# define mkdir(s,m) mc_mkdir(s,m)
# define itoa MY_itoa
# define CMalloc(x) malloc(x)
# define EDITOR_NO_FILE (1<<3)
# define EDITOR_NO_SCROLL (1<<4)
# define EDITOR_NO_TEXT (1<<5)
# define EDITOR_HORIZ_SCROLL (1<<6)
#include <gdk/gdkprivate.h>
# define CWindowOf(w) (w)
# define CHeightOf(w) ((w)->editable.widget.allocation.height)
# define CWidthOf(w) ((w)->editable.widget.allocation.width)
# define COptionsOf(w) ((w)->options)
# define cache_type unsigned int
/* font dimensions */
# define FONT_OVERHEAD gtk_edit_option_text_line_spacing
# define FONT_BASE_LINE (FONT_OVERHEAD + gtk_edit_option_font_ascent)
# define FONT_HEIGHT (gtk_edit_option_font_ascent + gtk_edit_option_font_descent)
# define FONT_PIX_PER_LINE (FONT_OVERHEAD + FONT_HEIGHT)
# define FONT_MEAN_WIDTH gtk_edit_option_font_mean_width
# define EDIT_FRAME_H 3
# define EDIT_FRAME_W 3
1998-09-15 00:18:54 +04:00
# define FONT_OFFSET_X 0
# define FONT_OFFSET_Y FONT_BASE_LINE
# define FONT_PER_CHAR gtk_edit_font_width_per_char
1998-09-15 00:18:54 +04:00
# ifndef _GTK_EDIT_C
extern guchar gtk_edit_font_width_per_char[256];
extern int gtk_edit_option_text_line_spacing;
extern int gtk_edit_option_font_ascent;
extern int gtk_edit_option_font_descent;
extern int gtk_edit_option_font_mean_width;
extern int gtk_edit_fixed_font;
# endif
/* start temporary */
# define COLOR_BLACK 0
# define COLOR_WHITE 1
# define CURSOR_TYPE_EDITOR 0
# define WIN_MESSAGES GTK_WINDOW_TOPLEVEL, 20, 20
# define option_text_line_spacing 1
# define fixed_font 0
#define color_palette(x) win->color[x].pixel
#define DndNotDnd -1
#define DndUnknown 0
#define DndRawData 1
#define DndFile 2
#define DndFiles 3
#define DndText 4
#define DndDir 5
#define DndLink 6
#define DndExe 7
#define DndURL 8
#define DndMIME 9
#define DndEND 10
#define dnd_null_term_type(d) \
((d) == DndFile || (d) == DndText || (d) == DndDir || \
(d) == DndLink || (d) == DndExe || (d) == DndURL)
/* end temporary */
# else
1998-09-18 18:22:49 +04:00
# define WIN_MESSAGES edit->widget ? edit->widget->mainid : CRoot, 20, 20
1998-09-15 00:18:54 +04:00
# endif
# define MY_O_TEXT 0
# ifdef GTK
# ifndef min
# define min(x,y) (((x) < (y)) ? (x) : (y))
# endif
# ifndef max
# define max(x,y) (((x) > (y)) ? (x) : (y))
# endif
/*
extern Display *gdk_display;
extern Window gdk_root_window;
*/
enum {
match_file, match_normal
};
# define edit_get_load_file(d,f,h) gtk_edit_dialog_get_load_file(d,f,h)
# define edit_get_save_file(d,f,h) gtk_edit_dialog_get_save_file(d,f,h)
# define edit_error_dialog(h,t) gtk_edit_dialog_error(h,"%s",t)
# define edit_message_dialog(h,t) gtk_edit_dialog_message(0,h,"%s",t)
# define edit_query_dialog2(h,t,a,b) gtk_edit_dialog_query(h,t,a,b,0)
# define edit_query_dialog3(h,t,a,b,c) gtk_edit_dialog_query(h,t,a,b,c,0)
# define edit_query_dialog4(h,t,a,b,c,d) gtk_edit_dialog_query(h,t,a,b,c,d,0)
# define CError(x) printf("Error: %s\n",x)
# define CIsDropAcknowledge(a,b) DndNotDnd
# define CGetDrop(e,d,s,x,y) DndNotDnd
# define CDropAcknowledge(x)
/* # define edit_get_syntax_color(e,i,f,b) */
# define get_international_character(k) 0
# define compose_key_pressed 0
# else
# define edit_get_load_file(d,f,h) CGetLoadFile(WIN_MESSAGES,d,f,h)
# define edit_get_save_file(d,f,h) CGetSaveFile(WIN_MESSAGES,d,f,h)
# define edit_error_dialog(h,t) CErrorDialog(WIN_MESSAGES,h,"%s",t)
# define edit_message_dialog(h,t) CMessageDialog(WIN_MESSAGES,0,h,"%s",t)
# define edit_query_dialog2(h,t,a,b) CQueryDialog(WIN_MESSAGES,h,t,a,b,0)
# define edit_query_dialog3(h,t,a,b,c) CQueryDialog(WIN_MESSAGES,h,t,a,b,c,0)
# define edit_query_dialog4(h,t,a,b,c,d) CQueryDialog(WIN_MESSAGES,h,t,a,b,c,d,0)
# endif
#endif /* ! MIDNIGHT */
extern char *home_dir;
#define NUM_SELECTION_HISTORY 64
1998-09-15 00:18:54 +04:00
1998-09-16 03:17:12 +04:00
#ifndef MAX_PATH_LEN
#ifdef PATH_MAX
#define MAX_PATH_LEN PATH_MAX
#else
#define MAX_PATH_LEN 1024
#endif
#endif
1998-09-15 00:18:54 +04:00
#ifdef _EDIT_C
struct selection selection =
{0, 0};
int current_selection = 0;
/* Note: selection.text = selection_history[current_selection].text */
struct selection selection_history[NUM_SELECTION_HISTORY] =
{
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
};
#ifdef MIDNIGHT
/*
what editor are we going to emulate? one of EDIT_KEY_EMULATION_NORMAL
or EDIT_KEY_EMULATION_EMACS
*/
int edit_key_emulation = EDIT_KEY_EMULATION_NORMAL;
#endif /* ! MIDNIGHT */
int option_word_wrap_line_length = 72;
int option_typewriter_wrap = 0;
int option_auto_para_formatting = 0;
int option_international_characters = 0;
int option_tab_spacing = 8;
int option_fill_tabs_with_spaces = 0;
int option_return_does_auto_indent = 1;
int option_backspace_through_tabs = 0;
int option_fake_half_tabs = 1;
int option_save_mode = 0;
int option_backup_ext_int = -1;
int option_find_bracket = 1;
int option_max_undo = 32768;
int option_editor_fg_normal = 26;
int option_editor_fg_bold = 8;
int option_editor_fg_italic = 10;
int option_edit_right_extreme = 0;
int option_edit_left_extreme = 0;
int option_edit_top_extreme = 0;
int option_edit_bottom_extreme = 0;
int option_editor_bg_normal = 1;
int option_editor_bg_abnormal = 0;
int option_editor_bg_marked = 2;
int option_editor_bg_marked_abnormal = 9;
int option_editor_bg_highlighted = 12;
int option_editor_fg_cursor = 18;
char *option_whole_chars_search = "0123456789abcdefghijklmnopqrstuvwxyz_";
char *option_chars_move_whole_word = "!=&|<>^~ !:;, !'!`!.?!\"!( !) !Aa0 !+-*/= |<> ![ !] !\\#! ";
1998-09-15 00:18:54 +04:00
char *option_backup_ext = "~";
#else /* ! _EDIT_C */
extern struct selection selection;
extern struct selection selection_history[];
extern int current_selection;
#ifdef MIDNIGHT
/*
what editor are we going to emulate? one of EDIT_KEY_EMULATION_NORMAL
or EDIT_KEY_EMULATION_EMACS
*/
extern int edit_key_emulation;
#endif /* ! MIDNIGHT */
extern int option_word_wrap_line_length;
extern int option_typewriter_wrap;
extern int option_auto_para_formatting;
extern int option_international_characters;
extern int option_tab_spacing;
extern int option_fill_tabs_with_spaces;
extern int option_return_does_auto_indent;
extern int option_backspace_through_tabs;
extern int option_fake_half_tabs;
extern int option_save_mode;
extern int option_backup_ext_int;
extern int option_find_bracket;
extern int option_max_undo;
extern int option_editor_fg_normal;
extern int option_editor_fg_bold;
extern int option_editor_fg_italic;
extern int option_edit_right_extreme;
extern int option_edit_left_extreme;
extern int option_edit_top_extreme;
extern int option_edit_bottom_extreme;
extern int option_editor_bg_normal;
extern int option_editor_bg_abnormal;
extern int option_editor_bg_marked;
extern int option_editor_bg_marked_abnormal;
extern int option_editor_bg_highlighted;
extern int option_editor_fg_cursor;
extern char *option_whole_chars_search;
extern char *option_chars_move_whole_word;
1998-09-15 00:18:54 +04:00
extern char *option_backup_ext;
extern int edit_confirm_save;
#endif /* ! _EDIT_C */
#endif /* __EDIT_H */