2001-08-24 22:23:17 +04:00
|
|
|
/* editor options dialog box
|
|
|
|
|
2007-09-25 19:33:35 +04:00
|
|
|
Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2007
|
|
|
|
Free Software Foundation, Inc.
|
2001-08-24 22:23:17 +04:00
|
|
|
|
|
|
|
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
|
2005-05-27 07:35:10 +04:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
02110-1301, USA.
|
2001-08-24 22:23:17 +04:00
|
|
|
*/
|
|
|
|
|
2009-02-07 00:09:50 +03:00
|
|
|
/** \file
|
|
|
|
* \brief Source: editor options dialog box
|
|
|
|
* \author Paul Sheer
|
|
|
|
* \date 1996, 1997
|
|
|
|
*/
|
|
|
|
|
2001-08-24 22:23:17 +04:00
|
|
|
#include <config.h>
|
2005-02-22 20:00:36 +03:00
|
|
|
|
2009-02-27 12:30:11 +03:00
|
|
|
#include <stdlib.h> /* atoi(), NULL */
|
2009-01-30 21:28:35 +03:00
|
|
|
|
2005-02-22 20:00:36 +03:00
|
|
|
#include "../src/global.h"
|
|
|
|
|
2009-06-14 19:18:27 +04:00
|
|
|
#include "edit-impl.h"
|
2005-07-20 15:56:30 +04:00
|
|
|
#include "usermap.h"
|
2003-10-29 11:54:22 +03:00
|
|
|
#include "../src/dialog.h" /* B_CANCEL */
|
|
|
|
#include "../src/wtools.h" /* QuickDialog */
|
2001-08-24 22:23:17 +04:00
|
|
|
|
2009-07-01 20:18:20 +04:00
|
|
|
#define OPT_DLG_H 21
|
2001-08-24 22:23:17 +04:00
|
|
|
#define OPT_DLG_W 72
|
|
|
|
|
2004-08-29 22:45:56 +04:00
|
|
|
static const char *key_emu_str[] =
|
2009-07-30 13:59:29 +04:00
|
|
|
{
|
|
|
|
N_("Intuitive"),
|
|
|
|
N_("Emacs"),
|
|
|
|
N_("User-defined"),
|
|
|
|
NULL
|
|
|
|
};
|
2001-08-24 22:23:17 +04:00
|
|
|
|
2004-08-29 22:45:56 +04:00
|
|
|
static const char *wrap_str[] =
|
2009-07-30 13:59:29 +04:00
|
|
|
{
|
|
|
|
N_("None"),
|
|
|
|
N_("Dynamic paragraphing"),
|
|
|
|
N_("Type writer wrap"),
|
|
|
|
NULL
|
|
|
|
};
|
2001-08-24 22:23:17 +04:00
|
|
|
|
2002-11-13 07:32:00 +03:00
|
|
|
static void
|
2004-08-29 22:45:56 +04:00
|
|
|
i18n_translate_array (const char *array[])
|
2001-08-24 22:23:17 +04:00
|
|
|
{
|
2009-07-30 13:59:29 +04:00
|
|
|
while (*array != NULL) {
|
2001-08-24 22:23:17 +04:00
|
|
|
*array = _(*array);
|
|
|
|
array++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-30 03:41:47 +03:00
|
|
|
void
|
|
|
|
edit_options_dialog (void)
|
2001-08-24 22:23:17 +04:00
|
|
|
{
|
2009-07-30 13:59:29 +04:00
|
|
|
char wrap_length[16], tab_spacing[16], *p, *q;
|
2001-08-24 22:23:17 +04:00
|
|
|
int wrap_mode = 0;
|
2002-11-30 03:41:47 +03:00
|
|
|
int old_syntax_hl;
|
2001-08-24 22:23:17 +04:00
|
|
|
int tedit_key_emulation = edit_key_emulation;
|
2009-07-30 13:59:29 +04:00
|
|
|
|
|
|
|
QuickWidget quick_widgets[] =
|
|
|
|
{
|
|
|
|
/* 0 */ QUICK_BUTTON (6, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&Cancel"), B_CANCEL, NULL),
|
|
|
|
/* 1 */ QUICK_BUTTON (2, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&OK"), B_ENTER, NULL),
|
|
|
|
/* 2 */ QUICK_LABEL (OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H, N_("Word wrap line length: ")),
|
|
|
|
/* 3 */ QUICK_INPUT (OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H,
|
|
|
|
wrap_length, OPT_DLG_W / 2 - 4 - 24, 0, "edit-word-wrap", &p),
|
|
|
|
/* 4 */ QUICK_LABEL (OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, N_("Tab spacing: ")),
|
|
|
|
/* 5 */ QUICK_INPUT (OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H,
|
|
|
|
tab_spacing, OPT_DLG_W / 2 - 4 - 24, 0, "edit-tab-spacing", &q),
|
|
|
|
/* 6 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 8, OPT_DLG_H,
|
2009-09-02 09:59:19 +04:00
|
|
|
N_("Cursor beyond end of line"), &option_cursor_beyond_eol),
|
2009-07-30 13:59:29 +04:00
|
|
|
/* 7 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 9, OPT_DLG_H,
|
|
|
|
N_("Pers&istent selection"), &option_persistent_selections),
|
|
|
|
/* 8 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 10, OPT_DLG_H,
|
|
|
|
N_("Synta&x highlighting"), &option_syntax_highlighting),
|
|
|
|
/* 9 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 11, OPT_DLG_H,
|
|
|
|
N_("Visible tabs"), &visible_tabs),
|
|
|
|
/* 10 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H,
|
|
|
|
N_("Visible trailing spaces"), &visible_tws),
|
|
|
|
/* 11 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 13, OPT_DLG_H,
|
|
|
|
N_("Save file &position"), &option_save_position),
|
|
|
|
/* 12 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 14, OPT_DLG_H,
|
|
|
|
N_("Confir&m before saving"), &edit_confirm_save),
|
|
|
|
/* 13 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 15, OPT_DLG_H,
|
|
|
|
N_("Fill tabs with &spaces"), &option_fill_tabs_with_spaces),
|
|
|
|
/* 14 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 16, OPT_DLG_H,
|
|
|
|
N_("&Return does autoindent"), &option_return_does_auto_indent),
|
|
|
|
/* 15 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 17, OPT_DLG_H,
|
|
|
|
N_("&Backspace through tabs"), &option_backspace_through_tabs),
|
|
|
|
/* 16 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 18, OPT_DLG_H,
|
|
|
|
N_("&Fake half tabs"), &option_fake_half_tabs),
|
|
|
|
/* 17 */ QUICK_RADIO (5, OPT_DLG_W, OPT_DLG_H - 11, OPT_DLG_H, 3, wrap_str, &wrap_mode),
|
|
|
|
/* 18 */ QUICK_LABEL (4, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H, N_("Wrap mode")),
|
|
|
|
/* 19 */ QUICK_RADIO (5, OPT_DLG_W, OPT_DLG_H - 17, OPT_DLG_H, 3, key_emu_str, &tedit_key_emulation),
|
|
|
|
/* 10 */ QUICK_LABEL (4, OPT_DLG_W, OPT_DLG_H - 18, OPT_DLG_H, N_("Key emulation")),
|
|
|
|
QUICK_END
|
2002-11-30 03:41:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
QuickDialog Quick_options =
|
2009-07-30 13:59:29 +04:00
|
|
|
{
|
|
|
|
OPT_DLG_W, OPT_DLG_H, -1, -1, N_(" Editor options "),
|
2009-09-02 09:59:19 +04:00
|
|
|
"[Editor options]", quick_widgets, FALSE
|
2009-07-30 13:59:29 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
static gboolean i18n_flag = FALSE;
|
2001-08-24 22:23:17 +04:00
|
|
|
|
|
|
|
if (!i18n_flag) {
|
|
|
|
i18n_translate_array (key_emu_str);
|
|
|
|
i18n_translate_array (wrap_str);
|
2009-07-30 13:59:29 +04:00
|
|
|
i18n_flag = TRUE;
|
2001-08-24 22:23:17 +04:00
|
|
|
}
|
2009-07-30 13:59:29 +04:00
|
|
|
#endif
|
2001-08-24 22:23:17 +04:00
|
|
|
|
2009-02-06 01:49:00 +03:00
|
|
|
g_snprintf (wrap_length, sizeof (wrap_length), "%d",
|
2002-11-23 20:26:55 +03:00
|
|
|
option_word_wrap_line_length);
|
2009-02-06 01:49:00 +03:00
|
|
|
g_snprintf (tab_spacing, sizeof (tab_spacing), "%d",
|
2002-11-30 03:41:47 +03:00
|
|
|
option_tab_spacing);
|
2001-08-24 22:23:17 +04:00
|
|
|
|
|
|
|
if (option_auto_para_formatting)
|
|
|
|
wrap_mode = 1;
|
|
|
|
else if (option_typewriter_wrap)
|
|
|
|
wrap_mode = 2;
|
|
|
|
else
|
|
|
|
wrap_mode = 0;
|
|
|
|
|
2002-11-30 03:41:47 +03:00
|
|
|
if (quick_dialog (&Quick_options) == B_CANCEL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
old_syntax_hl = option_syntax_highlighting;
|
|
|
|
|
|
|
|
if (p) {
|
|
|
|
option_word_wrap_line_length = atoi (p);
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (p);
|
2002-11-30 03:41:47 +03:00
|
|
|
}
|
|
|
|
if (q) {
|
|
|
|
option_tab_spacing = atoi (q);
|
|
|
|
if (option_tab_spacing <= 0)
|
|
|
|
option_tab_spacing = 8;
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (q);
|
2002-11-30 03:41:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (wrap_mode == 1) {
|
|
|
|
option_auto_para_formatting = 1;
|
|
|
|
option_typewriter_wrap = 0;
|
|
|
|
} else if (wrap_mode == 2) {
|
|
|
|
option_auto_para_formatting = 0;
|
|
|
|
option_typewriter_wrap = 1;
|
|
|
|
} else {
|
|
|
|
option_auto_para_formatting = 0;
|
|
|
|
option_typewriter_wrap = 0;
|
2001-08-24 22:23:17 +04:00
|
|
|
}
|
|
|
|
|
2005-05-21 01:19:40 +04:00
|
|
|
/* Reload menu if key emulation has changed */
|
|
|
|
if (edit_key_emulation != tedit_key_emulation) {
|
|
|
|
edit_key_emulation = tedit_key_emulation;
|
|
|
|
edit_reload_menu ();
|
|
|
|
}
|
2002-11-30 03:41:47 +03:00
|
|
|
|
|
|
|
/* Load or unload syntax rules if the option has changed */
|
|
|
|
if (option_syntax_highlighting != old_syntax_hl)
|
2009-07-01 20:18:20 +04:00
|
|
|
edit_load_syntax (wedit, NULL, option_syntax_type);
|
2005-07-20 15:56:30 +04:00
|
|
|
/* Load usermap if it's needed */
|
|
|
|
edit_load_user_map (wedit);
|
2002-11-30 03:41:47 +03:00
|
|
|
}
|