+1999-12-01 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/support/filetools.C (ExpandPath): removed an over eager
+ Assert.
+ (ReplaceEnvironmentPath): ditto
+
+ * src/toolbar.C (BubbleTimerCB): use C++ style casts. This clearly
+ shows that we are doing something fishy in our code...
+ (BubblePost): ditto
+ (ToolbarCB): ditto
+
+ * src/lyxrc.C (read): use a double switch trick to get more help
+ from the compiler. (the same trick is used in layout.C)
+ (write): new function. opens a ofstream and pass that to output
+ (output): new function, takes a ostream and writes the lyxrc
+ elemts to it. uses a dummy switch to make sure no elements are
+ forgotten.
+
+ * src/lyxlex.h: added a struct pushpophelper for use in functions
+ with more than one exit point.
+
+ * src/lyxlex.[Ch] (GetInteger): made it const
+ (GetFloat): ditto
+ (GetBool): ditto
+
+ * src/lyxfunc.C (Dispatch): added case for LFUN_SAVEPREFERENCES
+
+ * src/layout.[hC] : LayoutTags splitted into several enums, new
+ methods created, better error handling cleaner use of lyxlex. Read
+ the diff.
+
+ * src/bmtable.[Ch]: change some member prototypes because of the
+ image const changes.
+
+ * commandtags.h, src/LyXAction.C (init): new function:
+ "preferences-save", saves the lyxrc entries into .lyx/preferences.
+ This file is not read automatically but you can add \input
+ preferences to your lyxrc if you want to. We need to discuss how
+ to handle this.
+
+ * src/LaTeX.C (runBibTeX): use regex to match for the needed lines
+ in .aux, also remove .bib and .bst files from dependencies when
+ running bibtex.
+
+ * src/BufferView.C, src/LyXView.C: add const_cast several places
+ because of changes to images.
+
+ * lib/images/*: same change as for images/*
+
+ * lib/lyxrc.example: Default for accept_compound is false not no.
+
+ * images/*: changed to be const, however I have som misgivings
+ about this change so it might be changed back.
+
1999-11-26 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* lib/configure, po/POTFILES.in: regenerated
#define arrow_width 185
#define arrow_height 143
-static unsigned char arrow_bits[] = {
+static unsigned char const arrow_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe};
#define darrow_width 73
#define darrow_height 73
-static unsigned char darrow_bits[] = {
+static unsigned char const darrow_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe};
#define larrow_width 103
#define larrow_height 126
-static unsigned char larrow_bits[] = {
+static unsigned char const larrow_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
/* XPM */
-static char *banner[] = {
+static char const * banner[] = {
/* width height num_colors chars_per_pixel */
" 424 289 16 1",
/* colors */
#define banner_bw_width 424
#define banner_bw_height 289
-static unsigned char banner_bw_bits[] = {
+static unsigned char const banner_bw_bits[] = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
/* XPM */
-static char * bold_xpm[] = {
+static char const * bold_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
#define bop_width 118
#define bop_height 259
-static unsigned char bop_bits[] = {
+static unsigned char const bop_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
#define brel_width 123
#define brel_height 291
-static unsigned char brel_bits[] = {
+static unsigned char const brel_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* XPM */
-static char *build_xpm[] = {
+static char const * build_xpm[] = {
"20 20 4 1",
". c black",
" c #BFBFBFBFBFBF",
/* XPM */
-static char * close_xpm[] = {
+static char const * close_xpm[] = {
"20 20 5 1",
" c #BFBFBFBFBFBF",
". c #7B7B00000000",
/* XPM */
-static char * close_xpm[] = {
+static char const * close_xpm[] = {
/* width height num_colors chars_per_pixel */
"20 20 2 1",
/* colors */
/* XPM */
-static char * copy_xpm[] = {
+static char const * copy_xpm[] = {
"20 20 5 1",
" c #000000000000",
". c #BFBFBFBFBFBF",
/* XPM */
-static char * copy_xpm[] = {
+static char const * copy_xpm[] = {
"20 20 5 1",
" c black",
". c #BFBFBFBFBFBF",
/* XPM */
-static char * cut_xpm[] = {
+static char const * cut_xpm[] = {
"20 20 3 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * cut_xpm[] = {
+static char const * cut_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
#define deco_width 137
#define deco_height 90
-static unsigned char deco_bits[] = {
+static unsigned char const deco_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
/* XPM */
-static char * deco[] = {
+static char const * deco[] = {
"20 20 3 1",
" c #BEFBBEFBBEFB",
". c #000000000000",
#define delim_width 164
#define delim_height 136
-static unsigned char delim_bits[] = {
+static unsigned char const delim_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* XPM */
-static char *delim[] = {
+static char const * delim[] = {
/* width height num_colors chars_per_pixel */
" 20 20 3 1",
/* colors */
/* XPM */
-static char *delim0[] = {
+static char const * delim0[] = {
/* width height num_colors chars_per_pixel */
" 31 31 2 1",
/* colors */
"###############################",
"###############################",
"###############################",
-"#######a#######################",
-"######a#############aa#########",
+"#######a###########a###########",
+"######a#############a##########",
"#####a###############a#########",
"#####a################a########",
"####a##################a#######",
/* XPM */
-static char * depth_xpm[] = {
+static char const * depth_xpm[] = {
"20 20 5 1",
" c gray60",
". c #000000000000",
/* XPM */
-static char * depth_xpm[] = {
+static char const * depth_xpm[] = {
"20 20 3 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
#define dots_width 72
#define dots_height 18
-static unsigned char dots_bits[] = {
+static unsigned char const dots_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* XPM */
-static char *down_xpm[] = {
+static char const * down_xpm[] = {
/* width height num_colors chars_per_pixel */
" 11 11 4 1",
/* colors */
/* XPM */
-static char * emph_xpm[] = {
+static char const * emph_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * emph_xpm[] = {
+static char const * emph_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char *equation[] = {
+static char const * equation[] = {
/* width height num_colors chars_per_pixel */
" 20 20 3 1",
/* colors */
/* XPM */
-static char * fig_xpm[] = {
+static char const * fig_xpm[] = {
"20 20 4 1",
" c #000000000000",
". c #FFFFFFFFFFFF",
/* XPM */
-static char * fig_xpm[] = {
+static char const * fig_xpm[] = {
/* width height num_colors chars_per_pixel */
"20 20 2 1",
/* colors */
/* XPM */
-static char * foot_xpm[] = {
+static char const * foot_xpm[] = {
"20 20 4 1",
" c gray60",
". c #000000000000",
/* XPM */
-static char *frac[] = {
+static char const * frac[] = {
/* width height num_colors chars_per_pixel */
" 20 20 3 1",
/* colors */
/* XPM */
-static char * free_xpm[] = {
+static char const * free_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * free_xpm[] = {
+static char const * free_xpm[] = {
/* width height num_colors chars_per_pixel */
"20 20 2 1",
/* colors */
#define Greek_width 182
#define Greek_height 60
-static unsigned char Greek_bits[] = {
+static unsigned char const Greek_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* XPM */
-static char * layout_code_xpm[] = {
+static char const * layout_code_xpm[] = {
"20 20 4 1",
" c gray50",
". c black",
/* XPM */
-static char * layout_latex_xpm[] = {
+static char const * layout_latex_xpm[] = {
"20 20 4 1",
" c gray60",
". c #000000000000",
/* XPM */
-static char *layout_scrap_xpm[] = {
+static char const * layout_scrap_xpm[] = {
" 20 20 3 1",
". c gray30",
" c #BFBFBFBFBFBF",
/* XPM */
-static char * layout_sec_xpm[] = {
+static char const * layout_sec_xpm[] = {
"20 20 4 1",
" c gray60",
". c #000000000000",
/* XPM */
-static char * layout_std_xpm[] = {
+static char const * layout_std_xpm[] = {
"20 20 3 1",
" c gray50",
". c #000000000000",
/* XPM */
-static char *lyx_xpm[] = {
+static char const * lyx_xpm[] = {
/* width height num_colors chars_per_pixel */
" 48 48 7 1",
/* colors */
/* XPM */
-static char * make_ascii_xpm[] = {
+static char const * make_ascii_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c black",
/* XPM */
-static char * make_latex_xpm[] = {
+static char const * make_latex_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c black",
/* XPM */
-static char * margin_xpm[] = {
+static char const * margin_xpm[] = {
"20 20 5 1",
" c gray60",
". c #000000000000",
/* XPM */
-static char * margin_xpm[] = {
+static char const * margin_xpm[] = {
/* width height num_colors chars_per_pixel */
"20 20 2 1",
/* colors */
/* XPM */
-static char * math_xpm[] = {
+static char const * math_xpm[] = {
"20 20 4 1",
" c #BFBFBFBFBFBF",
". c #242423238E8E",
/* XPM */
-static char * math_xpm[] = {
+static char const * math_xpm[] = {
/**/
"20 20 2 1",
/*33333333333*/
/* XPM */
-static char *matrix[] = {
+static char const * matrix[] = {
/* width height num_colors chars_per_pixel */
" 20 20 2 1",
/* colors */
/* XPM */
-static char * melt_xpm[] = {
+static char const * melt_xpm[] = {
"20 20 5 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * melt_xpm[] = {
+static char const * melt_xpm[] = {
/**/
"20 20 2 1",
/*33333333333*/
#define misc_width 150
#define misc_height 193
-static unsigned char misc_bits[] = {
+static unsigned char const misc_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* XPM */
-static char * noun_xpm[] = {
+static char const * noun_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * noun_xpm[] = {
+static char const * noun_xpm[] = {
/**/
"20 20 2 1",
/*÷F¼\ 4÷FÃd÷FÄD÷FÆôges/delim.xbm*/
/* XPM */
-static char * open_xpm[] = {
+static char const * open_xpm[] = {
"20 20 5 1",
" c #BFBFBFBFBFBF",
". c navy",
/* XPM */
-static char * open_xpm[] = {
+static char const * open_xpm[] = {
/* width height num_colors chars_per_pixel */
"20 20 2 1",
/* colors */
/* XPM */
-static char * paste_xpm[] = {
+static char const * paste_xpm[] = {
"20 20 6 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * paste_xpm[] = {
+static char const * paste_xpm[] = {
/* width height num_colors chars_per_pixel */
"20 20 2 1",
/* colors */
/* XPM */
-static char * print1_xpm[] = {
+static char const * print1_xpm[] = {
"24 20 7 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * print1_xpm[] = {
+static char const * print1_xpm[] = {
/* width height num_colors chars_per_pixel */
"24 20 2 1",
/* colors */
/* XPM */
-static char *quit_xpm[] = {
+static char const * quit_xpm[] = {
/* width height num_colors chars_per_pixel */
" 20 20 7 1",
/* colors */
/* XPM */
-static char * quit_xpm[] = {
+static char const * quit_xpm[] = {
/* width height num_colors chars_per_pixel */
"20 20 2 1",
/* colors */
/* XPM */
-static char * run_latex_xpm[] = {
+static char const * run_latex_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * sans_xpm[] = {
+static char const * sans_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * save_xpm[] = {
+static char const * save_xpm[] = {
"20 20 5 1",
" c #BFBFBFBFBFBF",
". c black",
/* XPM */
-static char * save_xpm[] = {
+static char const * save_xpm[] = {
/*\80\10*/
"20 20 2 1",
/**/
/* XPM */
-static char * smallcaps_xpm[] = {
+static char const * smallcaps_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * smallcaps_xpm[] = {
+static char const * smallcaps_xpm[] = {
/**/
"20 20 2 1",
/**/
/* XPM */
-static char * space_xpm[] = {
+static char const * space_xpm[] = {
"20 20 2 1",
" c #BEFBBEFBBEFB",
". c #FBEE14514103",
/* XPM */
-static char *sqrt[] = {
+static char const * sqrt[] = {
/* width height num_colors chars_per_pixel */
" 20 20 3 1",
/* colors */
/* XPM */
-static char * tab_xpm[] = {
+static char const * tab_xpm[] = {
"20 20 3 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * tab_xpm[] = {
+static char const * tab_xpm[] = {
/*.e:*/
"20 20 2 1",
/**/
/* XPM */
-static char * tex_xpm[] = {
+static char const * tex_xpm[] = {
"20 20 2 1",
" c #BEFBBEFBBEFB",
". c #7B7B00000000",
/* XPM */
-static char * tex_xpm[] = {
+static char const * tex_xpm[] = {
/*.e:*/
"20 20 2 1",
/**/
/* XPM */
-static char * update_ps_xpm[] = {
+static char const * update_ps_xpm[] = {
"20 20 3 1",
" c #BFBFBFBFBFBF",
".c navy",
/* XPM */
-static char * update_ps_xpm[] = {
+static char const * update_ps_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c black",
/* XPM */
-static char *unknown_xpm[] = {
+static char const * unknown_xpm[] = {
/* width height num_colors chars_per_pixel */
" 20 20 2 1",
/* colors */
/* XPM */
-static char * unknown_xpm[] = {
+static char const * unknown_xpm[] = {
/* width height num_colors chars_per_pixel */
"20 20 2 1",
/**/
/* XPM */
-static char *up_xpm[] = {
+static char const * up_xpm[] = {
/* width height num_colors chars_per_pixel */
" 11 11 4 1",
/* colors */
#define varsz_width 110
#define varsz_height 192
-static unsigned char varsz_bits[] = {
+static unsigned char const varsz_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,
/* XPM */
-static char * view_dvi_xpm[] = {
+static char const * view_dvi_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
/* XPM */
-static char * view_ps_xpm[] = {
+static char const * view_ps_xpm[] = {
"20 20 2 1",
" c #BFBFBFBFBFBF",
". c #000000000000",
#define amssymb_width 264
#define amssymb_height 174
-static char amssymb_bits[] = {
+static char const amssymb_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* XPM */
-static char *amssymb[] = {
+static char const * amssymb[] = {
/* width height num_colors chars_per_pixel */
" 264 174 16 1",
/* colors */
#define psnfss1_width 264
#define psnfss1_height 174
-static char psnfss1_bits[] = {
+static char const psnfss1_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* XPM */
-static char *psnfss1[] = {
+static char const * psnfss1[] = {
/* width height num_colors chars_per_pixel */
" 264 174 16 1",
/* colors */
#define psnfss2_width 264
#define psnfss2_height 174
-static char psnfss2_bits[] = {
+static char const psnfss2_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* XPM */
-static char *psnfss2[] = {
+static char const * psnfss2[] = {
/* width height num_colors chars_per_pixel */
" 264 174 16 1",
/* colors */
#define psnfss3_width 264
#define psnfss3_height 174
-static char psnfss3_bits[] = {
+static char const psnfss3_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* XPM */
-static char *psnfss3[] = {
+static char const * psnfss3[] = {
/* width height num_colors chars_per_pixel */
" 264 174 16 1",
/* colors */
#define psnfss4_width 264
#define psnfss4_height 174
-static char psnfss4_bits[] = {
+static char const psnfss4_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* XPM */
-static char *psnfss4[] = {
+static char const * psnfss4[] = {
/* width height num_colors chars_per_pixel */
" 264 174 16 1",
/* colors */
#define standard_width 264
#define standard_height 174
-static char standard_bits[] = {
+static char const standard_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* XPM */
-static char *standard[] = {
+static char const * standard[] = {
/* width height num_colors chars_per_pixel */
" 264 174 16 1",
/* colors */
#\spell_command aspell
# Consider run-together words, such as "notthe" for "not the", as legal
-# words? Default is no.
+# words? Default is false.
#\accept_compound true
# Specify an alternate language. The default is to use the language of
fl_set_object_gravity(obj, NorthEastGravity, NorthEastGravity);
fl_set_object_callback(obj, C_BufferView_UpCB, 0);
obj->u_vdata = this;
- fl_set_pixmapbutton_data(obj, up_xpm);
+ fl_set_pixmapbutton_data(obj, const_cast<char**>(up_xpm));
#if FL_REVISION > 85
// Remove the blue feedback rectangle
fl_set_object_gravity(obj, SouthEastGravity, SouthEastGravity);
fl_set_object_callback(obj, C_BufferView_DownCB, 0);
obj->u_vdata = this;
- fl_set_pixmapbutton_data(obj, down_xpm);
+ fl_set_pixmapbutton_data(obj, const_cast<char**>(down_xpm));
fl_set_border_width(-bw);
#if FL_REVISION >85
ifstream ifs(file.c_str());
string token;
bool using_bibtex = false;
+ LRegex reg1("\\\\bibdata{([^}]+)}");
+ LRegex reg2("\\\\bibstyle{([^}]+)}");
while (getline(ifs, token)) {
- if (contains(token, "\\bibdata{")) {
+ if (reg1.exact_match(token)) {
using_bibtex = true;
- string::size_type a = token.find("\\bibdata{") + 9;
- string::size_type b = token.find_first_of("}", a);
- string data = token.substr(a, b - a);
+ LRegex::SubMatches const & sub = reg1.exec(token);
+ string data = LSubstring(token, sub[1].first,
+ sub[2].second);
// data is now all the bib files separated by ','
// get them one by one and pass them to the helper
+ string::size_type b;
do {
b = data.find_first_of(',', 0);
string l;
findtexfile(
ChangeExtension(l, "bib", false),
"bib");
- lyxerr << "data = `"
- << full_l << "'" << endl;
+ lyxerr[Debug::LATEX] << "Bibtex database: `"
+ << full_l << "'" << endl;
if (!full_l.empty()) {
// add full_l to the dep file.
dep.insert(full_l, true);
}
} while (b != string::npos);
- } else if (contains(token, "\\bibstyle{")) {
+ } else if (reg2.exact_match(token)) {
using_bibtex = true;
- string::size_type a = token.find("\\bibstyle{") + 10;
- string::size_type b = token.find_first_of("}", a);
- string style = token.substr(a, b - a);
+ LRegex::SubMatches const & sub = reg2.exec(token);
+ string style = LSubstring(token, sub[1].first,
+ sub[1].second);
// token is now the style file
// pass it to the helper
string full_l =
findtexfile(
ChangeExtension(style, "bst", false),
"bst");
- lyxerr << "style = `"
- << full_l << "'" << endl;
+ lyxerr[Debug::LATEX] << "Bibtex style: `"
+ << full_l << "'" << endl;
if (!full_l.empty()) {
// add full_l to the dep file.
dep.insert(full_l, true);
_("Export to"), ReadOnly);
newFunc(LFUN_FAX,"buffer-fax",
_("Fax"), ReadOnly);
- //newFunc(LFUN_INSERTFLOAT,"float-insert",
- // "", Noop);
newFunc(LFUN_INSERTFOOTNOTE, "buffer-float-insert", "", Noop);
newFunc(LFUN_IMPORT,"buffer-import",
_("Import document"), NoBuffer);
_("Open"), NoBuffer);
newFunc(LFUN_PREVBUFFER,"buffer-previous",
_("Switch to previous document"), ReadOnly);
- //newFunc(LFUN_SWITCHBUFFER,"buffer-switch",
- // _("Switch to an open document"), ReadOnly);
newFunc(LFUN_MENUPRINT,"buffer-print",
_("Print"), ReadOnly);
newFunc(LFUN_MENURELOAD,"buffer-reload",
"", Noop);
newFunc(LFUN_MATH_MODE,"math-mode",
_("Math mode"), Noop);
- //newFunc(LFUN_MATH_PANEL,"math-panel",
- // _("Math panel"), Noop);
newFunc(LFUN_MATH_NONUMBER,"math-nonumber",
"", Noop);
newFunc(LFUN_MATH_NUMBER,"math-number",
_("Select previous paragraph"), ReadOnly);
newFunc(LFUN_PARENTINSERT,"parent-insert",
"", Noop);
- newFunc( LFUN_PASTE,"paste",
+ newFunc(LFUN_PASTE,"paste",
_("Paste") , Noop);
+ newFunc(LFUN_SAVEPREFERENCES, "preferences-save",
+ "Save Preferences", NoBuffer);
newFunc(LFUN_PASTESELECTION,"primary-selection-paste",
"", Noop);
newFunc(LFUN_PROTECTEDSPACE,"protected-space-insert",
unsigned int w, h;
Pixmap lyx_p, lyx_mask;
lyx_p = fl_create_from_pixmapdata(fl_root,
- lyx_xpm,
+ const_cast<char**>(lyx_xpm),
&w,
&h,
&lyx_mask,
*
* The user could change these later. See below.
*/
-void fl_set_bmtable_data(FL_OBJECT *ob, int nx, int ny, int bw, int bh,
- unsigned char * bdata)
+void fl_set_bmtable_data(FL_OBJECT * ob, int nx, int ny, int bw, int bh,
+ unsigned char const * bdata)
{
- BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec;
+ BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec;
if (sp) {
sp->nx = nx;
sp->ny = ny;
}
-void fl_set_bmtable_pixmap_data(FL_OBJECT *ob, int nx, int ny,
- char **pdata)
+void fl_set_bmtable_pixmap_data(FL_OBJECT * ob, int nx, int ny,
+ char ** pdata)
{
- BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec;
+ BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec;
extern Colormap color_map;
if (sp) {
sp->nx = nx;
void fl_set_bmtable(FL_OBJECT *, int pushed, int pos);
/** Number of columns and rows, and the background bitmap */
-void fl_set_bmtable_data(FL_OBJECT *, int, int, int, int , unsigned char *);
+void fl_set_bmtable_data(FL_OBJECT *, int, int, int, int , unsigned char const *);
///
void fl_set_bmtable_pixmap_data(FL_OBJECT *, int, int, char **);
///
void BufferParams::readLanguage(LyXLex & lex)
{
- string tmptok;
- string test;
- int n = 0;
-
if (!lex.next()) return;
- tmptok = lex.GetString();
+ string tmptok = lex.GetString();
+ string test;
+ int n = 0;
// check if tmptok is part of tex_babel in tex-defs.h
while (true) {
test = tex_babel[n++];
LFUN_URL, // CFO-G 971121
LFUN_WORDFINDFORWARD, // Etienne 980216
LFUN_WORDFINDBACKWARD, // Etienne 980220
- LFUN_APPENDIX, // ettrich 980505
+ LFUN_APPENDIX, // ettrich 980505
LFUN_IMPORT, // Asger 980724
LFUN_MENU_SEPARATOR, // Asger 990220
- LFUN_SEQUENCE, // Andre' 991111
+ LFUN_SEQUENCE, // Andre' 991111
+ LFUN_SAVEPREFERENCES, // Lgb 991127
LFUN_LASTACTION /* this marks the end of the table */
};
static void addwait(int psx, int psy, int pswid, int pshgh, figdata *data)
{
// recompute the stuff and put in the queue
- queue *p, *p2;
- p = new queue;
+ queue * p = new queue;
p->ofsx = psx;
p->ofsy = psy;
p->rx = ((float)data->raw_wid*72)/pswid;
p->next = 0;
// now put into queue
- p2 = gsqueue;
+ queue * p2 = gsqueue;
if (!gsqueue) gsqueue = p;
else {
while (p2->next) p2 = p2->next;
}
-static figdata *getfigdata(int wid, int hgh, string const & fname,
- int psx, int psy, int pswid, int pshgh,
- int raw_wid, int raw_hgh, float angle, char flags)
+static figdata * getfigdata(int wid, int hgh, string const & fname,
+ int psx, int psy, int pswid, int pshgh,
+ int raw_wid, int raw_hgh, float angle, char flags)
{
/* first search for an exact match with fname and width/height */
- int i = 0;
- figdata *p;
- XWindowAttributes wa;
if (fname.empty()) return 0;
+ int i = 0;
while (i < bmpinsref) {
if (bitmaps[i]->wid == wid && bitmaps[i]->hgh == hgh &&
bitmaps[i]->flags == flags && bitmaps[i]->fname == fname &&
if (bmpinsref > bmparrsize) {
// allocate more space
bmparrsize += figallocchunk;
- figdata **tmp = (figdata**) malloc(sizeof(figdata*)*bmparrsize);
+ figdata ** tmp = (figdata**) malloc(sizeof(figdata*)*bmparrsize);
memcpy(tmp, bitmaps, sizeof(figdata*)*(bmparrsize-figallocchunk));
free(bitmaps);
bitmaps = tmp;
}
- p = new figdata;
+ figdata * p = new figdata;
bitmaps[bmpinsref-1] = p;
p->wid = wid;
p->hgh = hgh;
p->angle = angle;
p->fname = fname;
p->flags = flags;
+ XWindowAttributes wa;
XGetWindowAttributes(fl_display, fl_get_canvas_id(
figinset_canvas), &wa);
static void makeupdatelist(figdata *p)
{
- int i;
-
- for (i = 0; i < figinsref; ++i) if (figures[i]->data == p) {
- if (lyxerr.debugging()) {
- lyxerr << "Updating inset " << figures[i]->inset
- << endl;
+ for (int i = 0; i < figinsref; ++i)
+ if (figures[i]->data == p) {
+ if (lyxerr.debugging()) {
+ lyxerr << "Updating inset "
+ << figures[i]->inset
+ << endl;
+ }
+ //UpdateInset(figures[i]->inset);
+ // add inset figures[i]->inset into to_update list
+ PutInsetIntoInsetUpdateList(figures[i]->inset);
}
- //UpdateInset(figures[i]->inset);
- // add inset figures[i]->inset into to_update list
- PutInsetIntoInsetUpdateList(figures[i]->inset);
- }
}
-void sigchldchecker(pid_t pid, int *status)
+void sigchldchecker(pid_t pid, int * status)
{
- int i;
- figdata *p;
-
- bool pid_handled = false;
-
lyxerr.debug() << "Got pid = " << pid << endl;
- pid_handled = false;
- for (i = bmpinsref - 1; i >= 0; --i) {
+ bool pid_handled = false;
+ for (int i = bmpinsref - 1; i >= 0; --i) {
if (bitmaps[i]->reading && pid == bitmaps[i]->gspid) {
lyxerr.debug() << "Found pid in bitmaps" << endl;
// now read the file and remove it from disk
- p = bitmaps[i];
+ figdata * p = bitmaps[i];
p->reading = false;
if (bitmaps[i]->gsdone) *status = 0;
if (*status == 0) {
}
if (!pid_handled) {
lyxerr.debug() << "Checking pid in pidwait" << endl;
- pidwait *p = pw, *prev = 0;
+ pidwait * p = pw, * prev = 0;
while (p) {
if (pid == p->pid) {
lyxerr.debug() << "Found pid in pidwait" << endl;
static void getbitmaps()
{
- int i;
bitmap_waiting = false;
- for (i = 0; i < bmpinsref; ++i)
+ for (int i = 0; i < bmpinsref; ++i)
if (bitmaps[i]->gspid > 0 && !bitmaps[i]->reading)
getbitmap(bitmaps[i]);
}
static void RegisterFigure(InsetFig *fi)
{
- Figref *tmpfig;
-
if (figinsref == 0) InitFigures();
fi->form = 0;
++figinsref;
free(figures);
figures = tmp;
}
- tmpfig = new Figref;
+ Figref * tmpfig = new Figref;
tmpfig->data = 0;
tmpfig->inset = fi;
figures[figinsref-1] = tmpfig;
}
-int FindFigIndex(Figref *tmpfig)
+int FindFigIndex(Figref * tmpfig)
{
int i = 0;
while (i < figinsref) {
}
-static void UnregisterFigure(InsetFig *fi)
+static void UnregisterFigure(InsetFig * fi)
{
- Figref *tmpfig = fi->figure;
- int i;
+ Figref * tmpfig = fi->figure;
if (tmpfig->data) freefigdata(tmpfig->data);
if (tmpfig->inset->form) {
tmpfig->inset->form = 0;
#endif
}
- i = FindFigIndex(tmpfig);
+ int i = FindFigIndex(tmpfig);
--figinsref;
while (i < figinsref) {
figures[i] = figures[i+1];
}
-static char* NextToken(FILE *myfile)
+static char * NextToken(FILE * myfile)
{
- char* token = 0;
+ char * token = 0;
char c;
int i = 0;
}
-InsetFig::InsetFig(int tmpx, int tmpy, Buffer *o)
+InsetFig::InsetFig(int tmpx, int tmpy, Buffer * o)
: owner(o)
{
wid = tmpx;
}
-int InsetFig::Ascent(LyXFont const&) const
+int InsetFig::Ascent(LyXFont const &) const
{
return hgh + 3;
}
-int InsetFig::Descent(LyXFont const&) const
+int InsetFig::Descent(LyXFont const &) const
{
return 1;
}
-int InsetFig::Width(LyXFont const&) const
+int InsetFig::Width(LyXFont const &) const
{
return wid + 2;
}
-void InsetFig::Draw(LyXFont font, LyXScreen &scr, int baseline, float &x)
+void InsetFig::Draw(LyXFont font, LyXScreen & scr, int baseline, float & x)
{
if (bitmap_waiting) getbitmaps();
}
-void InsetFig::Write(FILE *file)
+void InsetFig::Write(FILE * file)
{
Regenerate();
fprintf(file, "Figure size %d %d\n", wid, hgh);
}
-void InsetFig::Read(LyXLex &lex)
+void InsetFig::Read(LyXLex & lex)
{
string buf;
bool finished = false;
}
-int InsetFig::Latex(FILE *file, signed char /* fragile*/ )
+int InsetFig::Latex(FILE * file, signed char /* fragile*/ )
{
Regenerate();
if (!cmd.empty()) fprintf(file, "%s ", cmd.c_str());
}
-int InsetFig::Latex(string &file, signed char /* fragile*/ )
+int InsetFig::Latex(string & file, signed char /* fragile*/ )
{
Regenerate();
file += cmd + ' ';
}
-int InsetFig::DocBook(string &file)
+int InsetFig::DocBook(string & file)
{
string figurename= fname;
}
-void InsetFig::Validate(LaTeXFeatures &features) const
+void InsetFig::Validate(LaTeXFeatures & features) const
{
features.graphics = true;
if (subfigure) features.subfigure = true;
void InsetFig::Regenerate()
{
string cmdbuf;
- string gcmd;
string resizeW, resizeH;
string rotate, recmd;
string buf1 = OnlyPath(owner->getFileName());
string fname2 = MakeRelPath(fname, buf1);
- gcmd = "\\includegraphics{" + fname2 + '}';
+ string gcmd = "\\includegraphics{" + fname2 + '}';
switch (wtype) {
case DEF:
void InsetFig::TempRegenerate()
{
- string gcmd;
string cmdbuf;
string resizeW, resizeH;
string rotate, recmd;
- string tsubcap;
- char const *tfname; // *textra;
- float tangle, txwid, txhgh;
-
- tfname = fl_get_input(form->EpsFile);
- tsubcap = fl_get_input(form->Subcaption);
- tangle = atof(fl_get_input(form->Angle));
- txwid = atof(fl_get_input(form->Width));
- txhgh = atof(fl_get_input(form->Height));
+ char const * tfname = fl_get_input(form->EpsFile);
+ string tsubcap = fl_get_input(form->Subcaption);
+ float tangle = atof(fl_get_input(form->Angle));
+ float txwid = atof(fl_get_input(form->Width));
+ float txhgh = atof(fl_get_input(form->Height));
if (!tfname || !*tfname) {
//fl_set_object_label(form->cmd, "");
string buf1 = OnlyPath(owner->getFileName());
string fname2 = MakeRelPath(tfname, buf1);
// \includegraphics*[<llx,lly>][<urx,ury>]{file}
- gcmd = "\\includegraphics{" + fname2 + '}';
+ string gcmd = "\\includegraphics{" + fname2 + '}';
switch (twtype) {
case DEF:
cmdbuf = string("\\subfigure{") + tsubcap
+ string("}{") + cmdbuf + "}";
}
-
-
- //fl_set_object_label(form->cmd, cmdbuf.c_str());
- //fl_redraw_object(form->cmd);
}
void InsetFig::Recompute()
{
bool changed = changedfname;
- int newx, newy, nraw_x, nraw_y, frame_wid, frame_hgh;
- float sin_a, cos_a;
+ int newx, newy, nraw_x, nraw_y;
if (changed) GetPSSizes();
- sin_a = sin (angle / DEG2PI); /* rotation; H. Zeller 021296 */
- cos_a = cos (angle / DEG2PI);
- frame_wid = (int) ceil (fabs(cos_a * pswid) + fabs(sin_a * pshgh));
- frame_hgh= (int) ceil (fabs(cos_a * pshgh) + fabs(sin_a * pswid));
+ float sin_a = sin (angle / DEG2PI); /* rotation; H. Zeller 021296 */
+ float cos_a = cos (angle / DEG2PI);
+ int frame_wid = (int) ceil (fabs(cos_a * pswid) + fabs(sin_a * pshgh));
+ int frame_hgh= (int) ceil (fabs(cos_a * pshgh) + fabs(sin_a * pswid));
/* now recompute wid and hgh, and if that is changed, set changed */
/* this depends on chosen size of the picture and its bbox */
subfigure = psubfigure;
if (changed) {
- figdata *pf = figure->data;
+ figdata * pf = figure->data;
// get new data
if (!fname.empty() && (flags & 3) && !lyxrc->ps_command.empty()) {
{
#warning rewrite this method to use ifstream
/* get %%BoundingBox: from postscript file */
- int lastchar, c;
char * p = 0;
/* defaults to associated size
pswid = 595;
pshgh = 842;
- lastchar = fgetc(f);
+ int lastchar = fgetc(f);
for (;;) {
- c = fgetc(f);
+ int c = fgetc(f);
if (c == EOF) {
lyxerr.debug() << "End of (E)PS file reached and"
" no BoundingBox!" << endl;
void InsetFig::CallbackFig(long arg)
{
bool regen = false;
- char const *p;
+ char const * p;
if (lyxerr.debugging()) {
printf("Figure callback, arg %ld\n", arg);
break;
case 7: /* apply */
case 8: /* ok (apply and close) */
- if(!current_view->buffer()->isReadonly())
- {
+ if(!current_view->buffer()->isReadonly()) {
wtype = twtype;
htype = thtype;
xwid = atof(fl_get_input(form->Width));
if (regen) TempRegenerate();
}
+
inline void DisableFigurePanel(FD_Figure * const form)
{
fl_deactivate_object(form->EpsFile);
fl_set_object_lcol (form->ApplyBtn, FL_INACTIVE);
}
+
inline void EnableFigurePanel(FD_Figure * const form)
{
fl_activate_object(form->EpsFile);
fl_set_object_lcol (form->ApplyBtn, FL_BLACK);
}
+
void InsetFig::RestoreForm()
{
char buf[32];
- int pflags;
EnableFigurePanel(form);
fl_activate_object(form->Height);
}
- pflags = flags & 3;
+ int pflags = flags & 3;
fl_set_button(form->Wysiwyg0, (pflags == 0));
fl_set_button(form->Wysiwyg1, (pflags == 1));
fl_set_button(form->Wysiwyg2, (pflags == 2));
}
-void InsetFig::Preview(char const *p)
+void InsetFig::Preview(char const * p)
{
- int pid;
-
- pid = fork();
+ int pid = fork();
if (pid == -1) {
lyxerr << "Cannot fork process!" << endl;
void InsetFig::BrowseFile()
{
- string buf, buf2, bufclip;
static string current_figure_path;
static int once = 0;
LyXFileDlg fileDlg;
}
string p = fl_get_input(form->EpsFile);
- buf = MakeAbsPath(owner->getFileName());
- buf2 = OnlyPath(buf);
+ string buf = MakeAbsPath(owner->getFileName());
+ string buf2 = OnlyPath(buf);
if (!p.empty()) {
buf = MakeAbsPath(p, buf2);
buf = OnlyPath(buf);
}
// Does user clipart directory exist?
- bufclip = AddName (user_lyxdir, "clipart");
+ string bufclip = AddName (user_lyxdir, "clipart");
FileInfo fileInfo(bufclip);
if (!(fileInfo.isOK() && fileInfo.isDir()))
// No - bail out to system clipart directory
}
-void GraphicsCB(FL_OBJECT *obj, long arg)
+void GraphicsCB(FL_OBJECT * obj, long arg)
{
/* obj->form contains the form */
// The order of the LayoutTags enum is no more important. [asierra300396]
// Tags indexes.
enum LayoutTags {
- LT_ALIGN, LT_ALIGNPOSSIBLE,
- LT_BLOCK, LT_MARGIN,
- LT_BOTTOMSEP, LT_CENTER, LT_CENTERED_TOP_ENVIRONMENT, LT_COLUMNS,
- LT_COPYSTYLE, LT_OBSOLETEDBY,
- LT_COMMAND, LT_COUNTER_CHAPTER, LT_COUNTER_ENUMI, LT_COUNTER_ENUMII,
- LT_COUNTER_ENUMIII, LT_COUNTER_ENUMIV, LT_COUNTER_PARAGRAPH,
- LT_COUNTER_SECTION, LT_COUNTER_SUBPARAGRAPH, LT_COUNTER_SUBSECTION,
- LT_COUNTER_SUBSUBSECTION, LT_DEFAULTFONT, LT_DYNAMIC, LT_EMPTY,
- LT_END, LT_ENVIRONMENT, LT_ENVIRONMENT_DEFAULT,
- LT_FANCYHDR, LT_FILL_BOTTOM, LT_FILL_TOP, LT_FIRST_COUNTER,
- LT_FIRST_DYNAMIC, LT_FONT, LT_FREE_SPACING, LT_HEADINGS, LT_INPUT,
- LT_ITEM_ENVIRONMENT, LT_ITEMSEP, LT_KEEPEMPTY,
- LT_LABEL_BOTTOMSEP, LT_LABELFONT, LT_TEXTFONT,
- LT_LABELINDENT, LT_LABELSEP, LT_LABELSTRING,
- LT_LABELSTRING_APPENDIX, LT_LABELTYPE,
- LT_LATEXNAME, LT_LATEXPARAM, LT_LATEXTYPE, LT_LAYOUT, LT_LEFT,
- LT_LEFTMARGIN,
- LT_LIST_ENVIRONMENT , LT_MANUAL, LT_MAXCOUNTER,
- LT_NEED_PROTECT, LT_NEWLINE,
- LT_NEXTNOINDENT, LT_NO_LABEL, LT_NOSTYLE,
- LT_PAGESTYLE, LT_PARAGRAPH,
- LT_PARINDENT, LT_PARSEP, LT_PARSKIP, LT_PLAIN, LT_PREAMBLE,
- LT_PROVIDESAMSMATH, LT_PROVIDESMAKEIDX, LT_PROVIDESURL, LT_RIGHT,
- LT_RIGHT_ADDRESS_BOX, LT_RIGHTMARGIN, LT_SENSITIVE, LT_SIDES,
- LT_SPACING, LT_SPACING_SINGLE, LT_SPACING_ONEHALF,
- LT_SPACING_DOUBLE, LT_OTHER, LT_CLASSOPTIONS, LT_FONTSIZE,
- LT_STATIC, LT_STYLE, LT_TOP_ENVIRONMENT, LT_TOPSEP, LT_BIBLIO,
- LT_INTITLE, LT_SECNUMDEPTH, LT_TOCDEPTH,
- LT_OUTPUTTYPE, LT_OTLATEX, LT_OTLINUXDOC, LT_OTDOCBOOK, LT_OTLITERATE
+ LT_ALIGN = 1,
+ LT_ALIGNPOSSIBLE,
+ LT_MARGIN,
+ LT_BOTTOMSEP,
+ LT_COPYSTYLE,
+ LT_OBSOLETEDBY,
+ //LT_EMPTY,
+ LT_END,
+ //LT_ENVIRONMENT_DEFAULT,
+ //LT_FANCYHDR,
+ LT_FILL_BOTTOM,
+ LT_FILL_TOP,
+ //LT_FIRST_COUNTER,
+ LT_FONT,
+ LT_FREE_SPACING,
+ //LT_HEADINGS,
+ LT_ITEMSEP,
+ LT_KEEPEMPTY,
+ LT_LABEL_BOTTOMSEP,
+ LT_LABELFONT,
+ LT_TEXTFONT,
+ LT_LABELINDENT,
+ LT_LABELSEP,
+ LT_LABELSTRING,
+ LT_LABELSTRING_APPENDIX,
+ LT_LABELTYPE,
+ LT_LATEXNAME,
+ LT_LATEXPARAM,
+ LT_LATEXTYPE,
+ LT_LEFTMARGIN,
+ LT_NEED_PROTECT,
+ LT_NEWLINE,
+ LT_NEXTNOINDENT,
+ LT_PARINDENT,
+ LT_PARSEP,
+ LT_PARSKIP,
+ //LT_PLAIN,
+ LT_PREAMBLE,
+ LT_RIGHTMARGIN,
+ LT_SPACING,
+ LT_TOPSEP,
+ LT_INTITLE
};
static keyword_item layoutTags[] = {
{ "align", LT_ALIGN },
{ "alignpossible", LT_ALIGNPOSSIBLE },
- { "bibliography", LT_BIBLIO },
- { "block", LT_BLOCK },
{ "bottomsep", LT_BOTTOMSEP },
- { "center", LT_CENTER },
- { "centered_top_environment", LT_CENTERED_TOP_ENVIRONMENT },
- { "classoptions", LT_CLASSOPTIONS },
- { "columns", LT_COLUMNS },
- { "command", LT_COMMAND },
{ "copystyle", LT_COPYSTYLE },
- { "counter_chapter", LT_COUNTER_CHAPTER },
- { "counter_enumi", LT_COUNTER_ENUMI },
- { "counter_enumii", LT_COUNTER_ENUMII },
- { "counter_enumiii", LT_COUNTER_ENUMIII },
- { "counter_enumiv", LT_COUNTER_ENUMIV },
- { "counter_paragraph", LT_COUNTER_PARAGRAPH },
- { "counter_section", LT_COUNTER_SECTION },
- { "counter_subparagraph", LT_COUNTER_SUBPARAGRAPH },
- { "counter_subsection", LT_COUNTER_SUBSECTION },
- { "counter_subsubsection", LT_COUNTER_SUBSUBSECTION },
- { "defaultfont", LT_DEFAULTFONT },
- { "docbook", LT_OTDOCBOOK },
- { "double", LT_SPACING_DOUBLE },
- { "dynamic", LT_DYNAMIC },
- { "empty", LT_EMPTY },
{ "end", LT_END },
- { "environment", LT_ENVIRONMENT },
- { "environment_default", LT_ENVIRONMENT_DEFAULT },
- { "fancyhdr", LT_FANCYHDR },
{ "fill_bottom", LT_FILL_BOTTOM },
{ "fill_top", LT_FILL_TOP },
- { "first_counter", LT_FIRST_COUNTER },
- { "first_dynamic", LT_FIRST_DYNAMIC },
{ "font", LT_FONT },
- { "fontsize", LT_FONTSIZE },
{ "freespacing", LT_FREE_SPACING },
- { "headings", LT_HEADINGS },
- { "input", LT_INPUT },
{ "intitle", LT_INTITLE },
- { "item_environment", LT_ITEM_ENVIRONMENT },
{ "itemsep", LT_ITEMSEP },
{ "keepempty", LT_KEEPEMPTY },
{ "labelbottomsep", LT_LABEL_BOTTOMSEP },
{ "labelstring", LT_LABELSTRING },
{ "labelstringappendix", LT_LABELSTRING_APPENDIX },
{ "labeltype", LT_LABELTYPE },
- { "latex", LT_OTLATEX },
{ "latexname", LT_LATEXNAME },
- { "latexparam", LT_LATEXPARAM }, //arrae970411
+ { "latexparam", LT_LATEXPARAM },
{ "latextype", LT_LATEXTYPE },
- { "layout", LT_LAYOUT },
- { "left", LT_LEFT },
{ "leftmargin", LT_LEFTMARGIN },
- { "linuxdoc", LT_OTLINUXDOC },
- { "list_environment", LT_LIST_ENVIRONMENT },
- { "literate", LT_OTLITERATE },
- { "manual", LT_MANUAL },
{ "margin", LT_MARGIN },
- { "maxcounter", LT_MAXCOUNTER },
{ "needprotect", LT_NEED_PROTECT },
{ "newline", LT_NEWLINE },
{ "nextnoindent", LT_NEXTNOINDENT },
- { "no_label", LT_NO_LABEL },
- { "nostyle", LT_NOSTYLE },
{ "obsoletedby", LT_OBSOLETEDBY },
- { "onehalf", LT_SPACING_ONEHALF },
- { "other", LT_OTHER },
- { "outputtype", LT_OUTPUTTYPE },
- { "pagestyle", LT_PAGESTYLE },
- { "paragraph", LT_PARAGRAPH },
{ "parindent", LT_PARINDENT },
{ "parsep", LT_PARSEP },
{ "parskip", LT_PARSKIP },
- { "plain", LT_PLAIN },
{ "preamble", LT_PREAMBLE },
- { "providesamsmath", LT_PROVIDESAMSMATH },
- { "providesmakeidx", LT_PROVIDESMAKEIDX },
- { "providesurl", LT_PROVIDESURL },
- { "right", LT_RIGHT },
- { "right_address_box", LT_RIGHT_ADDRESS_BOX },
{ "rightmargin", LT_RIGHTMARGIN },
- { "secnumdepth", LT_SECNUMDEPTH },
- { "sensitive", LT_SENSITIVE },
- { "sides", LT_SIDES },
- { "single", LT_SPACING_SINGLE },
{ "spacing", LT_SPACING },
- { "static", LT_STATIC },
- { "style", LT_STYLE },
{ "textfont", LT_TEXTFONT },
- { "tocdepth", LT_TOCDEPTH },
- { "top_environment", LT_TOP_ENVIRONMENT },
{ "topsep", LT_TOPSEP }
};
{
bool error = false;
bool finished = false;
-
+ lexrc.pushTable(layoutTags, LT_INTITLE);
// parse style section
while (!finished && lexrc.IsOK() && !error) {
- switch(lexrc.lex()) {
-
- case -2:
- break;
+ int le = lexrc.lex();
+ // See comment in lyxrc.C.
+ switch(le) {
+ case LyXLex::LEX_FEOF:
+ continue; break;
- case -1: // parse error
- lexrc.printError("Unknown tag `$$Token'");
+ case LyXLex::LEX_UNDEF: // parse error
+ lexrc.printError("Unknown layout tag `$$Token'");
error = true;
- break;
-
+ continue; break;
+ default: break;
+ }
+ switch(static_cast<LayoutTags>(le)) {
case LT_END: // end of structure
finished = true;
break;
break;
case LT_MARGIN: // Margin style definition.
-
- switch(lexrc.lex()) {
- case LT_STATIC:
- margintype = MARGIN_STATIC;
- break;
- case LT_MANUAL:
- margintype = MARGIN_MANUAL;
- break;
- case LT_DYNAMIC:
- margintype = MARGIN_DYNAMIC;
- break;
- case LT_FIRST_DYNAMIC:
- margintype = MARGIN_FIRST_DYNAMIC;
- break;
- case LT_RIGHT_ADDRESS_BOX:
- margintype = MARGIN_RIGHT_ADDRESS_BOX;
- break;
- default:
- lexrc.printError("Unknown margin type `$$Token'");
- break;
- }
+ readMargin(lexrc);
break;
case LT_LATEXTYPE: // Latex style definition.
- switch (lexrc.lex()) {
- case LT_PARAGRAPH:
- latextype= LATEX_PARAGRAPH;
- break;
- case LT_COMMAND:
- latextype= LATEX_COMMAND;
- break;
- case LT_ENVIRONMENT:
- latextype= LATEX_ENVIRONMENT;
- break;
- case LT_ITEM_ENVIRONMENT:
- latextype= LATEX_ITEM_ENVIRONMENT;
- break;
- case LT_LIST_ENVIRONMENT:
- latextype= LATEX_LIST_ENVIRONMENT;
- break;
- default:
- lexrc.printError("Unknown latextype `$$Token'");
- break;
- }
+ readLatexType(lexrc);
break;
case LT_INTITLE:
break;
case LT_LABELTYPE:
- switch (lexrc.lex()) {
- case LT_NO_LABEL:
- labeltype = LABEL_NO_LABEL;
- break;
- case LT_MANUAL:
- labeltype = LABEL_MANUAL;
- break;
- case LT_TOP_ENVIRONMENT:
- labeltype = LABEL_TOP_ENVIRONMENT;
- break;
- case LT_CENTERED_TOP_ENVIRONMENT:
- labeltype = LABEL_CENTERED_TOP_ENVIRONMENT;
- break;
- case LT_STATIC:
- labeltype = LABEL_STATIC;
- break;
- case LT_SENSITIVE:
- labeltype = LABEL_SENSITIVE;
- break;
- case LT_COUNTER_CHAPTER:
- labeltype = LABEL_COUNTER_CHAPTER;
- break;
- case LT_COUNTER_SECTION:
- labeltype = LABEL_COUNTER_SECTION;
- break;
- case LT_COUNTER_SUBSECTION:
- labeltype = LABEL_COUNTER_SUBSECTION;
- break;
- case LT_COUNTER_SUBSUBSECTION:
- labeltype = LABEL_COUNTER_SUBSUBSECTION;
- break;
- case LT_COUNTER_PARAGRAPH:
- labeltype = LABEL_COUNTER_PARAGRAPH;
- break;
- case LT_COUNTER_SUBPARAGRAPH:
- labeltype = LABEL_COUNTER_SUBPARAGRAPH;
- break;
- case LT_COUNTER_ENUMI:
- labeltype = LABEL_COUNTER_ENUMI;
- break;
- case LT_COUNTER_ENUMII:
- labeltype = LABEL_COUNTER_ENUMII;
- break;
- case LT_COUNTER_ENUMIII:
- labeltype = LABEL_COUNTER_ENUMIII;
- break;
- case LT_COUNTER_ENUMIV:
- labeltype = LABEL_COUNTER_ENUMIV;
- break;
- case LT_BIBLIO:
- labeltype = LABEL_BIBLIO;
- break;
- default:
- lexrc.printError("Unknown labeltype `$$Token'");
- }
+ readLabelType(lexrc);
break;
-
+
case LT_LEFTMARGIN: // left margin type
if (lexrc.next())
leftmargin = lexrc.GetString();
break;
case LT_ALIGN: // paragraph align
- switch (lexrc.lex()) {
- case LT_BLOCK:
- align = LYX_ALIGN_BLOCK;
- break;
- case LT_LEFT:
- align = LYX_ALIGN_LEFT;
- break;
- case LT_RIGHT:
- align = LYX_ALIGN_RIGHT;
- break;
- case LT_CENTER:
- align = LYX_ALIGN_CENTER;
- break;
- case LT_LAYOUT:
- align = LYX_ALIGN_LAYOUT;
- break;
- default:
- lexrc.printError("Unknown alignment `$$Token'");
- }
+ readAlign(lexrc);
break;
-
case LT_ALIGNPOSSIBLE: // paragraph allowed align
- { alignpossible = LYX_ALIGN_NONE;
-
- int lineno = lexrc.GetLineNo();
- do {
- switch (lexrc.lex()) {
- case LT_BLOCK:
- alignpossible |= LYX_ALIGN_BLOCK;
- break;
- case LT_LEFT:
- alignpossible |= LYX_ALIGN_LEFT;
- break;
- case LT_RIGHT:
- alignpossible |= LYX_ALIGN_RIGHT;
- break;
- case LT_CENTER:
- alignpossible |= LYX_ALIGN_CENTER;
- break;
- case LT_LAYOUT:
- alignpossible |= LYX_ALIGN_LAYOUT;
- break;
- default:
- lexrc.printError("Unknown alignment `$$Token'");
-
- }
- } while (lineno == lexrc.GetLineNo());
- break;
- }
+ readAlignPossible(lexrc);
+ break;
case LT_LABELSTRING: // label string definition
if (lexrc.next())
break;
case LT_SPACING: // setspace.sty
- switch(lexrc.lex()) {
- case LT_SPACING_SINGLE:
- spacing.set(Spacing::Single);
- break;
- case LT_SPACING_ONEHALF:
- spacing.set(Spacing::Onehalf);
- break;
- case LT_SPACING_DOUBLE:
- spacing.set(Spacing::Double);
- break;
- case LT_OTHER:
- lexrc.next();
- spacing.set(Spacing::Other, lexrc.GetFloat());
- break;
- default:
- lexrc.printError("Unknown spacing `$$Token'");
- }
+ readSpacing(lexrc);
break;
- default: /* context error */
- lexrc.printError("Tag `$$Token' is not "
- "allowed in layout");
- error = true;
+ }
+ }
+ lexrc.popTable();
+ return error;
+}
+
+enum AlignTags {
+ AT_BLOCK = 1,
+ AT_LEFT,
+ AT_RIGHT,
+ AT_CENTER,
+ AT_LAYOUT
+};
+
+static keyword_item alignTags[] = {
+ { "block", AT_BLOCK },
+ { "center", AT_CENTER },
+ { "layout", AT_LAYOUT },
+ { "left", AT_LEFT },
+ { "right", AT_RIGHT }
+};
+
+
+void LyXLayout::readAlign(LyXLex & lexrc)
+{
+ pushpophelper pph(lexrc, alignTags, AT_LAYOUT);
+ int le = lexrc.lex();
+ switch (le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown alignment `$$Token'");
+ return; break;
+ default: break;
+ };
+ switch(static_cast<AlignTags>(le)) {
+ case AT_BLOCK:
+ align = LYX_ALIGN_BLOCK;
+ break;
+ case AT_LEFT:
+ align = LYX_ALIGN_LEFT;
+ break;
+ case AT_RIGHT:
+ align = LYX_ALIGN_RIGHT;
+ break;
+ case AT_CENTER:
+ align = LYX_ALIGN_CENTER;
+ break;
+ case AT_LAYOUT:
+ align = LYX_ALIGN_LAYOUT;
+ break;
+ }
+}
+
+
+void LyXLayout::readAlignPossible(LyXLex & lexrc)
+{
+ lexrc.pushTable(alignTags, AT_LAYOUT);
+ alignpossible = LYX_ALIGN_NONE;
+ int lineno = lexrc.GetLineNo();
+ do {
+ int le = lexrc.lex();
+ switch (le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown alignment `$$Token'");
+ continue; break;
+ default: break;
+ };
+ switch (static_cast<AlignTags>(le)) {
+ case AT_BLOCK:
+ alignpossible |= LYX_ALIGN_BLOCK;
+ break;
+ case AT_LEFT:
+ alignpossible |= LYX_ALIGN_LEFT;
+ break;
+ case AT_RIGHT:
+ alignpossible |= LYX_ALIGN_RIGHT;
+ break;
+ case AT_CENTER:
+ alignpossible |= LYX_ALIGN_CENTER;
+ break;
+ case AT_LAYOUT:
+ alignpossible |= LYX_ALIGN_LAYOUT;
break;
}
+ } while (lineno == lexrc.GetLineNo());
+ lexrc.popTable();
+}
+
+enum LabelTypeTags {
+ LA_NO_LABEL = 1,
+ LA_MANUAL,
+ LA_TOP_ENVIRONMENT,
+ LA_CENTERED_TOP_ENVIRONMENT,
+ LA_STATIC,
+ LA_SENSITIVE,
+ LA_COUNTER_CHAPTER,
+ LA_COUNTER_SECTION,
+ LA_COUNTER_SUBSECTION,
+ LA_COUNTER_SUBSUBSECTION,
+ LA_COUNTER_PARAGRAPH,
+ LA_COUNTER_SUBPARAGRAPH,
+ LA_COUNTER_ENUMI,
+ LA_COUNTER_ENUMII,
+ LA_COUNTER_ENUMIII,
+ LA_COUNTER_ENUMIV,
+ LA_BIBLIO
+};
+
+static keyword_item labelTypeTags[] = {
+ { "bibliography", LA_BIBLIO },
+ { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
+ { "counter_chapter", LA_COUNTER_CHAPTER },
+ { "counter_enumi", LA_COUNTER_ENUMI },
+ { "counter_enumii", LA_COUNTER_ENUMII },
+ { "counter_enumiii", LA_COUNTER_ENUMIII },
+ { "counter_enumiv", LA_COUNTER_ENUMIV },
+ { "counter_paragraph", LA_COUNTER_PARAGRAPH },
+ { "counter_section", LA_COUNTER_SECTION },
+ { "counter_subparagraph", LA_COUNTER_SUBPARAGRAPH },
+ { "counter_subsection", LA_COUNTER_SUBSECTION },
+ { "counter_subsubsection", LA_COUNTER_SUBSUBSECTION },
+ { "manual", LA_MANUAL },
+ { "no_label", LA_NO_LABEL },
+ { "sensitive", LA_SENSITIVE },
+ { "static", LA_STATIC },
+ { "top_environment", LA_TOP_ENVIRONMENT }
+};
+
+void LyXLayout::readLabelType(LyXLex & lexrc)
+{
+ pushpophelper pph(lexrc, labelTypeTags, LA_BIBLIO);
+ int le = lexrc.lex();
+ switch (le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown labeltype tag `$$Token'");
+ return; break;
+ default: break;
+ }
+ switch (static_cast<LabelTypeTags>(le)) {
+ case LA_NO_LABEL:
+ labeltype = LABEL_NO_LABEL;
+ break;
+ case LA_MANUAL:
+ labeltype = LABEL_MANUAL;
+ break;
+ case LA_TOP_ENVIRONMENT:
+ labeltype = LABEL_TOP_ENVIRONMENT;
+ break;
+ case LA_CENTERED_TOP_ENVIRONMENT:
+ labeltype = LABEL_CENTERED_TOP_ENVIRONMENT;
+ break;
+ case LA_STATIC:
+ labeltype = LABEL_STATIC;
+ break;
+ case LA_SENSITIVE:
+ labeltype = LABEL_SENSITIVE;
+ break;
+ case LA_COUNTER_CHAPTER:
+ labeltype = LABEL_COUNTER_CHAPTER;
+ break;
+ case LA_COUNTER_SECTION:
+ labeltype = LABEL_COUNTER_SECTION;
+ break;
+ case LA_COUNTER_SUBSECTION:
+ labeltype = LABEL_COUNTER_SUBSECTION;
+ break;
+ case LA_COUNTER_SUBSUBSECTION:
+ labeltype = LABEL_COUNTER_SUBSUBSECTION;
+ break;
+ case LA_COUNTER_PARAGRAPH:
+ labeltype = LABEL_COUNTER_PARAGRAPH;
+ break;
+ case LA_COUNTER_SUBPARAGRAPH:
+ labeltype = LABEL_COUNTER_SUBPARAGRAPH;
+ break;
+ case LA_COUNTER_ENUMI:
+ labeltype = LABEL_COUNTER_ENUMI;
+ break;
+ case LA_COUNTER_ENUMII:
+ labeltype = LABEL_COUNTER_ENUMII;
+ break;
+ case LA_COUNTER_ENUMIII:
+ labeltype = LABEL_COUNTER_ENUMIII;
+ break;
+ case LA_COUNTER_ENUMIV:
+ labeltype = LABEL_COUNTER_ENUMIV;
+ break;
+ case LA_BIBLIO:
+ labeltype = LABEL_BIBLIO;
+ break;
}
+}
- return error;
+enum MarginTags {
+ MT_STATIC = 1,
+ MT_MANUAL,
+ MT_DYNAMIC,
+ MT_FIRST_DYNAMIC,
+ MT_RIGHT_ADDRESS_BOX
+};
+
+static keyword_item marginTags[] = {
+ { "dynamic", MT_DYNAMIC },
+ { "first_dynamic", MT_FIRST_DYNAMIC },
+ { "manual", MT_MANUAL },
+ { "right_address_box", MT_RIGHT_ADDRESS_BOX },
+ { "static", MT_STATIC }
+};
+
+void LyXLayout::readMargin(LyXLex & lexrc)
+{
+ pushpophelper pph(lexrc, marginTags, MT_RIGHT_ADDRESS_BOX);
+ int le = lexrc.lex();
+ switch(le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown margin type tag `$$Token'");
+ return; break;
+ default: break;
+ }
+ switch(static_cast<MarginTags>(le)) {
+ case MT_STATIC:
+ margintype = MARGIN_STATIC;
+ break;
+ case MT_MANUAL:
+ margintype = MARGIN_MANUAL;
+ break;
+ case MT_DYNAMIC:
+ margintype = MARGIN_DYNAMIC;
+ break;
+ case MT_FIRST_DYNAMIC:
+ margintype = MARGIN_FIRST_DYNAMIC;
+ break;
+ case MT_RIGHT_ADDRESS_BOX:
+ margintype = MARGIN_RIGHT_ADDRESS_BOX;
+ break;
+ }
}
+enum LatexTypeTags {
+ LX_PARAGRAPH = 1,
+ LX_COMMAND,
+ LX_ENVIRONMENT,
+ LX_ITEM_ENVIRONMENT,
+ LX_LIST_ENVIRONMENT
+};
+
+static keyword_item latexTypeTags[] = {
+ { "command", LX_COMMAND },
+ { "environment", LX_ENVIRONMENT },
+ { "item_environment", LX_ITEM_ENVIRONMENT },
+ { "list_environment", LX_LIST_ENVIRONMENT },
+ { "paragraph", LX_PARAGRAPH }
+};
+
+void LyXLayout::readLatexType(LyXLex & lexrc)
+{
+ pushpophelper pph(lexrc, latexTypeTags, LX_LIST_ENVIRONMENT);
+ int le = lexrc.lex();
+ switch (le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown latextype tag `$$Token'");
+ return; break;
+ default: break;
+ }
+ switch (static_cast<LatexTypeTags>(le)) {
+ case LX_PARAGRAPH:
+ latextype= LATEX_PARAGRAPH;
+ break;
+ case LX_COMMAND:
+ latextype= LATEX_COMMAND;
+ break;
+ case LX_ENVIRONMENT:
+ latextype= LATEX_ENVIRONMENT;
+ break;
+ case LX_ITEM_ENVIRONMENT:
+ latextype= LATEX_ITEM_ENVIRONMENT;
+ break;
+ case LX_LIST_ENVIRONMENT:
+ latextype= LATEX_LIST_ENVIRONMENT;
+ break;
+ }
+}
+
+enum SpacingTags {
+ ST_SPACING_SINGLE = 1,
+ ST_SPACING_ONEHALF,
+ ST_SPACING_DOUBLE,
+ ST_OTHER
+};
+
+static keyword_item spacingTags[] = {
+ {"double", ST_SPACING_DOUBLE },
+ {"onehalf", ST_SPACING_ONEHALF },
+ {"other", ST_OTHER },
+ {"single", ST_SPACING_SINGLE }
+};
+
+void LyXLayout::readSpacing(LyXLex & lexrc)
+{
+ pushpophelper pph(lexrc, spacingTags, ST_OTHER);
+ int le = lexrc.lex();
+ switch(le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown spacing token `$$Token'");
+ return; break;
+ default: break;
+ }
+ switch(static_cast<SpacingTags>(le)) {
+ case ST_SPACING_SINGLE:
+ spacing.set(Spacing::Single);
+ break;
+ case ST_SPACING_ONEHALF:
+ spacing.set(Spacing::Onehalf);
+ break;
+ case ST_SPACING_DOUBLE:
+ spacing.set(Spacing::Double);
+ break;
+ case ST_OTHER:
+ lexrc.next();
+ spacing.set(Spacing::Other, lexrc.GetFloat());
+ break;
+ }
+}
/* ******************************************************************* */
}
+enum TextClassTags {
+ TC_OUTPUTTYPE = 1,
+ TC_INPUT,
+ TC_STYLE,
+ TC_NOSTYLE,
+ TC_COLUMNS,
+ TC_SIDES,
+ TC_PAGESTYLE,
+ TC_DEFAULTFONT,
+ TC_MAXCOUNTER,
+ TC_SECNUMDEPTH,
+ TC_TOCDEPTH,
+ TC_CLASSOPTIONS,
+ TC_PREAMBLE,
+ TC_PROVIDESAMSMATH,
+ TC_PROVIDESMAKEIDX,
+ TC_PROVIDESURL,
+ TC_LEFTMARGIN,
+ TC_RIGHTMARGIN
+};
+
+static keyword_item textClassTags[] = {
+ { "classoptions", TC_CLASSOPTIONS },
+ { "columns", TC_COLUMNS },
+ { "defaultfont", TC_DEFAULTFONT },
+ { "input", TC_INPUT },
+ { "leftmargin", TC_LEFTMARGIN },
+ { "maxcounter", TC_MAXCOUNTER },
+ { "nostyle", TC_NOSTYLE },
+ { "outputtype", TC_OUTPUTTYPE },
+ { "pagestyle", TC_PAGESTYLE },
+ { "preamble", TC_PREAMBLE },
+ { "providesamsmath", TC_PROVIDESAMSMATH },
+ { "providesmakeidx", TC_PROVIDESMAKEIDX },
+ { "providesurl", TC_PROVIDESURL },
+ { "rightmargin", TC_RIGHTMARGIN },
+ { "secnumdepth", TC_SECNUMDEPTH },
+ { "sides", TC_SIDES },
+ { "style", TC_STYLE },
+ { "tocdepth", TC_TOCDEPTH }
+};
+
// Reads a textclass structure from file.
bool LyXTextClass::Read(string const & filename, bool merge)
{
<< MakeDisplayPath(filename)
<< endl;
- LyXLex lexrc(layoutTags, sizeof(layoutTags)/sizeof(keyword_item));
+ LyXLex lexrc(textClassTags, TC_RIGHTMARGIN);
bool error = false;
lexrc.setFile(filename);
// parsing
while (lexrc.IsOK() && !error) {
- switch(lexrc.lex()) {
- case -2:
- break;
+ int le = lexrc.lex();
+ switch(le) {
+ case LyXLex::LEX_FEOF:
+ continue; break;
- case -1:
- lexrc.printError("Unknown tag `$$Token'");
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown TextClass tag `$$Token'");
error = true;
- break;
-
- case LT_OUTPUTTYPE: // output type definition
- switch(lexrc.lex()) {
- case LT_OTLATEX:
- outputType_ = LATEX;
- break;
- case LT_OTLINUXDOC:
- outputType_ = LINUXDOC;
- break;
- case LT_OTDOCBOOK:
- outputType_ = DOCBOOK;
- break;
- case LT_OTLITERATE:
- outputType_ = LITERATE;
- break;
- default:
- lexrc.printError("Unknown output type `$$Token'");
- break;
- }
+ continue; break;
+ default: break;
+ }
+ switch(static_cast<TextClassTags>(le)) {
+ case TC_OUTPUTTYPE: // output type definition
+ readOutputType(lexrc);
break;
- case LT_INPUT: // Include file
+ case TC_INPUT: // Include file
if (lexrc.next()) {
string tmp = LibFileSearch("layouts",
lexrc.GetString(),
}
break;
- case LT_STYLE:
+ case TC_STYLE:
if (lexrc.next()) {
string name = subst(lexrc.GetString(),
'_', ' ');
}
break;
- case LT_NOSTYLE:
+ case TC_NOSTYLE:
if (lexrc.next()) {
string style = subst(lexrc.GetString(),
'_', ' ');
}
break;
- case LT_COLUMNS:
+ case TC_COLUMNS:
if (lexrc.next())
columns_ = lexrc.GetInteger();
break;
- case LT_SIDES:
+ case TC_SIDES:
if (lexrc.next()) {
switch(lexrc.GetInteger()) {
case 1: sides_ = OneSide; break;
}
break;
- case LT_PAGESTYLE:
+ case TC_PAGESTYLE:
lexrc.next();
pagestyle_ = strip(lexrc.GetString());
break;
- case LT_DEFAULTFONT:
+ case TC_DEFAULTFONT:
defaultfont_.lyxRead(lexrc);
if (!defaultfont_.resolved()) {
lexrc.printError("Warning: defaultfont should "
}
break;
- case LT_MAXCOUNTER:
- switch (lexrc.lex()) {
- case LT_COUNTER_CHAPTER:
- maxcounter_ = LABEL_COUNTER_CHAPTER;
- break;
- case LT_COUNTER_SECTION:
- maxcounter_ = LABEL_COUNTER_SECTION;
- break;
- case LT_COUNTER_SUBSECTION:
- maxcounter_ = LABEL_COUNTER_SUBSECTION;
- break;
- case LT_COUNTER_SUBSUBSECTION:
- maxcounter_ = LABEL_COUNTER_SUBSUBSECTION;
- break;
- case LT_COUNTER_PARAGRAPH:
- maxcounter_ = LABEL_COUNTER_PARAGRAPH;
- break;
- case LT_COUNTER_SUBPARAGRAPH:
- maxcounter_ = LABEL_COUNTER_SUBPARAGRAPH;
- break;
- case LT_COUNTER_ENUMI:
- maxcounter_ = LABEL_COUNTER_ENUMI;
- break;
- case LT_COUNTER_ENUMII:
- maxcounter_ = LABEL_COUNTER_ENUMII;
- break;
- case LT_COUNTER_ENUMIII:
- maxcounter_ = LABEL_COUNTER_ENUMIII;
- break;
- case LT_COUNTER_ENUMIV:
- maxcounter_ = LABEL_COUNTER_ENUMIV;
- break;
- }
+ case TC_MAXCOUNTER:
+ readMaxCounter(lexrc);
break;
- case LT_SECNUMDEPTH:
+ case TC_SECNUMDEPTH:
lexrc.next();
secnumdepth_ = lexrc.GetInteger();
break;
- case LT_TOCDEPTH:
+ case TC_TOCDEPTH:
lexrc.next();
tocdepth_ = lexrc.GetInteger();
break;
// First step to support options
- case LT_CLASSOPTIONS:
- {
- bool getout = true;
- while (getout && lexrc.IsOK()) {
- switch (lexrc.lex()) {
- case LT_FONTSIZE:
- lexrc.next();
- opt_fontsize_ = strip(lexrc.GetString());
- break;
- case LT_PAGESTYLE:
- lexrc.next();
- opt_pagestyle_ = strip(lexrc.GetString());
- break;
- case LT_OTHER:
- lexrc.next();
- options_ = lexrc.GetString();
- break;
- case LT_END: getout = false; break;
- default:
- lexrc.printError("Out of context tag `$$Token'");
- break;
- }
- }
+ case TC_CLASSOPTIONS:
+ readClassOptions(lexrc);
break;
- }
- case LT_PREAMBLE:
+ case TC_PREAMBLE:
preamble_ = lexrc.getLongString("EndPreamble");
break;
- case LT_PROVIDESAMSMATH:
+ case TC_PROVIDESAMSMATH:
if (lexrc.next() && lexrc.GetInteger())
provides_ |= amsmath;
break;
- case LT_PROVIDESMAKEIDX:
+ case TC_PROVIDESMAKEIDX:
if (lexrc.next() && lexrc.GetInteger())
provides_ |= makeidx;
break;
- case LT_PROVIDESURL:
+ case TC_PROVIDESURL:
if (lexrc.next() && lexrc.GetInteger())
provides_ = url;
break;
- case LT_LEFTMARGIN: // left margin type
+ case TC_LEFTMARGIN: // left margin type
if (lexrc.next())
leftmargin_ = lexrc.GetString();
break;
- case LT_RIGHTMARGIN: // right margin type
+ case TC_RIGHTMARGIN: // right margin type
if (lexrc.next())
rightmargin_ = lexrc.GetString();
break;
-
- default:
- lexrc.printError("Out of context tag `$$Token'");
- break;
}
}
return error;
}
+enum OutputTypeTags {
+ OT_OTLATEX = 1,
+ OT_OTLINUXDOC,
+ OT_OTDOCBOOK,
+ OT_OTLITERATE
+};
+
+static keyword_item outputTypeTags[] = {
+ { "docbook", OT_OTDOCBOOK },
+ { "latex", OT_OTLATEX },
+ { "linuxdoc", OT_OTLINUXDOC },
+ { "literate", OT_OTLITERATE }
+};
+
+void LyXTextClass::readOutputType(LyXLex & lexrc)
+{
+ pushpophelper pph(lexrc, outputTypeTags, OT_OTLITERATE);
+ int le = lexrc.lex();
+ switch(le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown output type `$$Token'");
+ return; break;
+ default: break;
+ }
+ switch(static_cast<OutputTypeTags>(le)) {
+ case OT_OTLATEX:
+ outputType_ = LATEX;
+ break;
+ case OT_OTLINUXDOC:
+ outputType_ = LINUXDOC;
+ break;
+ case OT_OTDOCBOOK:
+ outputType_ = DOCBOOK;
+ break;
+ case OT_OTLITERATE:
+ outputType_ = LITERATE;
+ break;
+ }
+}
+
+enum MaxCounterTags {
+ MC_COUNTER_CHAPTER = 1,
+ MC_COUNTER_SECTION,
+ MC_COUNTER_SUBSECTION,
+ MC_COUNTER_SUBSUBSECTION,
+ MC_COUNTER_PARAGRAPH,
+ MC_COUNTER_SUBPARAGRAPH,
+ MC_COUNTER_ENUMI,
+ MC_COUNTER_ENUMII,
+ MC_COUNTER_ENUMIII,
+ MC_COUNTER_ENUMIV
+};
+
+static keyword_item maxCounterTags[] = {
+ {"counter_chapter", MC_COUNTER_CHAPTER },
+ {"counter_enumi", MC_COUNTER_ENUMI },
+ {"counter_enumii", MC_COUNTER_ENUMII },
+ {"counter_enumiii", MC_COUNTER_ENUMIII },
+ {"counter_enumiv", MC_COUNTER_ENUMIV },
+ {"counter_paragraph", MC_COUNTER_PARAGRAPH },
+ {"counter_section", MC_COUNTER_SECTION },
+ {"counter_subparagraph", MC_COUNTER_SUBPARAGRAPH },
+ {"counter_subsection", MC_COUNTER_SUBSECTION },
+ {"counter_subsubsection", MC_COUNTER_SUBSUBSECTION }
+};
+
+void LyXTextClass::readMaxCounter(LyXLex & lexrc)
+{
+ pushpophelper pph(lexrc, maxCounterTags, MC_COUNTER_ENUMIV);
+ int le = lexrc.lex();
+ switch(le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown MaxCounter tag `$$Token'");
+ return; break;
+ default: break;
+ }
+ switch (static_cast<MaxCounterTags>(le)) {
+ case MC_COUNTER_CHAPTER:
+ maxcounter_ = LABEL_COUNTER_CHAPTER;
+ break;
+ case MC_COUNTER_SECTION:
+ maxcounter_ = LABEL_COUNTER_SECTION;
+ break;
+ case MC_COUNTER_SUBSECTION:
+ maxcounter_ = LABEL_COUNTER_SUBSECTION;
+ break;
+ case MC_COUNTER_SUBSUBSECTION:
+ maxcounter_ = LABEL_COUNTER_SUBSUBSECTION;
+ break;
+ case MC_COUNTER_PARAGRAPH:
+ maxcounter_ = LABEL_COUNTER_PARAGRAPH;
+ break;
+ case MC_COUNTER_SUBPARAGRAPH:
+ maxcounter_ = LABEL_COUNTER_SUBPARAGRAPH;
+ break;
+ case MC_COUNTER_ENUMI:
+ maxcounter_ = LABEL_COUNTER_ENUMI;
+ break;
+ case MC_COUNTER_ENUMII:
+ maxcounter_ = LABEL_COUNTER_ENUMII;
+ break;
+ case MC_COUNTER_ENUMIII:
+ maxcounter_ = LABEL_COUNTER_ENUMIII;
+ break;
+ case MC_COUNTER_ENUMIV:
+ maxcounter_ = LABEL_COUNTER_ENUMIV;
+ break;
+ }
+}
+
+enum ClassOptionsTags {
+ CO_FONTSIZE = 1,
+ CO_PAGESTYLE,
+ CO_OTHER,
+ CO_END
+};
+
+static keyword_item classOptionsTags[] = {
+ {"end", CO_END },
+ {"fontsize", CO_FONTSIZE },
+ {"other", CO_OTHER },
+ {"pagestyle", CO_PAGESTYLE }
+};
+
+void LyXTextClass::readClassOptions(LyXLex & lexrc)
+{
+ lexrc.pushTable(classOptionsTags, CO_END);
+ bool getout = false;
+ while (!getout && lexrc.IsOK()) {
+ int le = lexrc.lex();
+ switch (le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown ClassOption tag `$$Token'");
+ continue; break;
+ default: break;
+ }
+ switch (static_cast<ClassOptionsTags>(le)) {
+ case CO_FONTSIZE:
+ lexrc.next();
+ opt_fontsize_ = strip(lexrc.GetString());
+ break;
+ case CO_PAGESTYLE:
+ lexrc.next();
+ opt_pagestyle_ = strip(lexrc.GetString());
+ break;
+ case CO_OTHER:
+ lexrc.next();
+ options_ = lexrc.GetString();
+ break;
+ case CO_END:
+ getout = true;
+ break;
+ }
+ }
+ lexrc.popTable();
+}
+
bool LyXTextClass::hasLayout(string const & name) const
{
if (!lex.IsOK()) {
lyxerr << "LyXTextClassList::Read: unable to open "
"textclass file `" << MakeDisplayPath(real_file, 1000)
- << "\'\nCheck your installation. LyX can't continue."
+ << "'\nCheck your installation. LyX can't continue."
<< endl;
return false;
}
///
bool Read (LyXLex &, LyXTextClass const &);
-
+ void readAlign(LyXLex &);
+ void readAlignPossible(LyXLex &);
+ void readLabelType(LyXLex &);
+ void readMargin(LyXLex &);
+ void readLatexType(LyXLex &);
+ void readSpacing(LyXLex &);
string const & name() const { return name_; }
void name(string const & n) { name_ = n; }
string const & obsoleted_by() const { return obsoleted_by_; }
///
bool Read(string const & filename, bool merge = false);
-
+ void readOutputType(LyXLex &);
+ void readMaxCounter(LyXLex &);
+ void readClassOptions(LyXLex &);
///
bool hasLayout(string const & name) const;
AddName(system_lyxdir, "configure"));
p.pop();
minibuffer->Set(_("Reloading configuration..."));
- lyxrc->Read(LibFileSearch(string(), "lyxrc.defaults"));
+ lyxrc->read(LibFileSearch(string(), "lyxrc.defaults"));
WriteAlert(_("The system has been reconfigured."),
_("You need to restart LyX to make use of any"),
_("updated document class specifications."));
lyxrc->ReadBindFile();
if (lyxerr.debugging(Debug::LYXRC)) {
- lyxrc->Print();
+ lyxrc->print();
}
// Create temp directory
if (!lyxrc_path.empty()){
lyxerr[Debug::INIT] << "Found " << name
<< " in " << lyxrc_path << endl;
- if (lyxrc->Read(lyxrc_path) < 0) {
+ if (lyxrc->read(lyxrc_path) < 0) {
WriteAlert(_("LyX Warning!"),
_("Error while reading ")+lyxrc_path+".",
_("Using built-in defaults."));
// Set debugging level and report result to user
-void setDebuggingLevel(string const &dbgLevel)
+void setDebuggingLevel(string const & dbgLevel)
{
lyxerr << _("Setting debug level to ") << dbgLevel << endl;
lyxerr.level(Debug::value(dbgLevel));
lyxerr[Debug::INFO] << "Debugging INFO #" << Debug::INFO << endl;
lyxerr[Debug::INIT] << "Debugging INIT #" << Debug::INIT << endl;
- lyxerr[Debug::KEY] << "Debugging KEY #" << Debug::KEY << endl;
+ lyxerr[Debug::KEY] << "Debugging KEY #" << Debug::KEY << endl;
lyxerr[Debug::TOOLBAR] << "Debugging TOOLBAR #" << Debug::TOOLBAR << endl;
lyxerr[Debug::PARSER] << "Debugging LEX and PARSER #" << Debug::PARSER << endl;
lyxerr[Debug::LYXRC] << "Debugging LYXRC #" << Debug::LYXRC << endl;
error = true;
}
}
- return *this;
+ return * this;
}
extern int current_layout;
extern int getISOCodeFromLaTeX(char *);
-extern int UnlockInset(UpdatableInset*);
+extern int UnlockInset(UpdatableInset *);
extern void ShowLatexLog();
-extern void UpdateInset(Inset* inset, bool mark_dirty = true);
+extern void UpdateInset(Inset * inset, bool mark_dirty = true);
/* === globals =========================================================== */
break;
}
if (disable)
- flag = func_status(flag | LyXFunc::Disabled);
+ flag |= LyXFunc::Disabled;
func_status box = LyXFunc::ToggleOff;
// LyXFont font = buf->text->real_current_font;
}
break;
+ case LFUN_SAVEPREFERENCES:
+ {
+ Path p(user_lyxdir);
+ lyxrc->write("preferences");
+ }
+ break;
+
case LFUN_UNKNOWN_ACTION:
{
if (owner->buffer()->isReadonly()) {
void LyXLex::printTable()
{
lyxerr << "\nNumber of tags: " << no_items << endl;
- for(int i= 0; i<no_items; i++)
+ for(int i= 0; i < no_items; ++i)
lyxerr << "table[" << i
<< "]: tag: `" << table[i].tag
<< "' code:" << table[i].code << endl;
}
-void LyXLex::printError(string const & message)
+void LyXLex::printError(string const & message) const
{
string tmpmsg = subst(message, "$$Token", GetString());
lyxerr << "LyX: " << tmpmsg << " [around line " << lineno
bool LyXLex::setFile(string const & filename)
{
- if (file)
+ if (file)
lyxerr << "Error in LyXLex::setFile: file already set." <<endl;
file = fopen(filename.c_str(), "r");
name = filename;
void LyXLex::setFile(FILE * f)
{
if (file)
- lyxerr << "Error in LyXLex::setFile: file already set." << endl;
+ lyxerr << "Error in LyXLex::setFile: file already set."
+ << endl;
file = f;
owns_file = false;
lineno = 0; // this is bogus if the file already has been read from
}
-int LyXLex::GetInteger()
+int LyXLex::GetInteger() const
{
- if (buff[0]>' ')
+ if (buff[0] > ' ')
return atoi(buff);
else {
printError("Bad integer `$$Token'");
}
-float LyXLex::GetFloat()
+float LyXLex::GetFloat() const
{
- if (buff[0]>' ')
- return (float)strtod(buff, (char**)0);
+ if (buff[0] > ' ')
+ return atof(buff);
else {
printError("Bad float `$$Token'");
return -1;
}
-bool LyXLex::GetBool()
+bool LyXLex::GetBool() const
{
if (compare(buff, "true") == 0)
return true;
bool LyXLex::EatLine()
{
- int i= 0;
+ int i = 0;
int c = '\0'; // getc() returns an int
while (!feof(file) && c!= '\n' && i!= (LEX_MAX_BUFF-1)) {
int LyXLex::search_kw(char const * const tag) const
{
- int m, k= 0 , l= 0, r= no_items;
+ int m, k = 0 , l = 0, r = no_items;
while (l < r) {
- m = (l+r)/2;
+ m = (l + r) / 2;
if (lyxerr.debugging(Debug::PARSER)) {
lyxerr << "LyXLex::search_kw: elem " << m
if (k == 0)
return table[m].code;
else
- if (k<0) l = m+1; else r = m;
+ if (k < 0) l = m + 1; else r = m;
}
- return -1;
+ return LEX_UNDEF;
}
bool LyXLex::next(bool esc)
{
-
if (!esc) {
int c; // getc() returns an int
- //int i;
-
status = 0;
while (!feof(file) && !status) {
return false;
} else {
int c; // getc() returns an int
- //int i;
-
status = 0;
while (!feof(file) && !status) {
bool LyXLex::nextToken()
{
- int c; // getc() returns an int
- int i;
-
status = 0;
while (!feof(file) && !status) {
- c = getc(file);
+ int c = getc(file); // getc() returns an int
if (c >= ' ' && !feof(file)) {
- i = 0;
+ int i = 0;
if (c == '\\') { // first char == '\\'
do {
buff[i++] = c;
int i = -1;
if (compare(buff, "default")) {
- for (i = 0; str[i][0] && compare(str[i], buff); i++);
+ for (i = 0; str[i][0] && compare(str[i], buff); ++i);
if (!str[i][0]) {
if (print_error)
printError("Unknown argument `$$Token'");
// texclass and others to come. [asierra30/03/96]
//
// (C) 1996 Lyx Team.
-#ifndef _LYXLEX_H
-#define _LYXLEX_H
+#ifndef LYXLEX_H
+#define LYXLEX_H
#ifdef __GNUG__
#pragma interface
#endif
-#include <stdio.h>
+#include <cstdio>
#include "LString.h"
///
struct keyword_item {
///
- char const* tag;
+ char const * tag;
///
short code;
};
class LyXLex {
public:
///
- LyXLex (keyword_item*, int);
+ LyXLex (keyword_item *, int);
///
~LyXLex() { if (file && owns_file) fclose(file); };
};
/// file is open and end of file is not reached
- bool IsOK();
+ bool IsOK() const;
/// return true if able to open file, else false
bool setFile(string const & filename);
/// if file is already read from, line numbers will be wrong.
// should be removed
- void setFile(FILE *f);
+ void setFile(FILE * f);
///
// should be removed
- FILE *getFile() { return file; }
+ FILE * getFile() { return file; }
/// Danger! Don't use it unless you know what you are doing.
void setLineNo(int l) { lineno = l; }
/// returns a lex code
bool nextToken();
///
- int GetLineNo() { return lineno; }
+ int GetLineNo() const { return lineno; }
///
- int GetInteger();
+ int GetInteger() const;
///
- bool GetBool();
+ bool GetBool() const;
///
- float GetFloat();
+ float GetFloat() const;
///
string GetString() const;
/// get a long string, ended by the tag `endtag'
- string getLongString(string const &endtoken);
+ string getLongString(string const & endtoken);
///
bool EatLine();
///
- int FindToken(char const* string[]);
+ int FindToken(char const * string[]);
///
- int CheckToken(char const* string[], int print_error);
+ int CheckToken(char const * string[], int print_error);
///
- char const *text() const { return &buff[0]; }
+ char const * text() const { return &buff[0]; }
/** Pushes a token list on a stack and replaces it with a new one.
*/
- void pushTable(keyword_item*, int);
+ void pushTable(keyword_item *, int);
/** Pops a token list into void and replaces it with the one now
on top of the stack.
and file name. If message contains the substring `$$Token',
it is replaced with the value of GetString()
*/
- void printError(string const & message);
+ void printError(string const & message) const;
/**
Prints the current token table on cerr.
protected:
///
enum {
- ///
+ ///
LEX_MAX_BUFF = 2048
};
table_elem= 0;
}
///
- pushed_table *next;
+ pushed_table * next;
///
- keyword_item *table_elem;
+ keyword_item * table_elem;
///
int table_siz;
};
///
- FILE *file;
+ FILE * file;
///
bool owns_file;
///
///
int lineno;
///
- keyword_item *table;
+ keyword_item * table;
///
int no_items;
///
char buff[LEX_MAX_BUFF];
///
- pushed_table *pushed;
+ pushed_table * pushed;
///
int search_kw(char const * const) const;
///
inline
-bool LyXLex::IsOK()
+bool LyXLex::IsOK() const
{
return (file && !feof(file));
}
+// This is needed to ensure that the pop is done upon exit from methods
+// with more than one exit point or that can return as a response to
+// exceptions. (Lgb)
+struct pushpophelper {
+ pushpophelper(LyXLex & lexrc, keyword_item * i, int s) : lex(lexrc) {
+ lex.pushTable(i, s);
+ }
+ ~pushpophelper() {
+ lex.popTable();
+ }
+ LyXLex & lex;
+};
+
#endif
#pragma implementation "lyxrc.h"
#endif
+#include <fstream>
+#include <iomanip>
+
#include "debug.h"
#include "lyxrc.h"
extern string background_color;
extern char selection_color[];
extern bool cursor_follows_scrollbar;
-extern kb_keymap *toplevel_keymap;
+extern kb_keymap * toplevel_keymap;
extern LyXAction lyxaction;
-enum _LyXRCTags {
+enum LyXRCTags {
RC_BEGINTOOLBAR = 1,
RC_FONT_ENCODING,
RC_PRINTER,
// Should this be moved inside LyXAction?
static inline
-int bindKey(char const* seq, int action)
+int bindKey(char const * seq, int action)
{
return toplevel_keymap->bind(seq, action);
}
hasBindFile = true;
string tmp = i18nLibFileSearch("bind", name, "bind");
lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
- int result = Read(tmp);
+ int result = read(tmp);
if (result) {
lyxerr << "Error reading bind file: " << tmp << endl;
}
return result;
}
-int LyXRC::Read(string const &filename)
+int LyXRC::read(string const & filename)
{
// Default bindfile.
string bindFile = "cua";
-
+
LyXLex lexrc(lyxrcTags, lyxrcCount);
if (lyxerr.debugging(Debug::PARSER))
lexrc.printTable();
lexrc.setFile(filename);
if (!lexrc.IsOK()) return -2;
-
+
lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
while (lexrc.IsOK()) {
-
- switch(lexrc.lex()) {
+ // By using two switches we take advantage of the compiler
+ // telling us if we have missed a LyXRCTags element in
+ // the second switch.
+ // Note that this also shows a problem with LyXLex since it
+ // helps us avoid taking advantage of the strictness of the
+ // compiler.
+
+ int le = lexrc.lex();
+ switch(le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown tag `$$Token'");
+ continue; break;
case LyXLex::LEX_FEOF:
- break;
+ continue; break;
+ default: break;
+ }
+ switch (static_cast<LyXRCTags>(le)) {
case RC_INPUT: // Include file
if (lexrc.next()) {
string tmp = LibFileSearch(string(),
lexrc.GetString());
- if (Read(tmp)) {
+ if (read(tmp)) {
lexrc.printError("Error reading "
- "included file: "+tmp);
+ "included file: "+tmp);
}
}
break;
case RC_BINDFILE: // RVDK_PATCH_5
- if (lexrc.next())
+ if (lexrc.next()) {
ReadBindFile(lexrc.GetString());
+ }
break;
-
+
case RC_BEGINTOOLBAR:
// this toolbar should be changed to be a completely
// non gui toolbar. (Lgb)
if (lexrc.next())
use_kbmap = lexrc.GetBool();
break;
-
+
case RC_EXIT_CONFIRMATION:
if (lexrc.next())
exit_confirmation = lexrc.GetBool();
break;
-
+
case RC_DISPLAY_SHORTCUTS:
if (lexrc.next())
display_shortcuts = lexrc.GetBool();
break;
-
+
case RC_KBMAP_PRIMARY:
if (lexrc.next())
primary_kbmap = lexrc.GetString();
break;
-
+
case RC_KBMAP_SECONDARY:
if (lexrc.next())
secondary_kbmap = lexrc.GetString();
break;
-
+
case RC_FONT_ENCODING:
if (lexrc.next())
fontenc = lexrc.GetString();
if (lexrc.next())
print_pagerange_flag = lexrc.GetString();
break;
-
+
case RC_PRINTCOPIESFLAG:
if (lexrc.next())
print_copies_flag = lexrc.GetString();
break;
-
+
case RC_PRINTCOLLCOPIESFLAG:
if (lexrc.next())
print_collcopies_flag = lexrc.GetString();
if (lexrc.next())
print_spool_printerprefix = lexrc.GetString();
break;
-
+
case RC_PRINTPAPERDIMENSIONFLAG:
if (lexrc.next())
print_paper_dimension_flag = lexrc.GetString();
break;
-
+
case RC_PRINTPAPERFLAG:
if (lexrc.next())
print_paper_flag = lexrc.GetString();
if (lexrc.next())
custom_export_command = lexrc.GetString();
break;
-
+
case RC_CUSTOM_EXPORT_FORMAT:
if (lexrc.next())
custom_export_format = lexrc.GetString();
if (lexrc.next())
latex_command = lexrc.GetString();
break;
-
+
case RC_LITERATE_COMMAND:
if (lexrc.next())
literate_command = lexrc.GetString();
break;
-
+
case RC_LITERATE_EXTENSION:
if (lexrc.next())
literate_extension = lexrc.GetString();
break;
-
+
case RC_LITERATE_ERROR_FILTER:
if (lexrc.next())
literate_error_filter = lexrc.GetString();
break;
-
+
case RC_BUILD_COMMAND:
if (lexrc.next())
build_command = lexrc.GetString();
break;
-
+
case RC_BUILD_ERROR_FILTER:
if (lexrc.next())
build_error_filter = lexrc.GetString();
- break;
-
+ break;
+
case RC_RELYX_COMMAND:
if (lexrc.next())
relyx_command = lexrc.GetString();
break;
-
+
case RC_DEFAULT_PAPERSIZE:
if (lexrc.next()) {
string size = lowercase(lexrc.GetString());
if (size == "usletter")
- default_papersize = BufferParams::PAPER_USLETTER;
+ default_papersize =
+ BufferParams::PAPER_USLETTER;
else if (size == "legal")
- default_papersize = BufferParams::PAPER_LEGALPAPER;
+ default_papersize =
+ BufferParams::PAPER_LEGALPAPER;
else if (size == "executive")
- default_papersize = BufferParams::PAPER_EXECUTIVEPAPER;
+ default_papersize =
+ BufferParams::PAPER_EXECUTIVEPAPER;
else if (size == "a3")
- default_papersize = BufferParams::PAPER_A3PAPER;
+ default_papersize =
+ BufferParams::PAPER_A3PAPER;
else if (size == "a4")
- default_papersize = BufferParams::PAPER_A4PAPER;
+ default_papersize =
+ BufferParams::PAPER_A4PAPER;
else if (size == "a5")
- default_papersize = BufferParams::PAPER_A5PAPER;
+ default_papersize =
+ BufferParams::PAPER_A5PAPER;
else if (size == "b5")
- default_papersize = BufferParams::PAPER_B5PAPER;
+ default_papersize =
+ BufferParams::PAPER_B5PAPER;
}
break;
case RC_VIEWDVI_COMMAND:
if (lexrc.next())
view_dvi_command = lexrc.GetString();
break;
-
+
case RC_PS_COMMAND:
if (lexrc.next())
ps_command = lexrc.GetString();
break;
-
+
case RC_VIEWPS_COMMAND:
if (lexrc.next())
view_ps_command = lexrc.GetString();
break;
-
+
case RC_VIEWPSPIC_COMMAND:
if (lexrc.next())
view_pspic_command = lexrc.GetString();
break;
-
+
case RC_CHKTEX_COMMAND:
if (lexrc.next())
chktex_command = lexrc.GetString();
break;
-
+
case RC_HTML_COMMAND:
if (lexrc.next())
html_command = lexrc.GetString();
break;
-
+
case RC_SCREEN_DPI:
if (lexrc.next())
dpi = lexrc.GetInteger();
break;
-
+
case RC_SCREEN_ZOOM:
if (lexrc.next())
zoom = lexrc.GetInteger();
break;
-
+
case RC_SCREEN_FONT_SIZES:
if (lexrc.next())
font_sizes[LyXFont::SIZE_TINY] =
font_sizes[LyXFont::SIZE_HUGER] =
lexrc.GetFloat();
break;
-
+
case RC_SCREEN_FONT_SCALABLE:
if (lexrc.next())
use_scalable_fonts = lexrc.GetBool();
break;
-
+
case RC_AUTOSAVE:
if (lexrc.next())
autosave = lexrc.GetInteger();
if (lexrc.next())
sgml_extra_options = lexrc.GetString();
break;
-
+
case RC_DOCUMENTPATH:
if (lexrc.next()) {
document_path = ExpandPath(lexrc.GetString());
}
break;
-
+
case RC_TEMPLATEPATH:
if (lexrc.next())
template_path = ExpandPath(lexrc.GetString());
break;
-
+
case RC_TEMPDIRPATH:
if (lexrc.next())
tempdir_path = ExpandPath(lexrc.GetString());
if (lexrc.next())
use_tempdir = lexrc.GetBool();
break;
-
+
case RC_LASTFILES:
if (lexrc.next())
lastfiles = ExpandPath(lexrc.GetString());
break;
-
+
case RC_NUMLASTFILES:
if (lexrc.next())
num_lastfiles = lexrc.GetInteger();
break;
-
+
case RC_CHECKLASTFILES:
if (lexrc.next())
check_lastfiles = lexrc.GetBool();
break;
-
+
case RC_SCREEN_FONT_ROMAN:
if (lexrc.next())
roman_font_name = lexrc.GetString();
break;
-
+
case RC_SCREEN_FONT_SANS:
if (lexrc.next())
sans_font_name = lexrc.GetString();
break;
-
+
case RC_SCREEN_FONT_TYPEWRITER:
if (lexrc.next())
typewriter_font_name = lexrc.GetString();
// the default bind file.
if (!hasBindFile)
ReadBindFile();
-
+
// !!!chb, dynamic key binding...
int action, res = 0;
string seq, cmd;
-
+
if (lexrc.lex() == LyXLex::LEX_DATA) {
seq = lexrc.GetString();
} else {
lexrc.printError("Bad key sequence: `$$Token'");
break;
}
-
+
if (lexrc.lex() == LyXLex::LEX_DATA) {
cmd = lexrc.GetString();
} else {
lexrc.printError("Bad command: `$$Token'");
break;
}
-
+
if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
if (lyxerr.debugging(Debug::KEY)) {
lyxerr << "RC_BIND: Sequence `"
res = bindKey(seq.c_str(), action);
if (res != 0) {
lexrc.printError(
- "Invalid key sequence `"
- + seq + '\'');
+ "Invalid key sequence `"
+ + seq + '\'');
}
} else {// cmd is the last token read.
lexrc.printError(
- "Unknown LyX function `$$Token'");
+ "Unknown LyX function `$$Token'");
}
break;
}
break;
case RC_ASCIIROFF_COMMAND:
if (lexrc.next())
- ascii_roff_command = lexrc.GetString();
+ ascii_roff_command = lexrc.GetString();
break;
case RC_ASCII_LINELEN:
if (lexrc.next())
- ascii_linelen = lexrc.GetInteger();
+ ascii_linelen = lexrc.GetInteger();
break;
- // Spellchecker settings:
+ // Spellchecker settings:
case RC_SPELL_COMMAND:
if (lexrc.next())
isp_command = lexrc.GetString();
if (lexrc.next())
isp_esc_chars = lexrc.GetString();
break;
-
- default:
- lexrc.printError("Unknown tag `$$Token'");
- break;
+ case RC_LAST: break; // this is just a dummy
}
}
}
-void LyXRC::Print()
+void LyXRC::write(string const & filename) const
{
- lyxerr << "The current internal LyXRC:" << endl;
+ ofstream ofs(filename.c_str());
+ if (ofs)
+ output(ofs);
+}
+
+
+void LyXRC::print() const
+{
+ if (lyxerr.debugging())
+ output(lyxerr);
+ else
+ output(cout);
+}
+
+
+void LyXRC::output(ostream & os) const
+{
+ os << "### This file is part of\n"
+ << "### ========================================================\n"
+ << "### LyX, The Document Processor\n"
+ << "###\n"
+ << "### Copyright 1995 Matthias Ettrich\n"
+ << "### Copyright 1995-1998 The LyX Team.\n"
+ << "###\n"
+ << "### ========================================================\n"
+ << "\n"
+ << "# This file is written by LyX, if you want to make your own\n"
+ << "# modifications you should do them from inside LyX and save\n"
+ << "# your preferences, or you can also make your modifications\n"
+ << "# to lyxrc by hand. It is not advisable to edit this file.\n"
+ << "\n";
+
+ // Why the switch you might ask. It is a trick to ensure that all
+ // the elements in the LyXRCTags enum is handled. As you can see
+ // there are no breaks at all. So it is just a huge fall-through.
+ // The nice thing is that we will get a warning from the compiler
+ // if we forget an element.
+ LyXRCTags tag = RC_LAST;
+ switch(tag) {
+ case RC_LAST:
+ case RC_INPUT:
+ // input/include files are not done here
+ case RC_BIND:
+ // bindings is not written to the preferences file.
+ case RC_BINDFILE:
+ // bind files are not done here.
+ case RC_BEGINTOOLBAR:
+ // Toolbar is not written here (yet).
+ case RC_FONT_ENCODING:
+ os << "\\font_encoding \"" << fontenc << "\"\n";
+ case RC_PRINTER:
+ os << "\\printer \"" << printer << "\"\n";
+ case RC_PRINT_COMMAND:
+ os << "\\print_command \"" << print_command << "\"\n";
+ case RC_PRINTEVENPAGEFLAG:
+ os << "\\print_evenpage_flag \"" << print_evenpage_flag
+ << "\"\n";
+ case RC_PRINTODDPAGEFLAG:
+ os << "\\print_oddpage_flag \"" << print_oddpage_flag
+ << "\"\n";
+ case RC_PRINTPAGERANGEFLAG:
+ os << "\\print_pagerange_flag \"" << print_pagerange_flag
+ << "\"\n";
+ case RC_PRINTCOPIESFLAG:
+ os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
+ case RC_PRINTCOLLCOPIESFLAG:
+ os << "\\print_collcopies_flag \"" << print_collcopies_flag
+ << "\"\n";
+ case RC_PRINTREVERSEFLAG:
+ os << "\\print_reverse_flag \"" << print_reverse_flag
+ << "\"\n";
+ case RC_PRINTLANDSCAPEFLAG:
+ os << "\\print_landscape_flag \"" << print_landscape_flag
+ << "\"\n";
+ case RC_PRINTTOPRINTER:
+ os << "\\print_to_printer \"" << print_to_printer << "\"\n";
+ case RC_PRINT_ADAPTOUTPUT:
+ os << "\\print_adapt_output " << tostr(print_adapt_output)
+ << "\n";
+ case RC_PRINTTOFILE:
+ os << "\\print_to_file \"" << print_to_file << "\"\n";
+ case RC_PRINTFILEEXTENSION:
+ os << "\\print_file_extension \"" << print_file_extension
+ << "\"\n";
+ case RC_PRINTEXSTRAOPTIONS:
+ os << "\\print_extra_options \"" << print_extra_options
+ << "\"\n";
+ case RC_PRINTSPOOL_COMMAND:
+ os << "\\print_spool_command \"" << print_spool_command
+ << "\"\n";
+ case RC_PRINTSPOOL_PRINTERPREFIX:
+ os << "\\print_spool_printerprefix \""
+ << print_spool_printerprefix << "\"\n";
+ case RC_PRINTPAPERDIMENSIONFLAG:
+ os << "\\print_paper_dimension_flag \""
+ << print_paper_dimension_flag << "\"\n";
+ case RC_PRINTPAPERFLAG:
+ os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
+ case RC_CUSTOM_EXPORT_COMMAND:
+ os << "\\custom_export_command \"" << custom_export_command
+ << "\"\n";
+ case RC_CUSTOM_EXPORT_FORMAT:
+ os << "\\custom_export_format \"" << custom_export_format
+ << "\"\n";
+ case RC_LATEX_COMMAND:
+ os << "\\latex_command \"" << latex_command << "\"\n";
+ case RC_LITERATE_COMMAND:
+ os << "\\literate_command \"" << literate_command << "\"\n";
+ case RC_LITERATE_EXTENSION:
+ os << "\\literate_extension \"" << literate_extension
+ << "\"\n";
+ case RC_LITERATE_ERROR_FILTER:
+ os << "\\literate_error_filter \"" << literate_error_filter
+ << "\"\n";
+ case RC_BUILD_COMMAND:
+ os << "\\build_command \"" << build_command << "\"\n";
+ case RC_BUILD_ERROR_FILTER:
+ os << "\\build_error_filter \"" << build_error_filter
+ << "\"\n";
+ case RC_SCREEN_DPI:
+ os << "\\screen_dpi " << dpi << "\n";
+ case RC_SCREEN_ZOOM:
+ os << "\\screen_zoom " << zoom << "\n";
+ case RC_SCREEN_FONT_SIZES:
+ os.setf(ios::fixed);
+ os.precision(2);
+ os << "\\screen_font_sizes";
+ os << " " << font_sizes[LyXFont::SIZE_TINY];
+ os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
+ os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
+ os << " " << font_sizes[LyXFont::SIZE_SMALL];
+ os << " " << font_sizes[LyXFont::SIZE_NORMAL];
+ os << " " << font_sizes[LyXFont::SIZE_LARGE];
+ os << " " << font_sizes[LyXFont::SIZE_LARGER];
+ os << " " << font_sizes[LyXFont::SIZE_LARGEST];
+ os << " " << font_sizes[LyXFont::SIZE_HUGE];
+ os << " " << font_sizes[LyXFont::SIZE_HUGER];
+ os << "\n";
+ case RC_AUTOREGIONDELETE:
+ os << "\\auto_region_delete " << tostr(auto_region_delete)
+ << "\n";
+ case RC_AUTOSAVE:
+ os << "\\autosave " << autosave << "\n";
+ case RC_EXIT_CONFIRMATION:
+ os << "\\exit_confirmation " << tostr(exit_confirmation)
+ << "\n";
+ case RC_DISPLAY_SHORTCUTS:
+ os << "\\display_shortcuts " << tostr(display_shortcuts)
+ << "\n";
+ case RC_VIEWDVI_COMMAND:
+ os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
+ case RC_DEFAULT_PAPERSIZE:
+ os << "\\default_papersize \"";
+ switch (default_papersize) {
+ case BufferParams::PAPER_USLETTER:
+ os << "usletter"; break;
+ case BufferParams::PAPER_LEGALPAPER:
+ os << "legal"; break;
+ case BufferParams::PAPER_EXECUTIVEPAPER:
+ os << "executive"; break;
+ case BufferParams::PAPER_A3PAPER:
+ os << "a3"; break;
+ case BufferParams::PAPER_A4PAPER:
+ os << "a4"; break;
+ case BufferParams::PAPER_A5PAPER:
+ os << "a5"; break;
+ case BufferParams::PAPER_B5PAPER:
+ os << "b5"; break;
+ case BufferParams::PAPER_DEFAULT: break;
+ }
+ os << "\"\n";
+ case RC_VIEWPS_COMMAND:
+ os << "\\view_ps_command \"" << view_ps_command << "\"\n";
+ case RC_VIEWPSPIC_COMMAND:
+ os << "\\view_pspic_command \"" << view_pspic_command
+ << "\"\n";
+ case RC_PS_COMMAND:
+ os << "\\ps_command \"" << ps_command << "\"\n";
+ case RC_CHKTEX_COMMAND:
+ os << "\\chktex_command \"" << chktex_command << "\"\n";
+ case RC_HTML_COMMAND:
+ os << "\\html_command \"" << html_command << "\"\n";
+ case RC_SGML_EXTRA_OPTIONS:
+ os << "\\sgml_extra_options \"" << sgml_extra_options
+ << "\"\n";
+ case RC_KBMAP:
+ os << "\\kbmap " << tostr(use_kbmap) << "\n";
+ case RC_KBMAP_PRIMARY:
+ os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
+ case RC_KBMAP_SECONDARY:
+ os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
+ case RC_SERVERPIPE:
+ os << "\\serverpipe \"" << lyxpipes << "\"\n";
+ case RC_RELYX_COMMAND:
+ os << "\\relyx_command \"" << relyx_command << "\"\n";
+ case RC_DOCUMENTPATH:
+ os << "\\document_path \"" << document_path << "\"\n";
+ case RC_TEMPLATEPATH:
+ os << "\\template_path \"" << template_path << "\"\n";
+ case RC_TEMPDIRPATH:
+ os << "\\tempdir_path \"" << tempdir_path << "\"\n";
+ case RC_USETEMPDIR:
+ os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
+ case RC_LASTFILES:
+ os << "\\lastfiles \"" << lastfiles << "\"\n";
+ case RC_NUMLASTFILES:
+ os << "\\num_lastfiles " << num_lastfiles << "\n";
+ case RC_CHECKLASTFILES:
+ os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
+ case RC_SCREEN_FONT_ROMAN:
+ os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
+ case RC_SCREEN_FONT_SANS:
+ os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
+ case RC_SCREEN_FONT_TYPEWRITER:
+ os << "\\screen_font_typewriter \""
+ << typewriter_font_name << "\"\n";
+ case RC_SCREEN_FONT_MENU:
+ os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
+ case RC_SCREEN_FONT_POPUP:
+ os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
+ case RC_SCREEN_FONT_ENCODING:
+ os << "\\screen_font_encoding \"" << font_norm << "\"\n";
+ case RC_SCREEN_FONT_SCALABLE:
+ os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
+ << "\n";
+ case RC_CURSOR_FOLLOWS_SCROLLBAR:
+ os << "\\cursor_follows_scrollbar "
+ << tostr(cursor_follows_scrollbar) << "\n";
+ case RC_FAST_SELECTION:
+ os << "\\fast_selection "
+ << tostr(static_cast<bool>(fast_selection)) << "\n";
+ case RC_BACKGROUND_COLOR:
+ os << "\\background_color \"" << background_color << "\"\n";
+ case RC_SELECTION_COLOR:
+ os << "\\selection_color \"" << selection_color << "\"\n";
+ case RC_FAX_COMMAND:
+ os << "\\fax_command \"" << fax_command << "\"\n";
+ case RC_FAXPROGRAM:
+ os << "\\fax_program \"" << fax_program << "\"\n";
+ case RC_PHONEBOOK:
+ os << "\\phone_book \"" << phone_book << "\"\n";
+ case RC_ASCIIROFF_COMMAND:
+ os << "\\ascii_roff_command \"" << ascii_roff_command
+ << "\"\n";
+ case RC_ASCII_LINELEN:
+ os << "\\ascii_linelen " << ascii_linelen << "\n";
+ case RC_SPELL_COMMAND:
+ os << "\\spell_command \"" << isp_command << "\"\n";
+ case RC_ACCEPT_COMPOUND:
+ os << "\\accept_compound " << tostr(isp_accept_compound)
+ << "\n";
+ case RC_USE_INP_ENC:
+ os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
+ << "\n";
+ case RC_USE_ALT_LANG:
+ os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
+ case RC_USE_PERS_DICT:
+ os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
+ << "\n";
+ case RC_USE_ESC_CHARS:
+ os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
+ << "\n";
+ case RC_ALT_LANG:
+ os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
+ case RC_PERS_DICT:
+ os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
+ case RC_ESC_CHARS:
+ os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
+ }
+ os.flush();
}
bindKey("Left", LFUN_LEFT);
bindKey("Up", LFUN_UP);
bindKey("Down", LFUN_DOWN);
-
+
bindKey("Tab", LFUN_TAB);
-
+
bindKey("Home", LFUN_HOME);
bindKey("End", LFUN_END);
bindKey("Prior", LFUN_PRIOR);
bindKey("Next", LFUN_NEXT);
-
+
bindKey("Return", LFUN_BREAKPARAGRAPH);
bindKey("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
-
+
bindKey("Delete", LFUN_DELETE);
bindKey("BackSpace", LFUN_BACKSPACE);
// bindKeyings for transparent handling of deadkeys
bindKey("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
bindKey("~C-~S-~M-dead_tie", LFUN_TIE);
bindKey("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
-
+
// bindings to utilize the use of the numeric keypad
// e.g. Num Lock set
bindKey("KP_0", LFUN_SELFINSERT);
bindKey("KP_Divide", LFUN_SELFINSERT);
bindKey("KP_Multiply", LFUN_SELFINSERT);
bindKey("KP_Subtract", LFUN_SELFINSERT);
-
+
/* Most self-insert keys are handled in the 'default:' section of
* WorkAreaKeyPress - so we don't have to define them all.
* However keys explicit decleared as self-insert are
* handled seperatly (LFUN_SELFINSERT.) Lgb. */
-
+
bindKey("C-Tab", LFUN_TABINSERT); // ale970515
}
///
LyXRC();
///
- int Read (string const & filename);
+ int read (string const & filename);
///
- void Print();
+ void write(string const & filename) const;
+ ///
+ void print() const;
+ ///
+ void output(ostream & os) const;
/// Is a bind file already (or currently) read?
bool hasBindFile;
///
};
///
- LyxArrayBase(int size= ARRAY_STEP);
+ LyxArrayBase(int size = ARRAY_STEP);
///
- LyxArrayBase(const LyxArrayBase&);
+ LyxArrayBase(LyxArrayBase const &);
///
~LyxArrayBase();
///
- int Empty() { return (last == 0); }
+ int empty() const { return (last == 0); }
///
int Last() { return last; }
void Remove(int pos, int dx);
/// Merge dx elements from array a at pos. Changes the size if necessary.
- void Merge(LyxArrayBase *a, int pos, int dx);
+ void Merge(LyxArrayBase * a, int pos, int dx);
/// Same as Merge but doesn't changes the size (dangerous)
- void MergeF(LyxArrayBase *a, int pos, int dx);
+ void MergeF(LyxArrayBase * a, int pos, int dx);
/// Copy dx byts from an array at position pos
void Copy(void *, int pos, int dx);
/// Constructs a new array with dx elements starting at pos
- LyxArrayBase* Extract(int pos, int dx);
+ LyxArrayBase * Extract(int pos, int dx);
/// Insert a character at position pos
void Insert(int pos, byte);
byte operator[](const int);
/// Constructs a new array with dx elements starting at pos
- LyxArrayBase& operator= (const LyxArrayBase&);
+ LyxArrayBase & operator= (LyxArrayBase const &);
protected:
///
bool Move(int p, int shift);
/// Buffer
- byte *bf;
+ byte * bf;
/// Last position inserted.
int last;
/// Max size of the array.
bool limits = false;
xo = x; yo = y;
- if (!array || array->Empty()) {
+ if (!array || array->empty()) {
mathed_set_font(LM_TC_VAR, 1);
if (array) {
MathedXIter data(this);
width = df_width;
descent = 0;
if (!array) return;
- if (array->Empty()) return;
+ if (array->empty()) return;
ascent = 0;
MathedXIter data(this);
descent = ascent = width = 0;
if (!array) return;
- if (array->Empty()) return;
+ if (array->empty()) return;
// if (pos2 > array->last) return;
x1 = x;
while (pos<pos2) {
///
void goPosAbs(int);
///
- int Empty() { return array->last<= 1; }
+ int Empty() { return array->Last()<= 1; }
///
- int OK() { return array && (pos < array->last); }
+ int OK() { return array && (pos < array->Last()); }
///
int IsFirst() { return (pos == 0); }
///
inline
bool MathedIter::IsInset()
{
- return MathIsInset(array->bf[pos]);
+ return MathIsInset((*array)[pos]);
}
inline
bool MathedIter::IsActive()
{
- return MathIsActive(array->bf[pos]);
+ return MathIsActive((*array)[pos]);
}
inline
bool MathedIter::IsFont()
{
- return MathIsFont(array->bf[pos]);
+ return MathIsFont((*array)[pos]);
}
inline
bool MathedIter::IsScript()
{
- return MathIsScript(array->bf[pos]);
+ return MathIsScript((*array)[pos]);
}
inline
bool MathedIter::IsTab()
{
- return (array->bf[pos] == LM_TC_TAB);
+ return ((*array)[pos] == LM_TC_TAB);
}
inline
bool MathedIter::IsCR()
{
- return (array->bf[pos] == LM_TC_CR);
+ return ((*array)[pos] == LM_TC_CR);
}
inline
-MathedIter::MathedIter(LyxArrayBase *d): array(d)
+MathedIter::MathedIter(LyxArrayBase * d): array(d)
{
pos = 0;
row = col = 0;
- fcode = (array && IsFont()) ? array->bf[0]: 0;
+ fcode = (array && IsFont()) ? (*array)[0]: 0;
}
}
-char ** mathed_get_pixmap_from_icon(int d)
+char const ** mathed_get_pixmap_from_icon(int d)
{
switch (d) {
case MM_FRAC: return frac;
/* fill-in form initialization code */
fl_set_button(fd_delim->left, 1);
- fl_set_pixmap_data(fd_delim->pix, delim0);
+ fl_set_pixmap_data(fd_delim->pix, const_cast<char**>(delim0));
fl_set_bmtable_data(fd_delim->menu, 6, 4, delim_width, delim_height,
delim_bits);
fl_set_bmtable_maxitems(fd_delim->menu, 23);
- fl_set_pixmap_data(fd_panel->sqrt, sqrt);
- fl_set_pixmap_data(fd_panel->frac, frac);
- fl_set_pixmap_data(fd_panel->delim, delim);
- fl_set_pixmap_data(fd_panel->deco, deco);
- fl_set_pixmap_data(fd_panel->space, space_xpm);
- fl_set_pixmap_data(fd_panel->matrix, matrix);
- fl_set_pixmap_data(fd_panel->equation, equation);
-
- for (int i= 0; i<32; i++) {
+ fl_set_pixmap_data(fd_panel->sqrt, const_cast<char**>(sqrt));
+ fl_set_pixmap_data(fd_panel->frac, const_cast<char**>(frac));
+ fl_set_pixmap_data(fd_panel->delim, const_cast<char**>(delim));
+ fl_set_pixmap_data(fd_panel->deco, const_cast<char**>(deco));
+ fl_set_pixmap_data(fd_panel->space, const_cast<char**>(space_xpm));
+ fl_set_pixmap_data(fd_panel->matrix, const_cast<char**>(matrix));
+ fl_set_pixmap_data(fd_panel->equation, const_cast<char**>(equation));
+
+ for (int i = 0; i < 32; ++i) {
fl_add_browser_line(fd_panel->func_browse, func_code[i]);
}
~BitmapMenu();
///
FL_OBJECT * AddBitmap(int id,
- int nx, int ny, int bw, int bh,
- unsigned char * data, Bool vert= True); // Why Bool?
+ int nx, int ny, int bw, int bh,
+ unsigned char const * data,
+ Bool vert= True); // Why Bool?
///
void Create();
///
extern void SmallUpdate(signed char);
extern void BeforeChange();
extern void Update(signed char);
-extern int UnlockInset(UpdatableInset*);
+extern int UnlockInset(UpdatableInset *);
extern short greek_kb_flag;
-extern MiniBuffer *minibuffer;
+extern MiniBuffer * minibuffer;
-extern BufferView *current_view;
+extern BufferView * current_view;
/* Bitmaps */
#include "greek.xbm"
#include "dots.xbm"
/* Latex code for those bitmaps */
-static char const *latex_greek[] = {
+static char const * latex_greek[] = {
"Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi",
"Sigma", "Upsilon", "Phi", "Psi", "Omega",
"alpha", "beta", "gamma", "delta", "epsilon", "varepsilon", "zeta",
"tau", "upsilon", "phi", "varphi", "chi", "psi", "omega", ""
};
-static char const *latex_brel[] = {
+static char const * latex_brel[] = {
"leq", "geq", "equiv", "models",
"prec", "succ", "sim", "perp",
"preceq", "succeq", "simeq", "mid",
"vdash", "dashv", "bowtie", ""
};
-static char const* latex_arrow[] = {
+static char const * latex_arrow[] = {
"downarrow", "leftarrow", "Downarrow", "Leftarrow",
"hookleftarrow", "rightarrow", "uparrow", "Rightarrow", "Uparrow",
"hookrightarrow", "updownarrow", "Leftrightarrow", "leftharpoonup",
"nwarrow", "nearrow", "swarrow", "searrow", "",
};
-char const* latex_varsz[] = {
+char const * latex_varsz[] = {
"sum", "int", "oint",
"prod", "coprod", "bigsqcup",
"bigotimes", "bigodot", "bigoplus",
"bigvee", "bigwedge", ""
};
-static char const* latex_bop[] = {
+static char const * latex_bop[] = {
"pm", "cap", "diamond", "oplus",
"mp", "cup", "bigtriangleup", "ominus",
"times", "uplus", "bigtriangledown", "otimes",
"bullet", "wr", "ddagger", ""
};
-static char const* latex_misc[] = {
+static char const * latex_misc[] = {
"nabla", "partial", "infty", "prime", "ell",
"emptyset", "exists", "forall", "imath", "jmath",
"Re", "Im", "aleph", "wp", "hbar",
"diamondsuit", "heartsuit", "clubsuit", "spadesuit", ""
};
-static char const* latex_dots[] = {
+static char const * latex_dots[] = {
"ldots", "cdots", "vdots", "ddots"
};
5, 2, -1, 6, -1, 7, -1, 10, 4, 9, -1
};
-extern char** mathed_get_pixmap_from_icon(int d);
+extern char const ** mathed_get_pixmap_from_icon(int d);
extern "C" void math_cb(FL_OBJECT*, long);
-static char** pixmapFromBitmapData(char const *, int, int);
-void math_insert_symbol(char const* s);
+static char const ** pixmapFromBitmapData(char const *, int, int);
+void math_insert_symbol(char const * s);
Bool math_insert_greek(char const c);
-BitmapMenu *BitmapMenu::active = 0;
+BitmapMenu * BitmapMenu::active = 0;
-BitmapMenu::BitmapMenu(int n, FL_OBJECT* bt, BitmapMenu* prevx): nb(n) {
+BitmapMenu::BitmapMenu(int n, FL_OBJECT * bt, BitmapMenu * prevx): nb(n)
+{
w = h = 0;
form = 0;
i = 0;
prev->next = this;
}
-BitmapMenu::~BitmapMenu() {
+
+BitmapMenu::~BitmapMenu()
+{
if (next) delete next;
if (form->visible) Hide();
fl_free_form(form);
delete[] bitmap;
}
-void BitmapMenu::Hide() {
+
+void BitmapMenu::Hide()
+{
fl_hide_form(form);
fl_set_button(button, 0);
active = 0;
}
-void BitmapMenu::Show() {
+
+void BitmapMenu::Show()
+{
if (active)
active->Hide();
active = this;
fl_show_form(form, FL_PLACE_MOUSE, FL_NOBORDER, "");
}
-FL_OBJECT*
-BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, unsigned char* data, Bool vert)
+FL_OBJECT *
+BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, unsigned char const * data, Bool vert)
{
- if (i>= nb)
+ if (i >= nb)
return 0;
- int wx= bw+ww/2, wy= bh+ww/2;
+ int wx = bw+ww/2, wy = bh+ww/2;
wx += (wx % nx);
wy += (wy % ny);
- FL_OBJECT *obj = fl_create_bmtable(1, x, y, wx, wy, "");
+ FL_OBJECT * obj = fl_create_bmtable(1, x, y, wx, wy, "");
fl_set_object_callback(obj, math_cb, id);
fl_set_object_lcol(obj, FL_BLUE);
fl_set_object_boxtype(obj, FL_UP_BOX);
menu->Hide();
}
-char** get_pixmap_from_symbol(char const *arg, int wx, int hx)
+char const ** get_pixmap_from_symbol(char const * arg, int wx, int hx)
{
- char** data= 0;
- latexkeys *l = in_word_set (arg, strlen(arg));
+ char const ** data = 0;
+ latexkeys * l = in_word_set (arg, strlen(arg));
if (!l)
return 0;
Bool math_insert_greek(char const c)
{
int i;
- char const *s= 0;
+ char const * s= 0;
- if ('A'<= c && c<= 'Z') {
- if ((i= Latin2Greek[c - 'A'])>= 0)
+ if ('A' <= c && c <= 'Z') {
+ if ((i = Latin2Greek[c - 'A']) >= 0)
s = latex_greek[i];
}
if ('a'<= c && c<= 'z') {
}
static
-char** pixmapFromBitmapData(char const *s, int wx, int hx)
+char const ** pixmapFromBitmapData(char const * s, int wx, int hx)
{
- int i, id;
- char** data= 0;
+ int i;
+ char const ** data = 0;
- id= -1;
+ int id = -1;
- for (i= 0; i<6; i++) {
- char const **latex_str = 0;
+ for (i = 0; i < 6; ++i) {
+ char const ** latex_str = 0;
switch (i) {
case 0: latex_str = latex_greek; break;
case 1: latex_str = latex_bop; break;
break;
}
}
- if (id>= 0) break;
+ if (id >= 0) break;
}
- if (i<6 && id>= 0) {
- unsigned char *bdata = 0;
+ if (i < 6 && id >= 0) {
+ unsigned char const * bdata = 0;
int w = 0, h = 0, dw = 0, dh = 0;
lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl;
}
int ww = w/dw, hh = h/dh, x, y;
- XImage *xima = XCreateImage(fl_display, 0, 1, XYBitmap, 0,
- reinterpret_cast<char*>(bdata), w, h, 8, 0);
+ XImage * xima = XCreateImage(fl_display, 0, 1, XYBitmap, 0,
+ const_cast<char*>(reinterpret_cast<char const *>(bdata)), w, h, 8, 0);
xima->byte_order = LSBFirst;
xima->bitmap_bit_order = LSBFirst;
x = (id % dw)*ww;
y = (id/dw)*hh;
- if (ww>wx) ww = wx;
- if (hh>hx) hh = hx;
- XImage *sbima = XSubImage(xima, x, y, ww, hh);
- XpmCreateDataFromImage(fl_display, &data, sbima, sbima, 0);
+ if (ww > wx) ww = wx;
+ if (hh > hx) hh = hx;
+ XImage * sbima = XSubImage(xima, x, y, ww, hh);
+ XpmCreateDataFromImage(fl_display, const_cast<char***>(&data), sbima, sbima, 0);
// Dirty hack to get blue symbols quickly
- char *sx = strstr(data[2], "FFFFFFFF");
+ char * sx = strstr(data[2], "FFFFFFFF");
if (sx) {
- for (int k= 0; k<8; k++) sx[k] = '0';
+ for (int k = 0; k < 8; ++k) sx[k] = '0';
}
// XDestroyImage(xima);
// Supports ./ and ~/. Later we can add support for ~logname/. (Asger)
string ExpandPath(string const & path)
{
- Assert(!path.empty()); // We don't allow empty path. (Lgb)
// checks for already absolute path
string RTemp = ReplaceEnvironmentPath(path);
if (AbsolutePath(RTemp))
string ReplaceEnvironmentPath(string const & path)
{
- Assert(!path.empty()); // We don't allow empty path. (Lgb)
//
// CompareChar: Environmentvariables starts with this character
// PathChar: Next path component start with this character
// this one is not "C" because combox callbacks are really C++ %-|
extern void LayoutsCB(int, void*);
-extern char** get_pixmap_from_symbol(char const *arg, int, int);
+extern char const ** get_pixmap_from_symbol(char const * arg, int, int);
extern LyXAction lyxaction;
// timer-cb for bubble-help (Matthias)
void Toolbar::BubbleTimerCB(FL_OBJECT *, long data)
{
- FL_OBJECT* ob = (FL_OBJECT*) data;
- char* help = (char*) ob->u_vdata;
+ FL_OBJECT * ob = reinterpret_cast<FL_OBJECT*>(data);
+ char* help = static_cast<char*>(ob->u_vdata);
fl_show_oneliner(help, ob->form->x + ob->x,
ob->form->y + ob->y + ob->h);
}
-extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT *ob, long data)
+
+extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data)
{
Toolbar::BubbleTimerCB(ob, data);
}
+
// post_handler for bubble-help (Matthias)
int Toolbar::BubblePost(FL_OBJECT *ob, int event,
FL_Coord /*mx*/, FL_Coord /*my*/, int /*key*/, void */*xev*/)
{
- string help = (char *)ob->u_vdata;
- Toolbar *t = (Toolbar*)ob->u_ldata;
+ string help = static_cast<char *>(ob->u_vdata);
+ Toolbar * t = reinterpret_cast<Toolbar*>(ob->u_ldata);
if(event == FL_ENTER && !help.empty()){
fl_set_object_callback(t->bubble_timer,
return 0;
}
-extern "C" int C_Toolbar_BubblePost(FL_OBJECT *ob, int event,
+
+extern "C" int C_Toolbar_BubblePost(FL_OBJECT * ob, int event,
FL_Coord /*mx*/, FL_Coord /*my*/,
- int key, void *xev)
+ int key, void * xev)
{
return Toolbar::BubblePost(ob, event, 0, 0, key, xev);
}
+
void Toolbar::activate()
{
- toolbarItem *item, *tmp= 0;
- item = toollist;
+ toolbarItem * tmp= 0;
+ toolbarItem * item = toollist;
while(item){
tmp = item->next;
if (item->icon) {
void Toolbar::deactivate()
{
- toolbarItem *item, *tmp= 0;
- item = toollist;
+ toolbarItem * tmp= 0;
+ toolbarItem * item = toollist;
while(item){
tmp = item->next;
if (item->icon) {
}
-void Toolbar::ToolbarCB(FL_OBJECT *ob, long ac)
+void Toolbar::ToolbarCB(FL_OBJECT * ob, long ac)
{
- Toolbar *t = (Toolbar*)ob->u_ldata;
+ Toolbar * t = reinterpret_cast<Toolbar*>(ob->u_ldata);
string res = t->owner->getLyXFunc()->Dispatch(int(ac));
if(!res.empty())
lyxerr[Debug::TOOLBAR] << res << endl;
}
-extern "C" void C_Toolbar_ToolbarCB(FL_OBJECT *ob, long data)
+
+extern "C" void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
{
Toolbar::ToolbarCB(ob, data);
}
+
int Toolbar::get_toolbar_func(string const & func)
{
int action = lyxaction.LookupFunc(func.c_str());
// we shouldn't set if we have not cleaned
if (!cleaned) return;
- toolbarItem *item;
- FL_OBJECT *obj;
- item = toollist;
+ FL_OBJECT * obj;
+ toolbarItem * item = toollist;
if (!doingmain) {
fl_freeze_form(owner->getForm());
fl_set_object_posthandler(obj, C_Toolbar_BubblePost);
- fl_set_pixmapbutton_data(obj, item->pixmap);
+ fl_set_pixmapbutton_data(obj, const_cast<char**>(item->pixmap));
item = item->next;
// we must remember to update the positions
xpos += buttonwidth;
}
-char **Toolbar::getPixmap(kb_action action, string const & arg)
+char const **Toolbar::getPixmap(kb_action action, string const & arg)
{
- char **pixmap = unknown_xpm; //0
+ char const ** pixmap = unknown_xpm; //0
switch(action){
case LFUN_MENUOPEN: pixmap = open_xpm; break;
case LFUN_CLOSEBUFFER: pixmap = close_xpm; break;
// first «hide» the toolbar buttons. This is not a real hide
// actually it deletes and frees the button altogether.
lyxerr << "Toolbar::add: «hide» the toolbar buttons." << endl;
- toolbarItem *item, *tmp= 0;
- item = toollist;
+ toolbarItem * tmp= 0;
+ toolbarItem * item = toollist;
lightReset();
// there exist some special actions not part of
// kb_action: SEPARATOR, LAYOUTS
- char **pixmap = 0;
+ char const ** pixmap = 0;
string help;
- toolbarItem *newItem,*tmp;
+ toolbarItem * newItem, * tmp;
if (lyxaction.isPseudoAction(action)) {
string arg;
void Toolbar::clean()
{
- toolbarItem *item, *tmp= 0;
- item = toollist;
+ toolbarItem * tmp = 0;
+ toolbarItem * item = toollist;
reset();
if (nth == 0) return;
- int count= 0;
- toolbarItem *tmp = toollist;
+ int count = 0;
+ toolbarItem * tmp = toollist;
while (tmp) {
count++;
if (count == nth) {
}
-void Toolbar::read(LyXLex &lex)
+void Toolbar::read(LyXLex & lex)
{
//consistency check
if (lex.GetString() != "\\begin_toolbar")
// -*- C++ -*-
/* This file is part of
* ======================================================
-*
-* LyX, The Document Processor
-* Copyright (C) 1995 Matthias Ettrich
-*
-* This file is Copyright (C) 1996-1998
-* Lars Gullik Bjønnes
-*
-* ====================================================== */
+ *
+ * LyX, The Document Processor
+ * Copyright (C) 1995 Matthias Ettrich
+ *
+ * This file is Copyright (C) 1996-1999
+ * Lars Gullik Bjønnes
+ *
+ * ====================================================== */
#ifndef TOOLBAR_H
#define TOOLBAR_H
class Toolbar {
public:
///
- Toolbar(Toolbar const &, LyXView *o, int x, int y);
+ Toolbar(Toolbar const &, LyXView * o, int x, int y);
///
Toolbar()
};
///
- Combox *combox;
+ Combox * combox;
///
- void read(LyXLex&);
+ void read(LyXLex &);
/// sets up the default toolbar
void init();
/// (re)sets the toolbar
- void set(bool doingmain= false);
+ void set(bool doingmain = false);
/** this is to be the entry point to the toolbar
frame, where you can change the toolbar realtime. */
void edit();
/// add a new button to the toolbar.
- void add(int , bool doclean= true);
+ void add(int , bool doclean = true);
/// name of func instead of kb_action
- void add(string const & , bool doclean= true);
+ void add(string const & , bool doclean = true);
/// invokes the n'th icon in the toolbar
void push(int);
/// activates the toolbar
void deactivate();
///
- static void ToolbarCB(FL_OBJECT*, long);
+ static void ToolbarCB(FL_OBJECT *, long);
///
static void BubbleTimerCB(FL_OBJECT *, long);
///
- static int BubblePost(FL_OBJECT *ob, int event,
- FL_Coord mx, FL_Coord my, int key, void *xev);
+ static int BubblePost(FL_OBJECT * ob, int event,
+ FL_Coord mx, FL_Coord my, int key, void * xev);
private:
///
struct toolbarItem
{
///
- toolbarItem *next;
+ toolbarItem * next;
///
int action;
///
string help;
///
- FL_OBJECT *icon;
+ FL_OBJECT * icon;
///
bool IsBitmap;
///
- char **pixmap;
+ char const ** pixmap;
///
toolbarItem(){
next = 0;
};
/// a list containing all the buttons
- toolbarItem *toollist;
+ toolbarItem * toollist;
///
- LyXView *owner;
+ LyXView * owner;
///
- FL_OBJECT *bubble_timer;
+ FL_OBJECT * bubble_timer;
/// Starting position
int sxpos, sypos;
///
bool cleaned;
///
- char **getPixmap(kb_action, string const & arg = string());
+ char const ** getPixmap(kb_action, string const & arg = string());
/// removes all toolbar buttons from the toolbar.
void clean();