]> git.lyx.org Git - lyx.git/commitdiff
fixes because of SUN CC warnings, bmtable now compiled with C compilator, countChar...
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 21 Dec 1999 06:10:21 +0000 (06:10 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 21 Dec 1999 06:10:21 +0000 (06:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@390 a592a061-630c-0410-9148-cb99ea01b6c8

36 files changed:
ChangeLog
acinclude.m4
configure.in
src/BufferView.C
src/BufferView.h
src/LaTeX.C
src/LyXView.C
src/Makefile.am
src/bmtable.C
src/bmtable.c [new file with mode: 0644]
src/bmtable.h
src/buffer.C
src/buffer.h
src/definitions.h [deleted file]
src/insets/figinset.C
src/insets/insetbib.C
src/insets/insetinclude.C
src/insets/insetindex.C
src/insets/insetinfo.C
src/insets/inseturl.C
src/intl.C
src/kbmap.C
src/layout.h
src/lyx_gui.C
src/lyx_gui_misc.C
src/lyx_gui_misc.h
src/support/LAssert.h
src/support/lstrings.C
src/support/lstrings.h
src/support/lyxstring.h
src/text.C
src/text2.C
src/trans.C
src/trans_decl.h
src/trans_mgr.C
src/trans_mgr.h

index cee84cde307e0257659c969dae6fbbfb6b5687b7..1386aaeeb27d470c821011ab9b3d7492aacc4760 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,58 @@
+1999-12-21  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * src/text2.C (RedoHeightOfParagraph): rename arg cursor -> cur
+       (RedoDrawingOfParagraph): ditto
+       (RedoParagraphs): ditto
+       (RemoveTableRow): ditto
+
+       * src/text.C (Fill): rename arg paperwidth -> paper_width
+
+       * src/buffer.C (insertLyXFile): rename var filename -> fname
+       (writeFile): rename arg filename -> fname
+       (writeFileAscii): ditto
+       (makeLaTeXFile): ditto
+       (makeLinuxDocFile): ditto
+       (makeDocBookFile): ditto
+
+       * src/LaTeX.C (runMakeIndex): change arg name from file -> f
+       (runBibTeX): ditto
+
+       * src/Makefile.am (lyx_SOURCES): add bmtable.c and remove bmtable.C
+
+       * src/bmtable.h: add extern "C" on this file when __cplusplus is
+       defined.
+
+       * src/bmtable.c: new file, a C'ified copy of bmtable.C, this is
+       compiled by a C compilator not C++. 
+
+       * src/layout.h (LyXTextClass): added typedef for const_iterator
+       (LyXTextClassList): added typedef for const_iterator + member
+       functions begin and end.
+
+       * src/LyXView.C (UpdateDocumentClassChoice): rewritten to use
+       iterators to fill the choice_class.
+       (updateLayoutChoice): rewritten to use iterators to fill the
+       layoutlist in the toolbar.
+
+       * src/BufferView.h (BufferView::work_area_width): removed unused
+       variable. 
+
+       * src/lyx_gui_misc.C (WarnReadonly): added string parameter 'file'
+
+       * src/buffer.C (sgmlOpenTag): drop the use of the static space array
+       (sgmlCloseTag): ditto
+
+       * src/support/lstrings.h: return type of countChar changed to
+       unsigned char.
+
+       * src/support/lstrings.C (countChar): use HAVE_STD_COUNT to choose
+       what version of this func to use. Also made to return unsigned int.
+
+       * configure.in: call LYX_STD_COUNT 
+
+       * acinclude.m4 (LYX_STD_COUNT): new function checks for a standard
+       conforming std::count. 
+
 1999-12-20  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * src/mathed/math_draw.C (Draw, Metrics): fix a bug where a prime
index c919e6c3df331fc3b92afde5b2581075d12225f6..3362b4c385f592d380a8774acb7299503a87c729 100644 (file)
@@ -286,6 +286,30 @@ if test $lyx_cv_broken_stack = yes ; then
 fi])
 
 
+dnl Usage: LYX_STD_COUNT : checks wherer the C++ library have a conforming
+dnl    count template, if not the old HP version is assumed.
+AC_DEFUN(LYX_STD_COUNT,[
+AC_CACHE_CHECK(for conforming std::count,lyx_cv_std_count,
+ [AC_TRY_COMPILE([
+#include <string>
+#include <algorithm>
+using std::string;
+using std::count;
+int countChar(string const & a, char const c)
+{
+        return count(a.begin(), a.end(), c);
+}
+],[
+    string a("hello");
+    int i = countChar(a, 'l');
+],lyx_cv_std_count=yes,lyx_cv_std_count=no)
+])
+if test $lyx_cv_std_count = yes ; then
+    AC_DEFINE(HAVE_STD_COUNT, 1,
+    [Define if you have a conforming std::count template, otherwise HP version of count template is assumed.])
+fi])
+
+
 dnl Usage: LYX_CXX_STL_MODERN_STREAMS : checks whether the C++ compiler
 dnl   supports modern STL streams
 AC_DEFUN(LYX_CXX_STL_MODERN_STREAMS,[
index 80ff6a10d818a160868aa27ca0ceddf30650d03f..2c3ff8beae952c7d6764e438fed64b9d00bba852 100644 (file)
@@ -70,6 +70,7 @@ dnl LYX_CXX_STL_STACK
 LYX_CXX_STL_STRING
 LYX_CXX_NAMESPACES
 LYX_CXX_CHEADERS
+LYX_STD_COUNT
 dnl we disable rtti for now
 dnl LYX_CXX_RTTI
 AC_CHECK_HEADERS(ostream istream)
index 48dc183a9180ce312e6e1834ed969fc7abba7bd7..c6ab81144be94ff7c440c77d47d32fa159d5c916 100644 (file)
@@ -402,7 +402,7 @@ extern "C" {
 void BufferView::create_view(int xpos, int ypos, int width, int height)
 {
        FL_OBJECT * obj;
-       const int bw = abs(fl_get_border_width());
+       int const bw = abs(fl_get_border_width());
 
        // a hack for the figinsets (Matthias)
        // This one first, then it will probably be invisible. (Lgb)
@@ -423,9 +423,9 @@ void BufferView::create_view(int xpos, int ypos, int width, int height)
 
        // the free object
        work_area = obj = fl_add_free(FL_INPUT_FREE,
-                                     xpos +bw, ypos+bw,
-                                     width-15-2*bw /* scrollbarwidth */,
-                                     height-2*bw, "",
+                                     xpos + bw, ypos + bw,
+                                     width - 15 - 2 * bw /* scrollbarwidth */,
+                                     height - 2 * bw, "",
                                      C_BufferView_work_area_handler);
        obj->wantkey = FL_KEY_TAB;
        obj->u_vdata = this; /* This is how we pass the BufferView
@@ -445,7 +445,7 @@ void BufferView::create_view(int xpos, int ypos, int width, int height)
        fl_set_border_width(-2); // to get visible feedback
 #endif
        button_up = obj = fl_add_pixmapbutton(FL_TOUCH_BUTTON,
-                                             width-15+4*bw,
+                                             width - 15 + 4 * bw,
                                              ypos,
                                              15, 15, "");
        fl_set_object_boxtype(obj, FL_UP_BOX);
@@ -464,9 +464,9 @@ void BufferView::create_view(int xpos, int ypos, int width, int height)
        // the scrollbar slider
        fl_set_border_width(-bw);
        scrollbar = obj = fl_add_slider(FL_VERT_SLIDER,
-                                       width-15+4*bw,
+                                       width - 15 + 4 * bw,
                                        ypos + 15,
-                                       15, height-30, "");
+                                       15, height - 30, "");
        fl_set_object_color(obj, FL_COL1, FL_MCOL);
        fl_set_object_boxtype(obj, FL_UP_BOX);
        fl_set_object_resize(obj, FL_RESIZE_ALL);
@@ -824,11 +824,10 @@ int BufferView::work_area_handler(FL_OBJECT * ob, int event,
        return 1;
 }
 
-int BufferView::WorkAreaMotionNotify(FL_OBJECT *ob, Window,
+int BufferView::WorkAreaMotionNotify(FL_OBJECT * ob, Window,
                                     int /*w*/, int /*h*/,
-                                    XEvent * ev, void */*d*/)
+                                    XEvent * ev, void * /*d*/)
 {
-
        if (buffer_ == 0) return 0;
        if (!screen) return 0;
 
@@ -1350,7 +1349,7 @@ void BufferView::CursorToggleCB(FL_OBJECT * ob, long)
        }
 
        if (view->lyx_focus && view->work_area_focus) {
-               if (!view->buffer_->the_locking_inset){
+               if (!view->buffer_->the_locking_inset) {
                        view->screen->CursorToggle();
                } else {
                        view->buffer_->the_locking_inset->
@@ -1359,7 +1358,7 @@ void BufferView::CursorToggleCB(FL_OBJECT * ob, long)
                goto set_timer_and_return;
        } else {
                // Make sure that the cursor is visible.
-               if (!view->buffer_->the_locking_inset){
+               if (!view->buffer_->the_locking_inset) {
                        view->screen->ShowCursor();
                } else {
                        if (!view->buffer_->the_locking_inset->isCursorVisible())
@@ -1433,7 +1432,7 @@ int BufferView::WorkAreaSelectionNotify(FL_OBJECT *, Window win,
                }
                XFlush(fl_display);
 
-               if (uc){
+               if (uc) {
                        free(uc);
                        uc = 0;
                }
index 45e4cce06be4fc8dc434bb7dfde64c37f1812334..2ec4f88575b3d429ccb059b3d87840a9fce95ea9 100644 (file)
@@ -30,7 +30,7 @@ class Inset;
 class BufferView {
 public:
        ///
-       BufferView(LyXView *owner, int , int , int, int);
+       BufferView(LyXView * owner, int , int , int, int);
        ///
        ~BufferView();
        ///
@@ -66,11 +66,10 @@ public:
        ///
        LyXView * owner() const { return owner_; }
        ///
-       LyXScreen * getScreen()
-               {
-                       fl_set_timer(timer_cursor, 0.4);
-                       return screen;
-               }
+       LyXScreen * getScreen() {
+               fl_set_timer(timer_cursor, 0.4);
+               return screen;
+       }
         ///
         void savePosition();
         ///
@@ -142,8 +141,6 @@ private:
        ///
        long current_scrollbar_value;
        ///
-       int work_area_width;
-       ///
        bool lyx_focus;
        ///
        bool work_area_focus;
index f2a3c12f33fd83f5a5a4afa76f632ffdfc2eb9da..82813fa1cbac09512285dfafe43b642e19051f10 100644 (file)
@@ -296,18 +296,18 @@ int LaTeX::operator()()
 }
 
 
-bool LaTeX::runMakeIndex(string const &file)
+bool LaTeX::runMakeIndex(string const & f)
 {
        lyxerr[Debug::LATEX] << "idx file has been made,"
                " running makeindex on file "
-                            <<  file << endl;
+                            <<  f << endl;
 
        // It should be possible to set the switches for makeindex
        // sorting style and such. It would also be very convenient
        // to be able to make style files from within LyX. This has
        // to come for a later time. (0.13 perhaps?)
        string tmp = "makeindex -c -q ";
-       tmp += file;
+       tmp += f;
        Systemcalls one;
        one.startscript(Systemcalls::System, tmp);
        return true;
@@ -369,14 +369,14 @@ bool LaTeX::scanAux(DepTable & dep)
 }
 
 
-bool LaTeX::runBibTeX(string const & file, DepTable & dep)
+bool LaTeX::runBibTeX(string const & f, DepTable & dep)
 {
        // Since a run of Bibtex mandates more latex runs it is ok to
        // remove all ".bib" and ".bst" files, it is also required to
        // discover style and database changes.
        dep.remove_files_with_extension(".bib");
        dep.remove_files_with_extension(".bst");
-       ifstream ifs(file.c_str());
+       ifstream ifs(f.c_str());
        string token;
        bool using_bibtex = false;
        LRegex reg1("\\\\bibdata{([^}]+)}");
index 79a5e9a7df59ec935704911045dcb34a0bbbe5c9..129aec0e009ac05626c7908c5713cfcadfe2a83d 100644 (file)
@@ -158,22 +158,20 @@ void LyXView::create_form_form_main(int width, int height)
         * are presented (and rightly so) in GUI popups. Asger. 
         */
 {
-       FL_OBJECT * obj;
-       
-       FD_form_main *fdui = (FD_form_main *)
-               fl_calloc(1, sizeof(FD_form_main));
+       FD_form_main * fdui = static_cast<FD_form_main *>
+               (fl_calloc(1, sizeof(FD_form_main)));
 
        _form_main = fdui;
 
        // the main form
        _form = fdui->form_main = fl_bgn_form(FL_NO_BOX, width, height);
        fdui->form_main->u_vdata = this;
-       obj = fl_add_box(FL_FLAT_BOX, 0, 0, width, height, "");
+       FL_OBJECT * obj = fl_add_box(FL_FLAT_BOX, 0, 0, width, height, "");
        fl_set_object_color(obj, FL_MCOL, FL_MCOL);
 
        // Parameters for the appearance of the main form
-       const int air = 2;
-       const int bw = abs(fl_get_border_width());
+       int const air = 2;
+       int const bw = abs(fl_get_border_width());
        
        //
        // THE MENUBAR
@@ -194,19 +192,19 @@ void LyXView::create_form_form_main(int width, int height)
        // WORKAREA
        //
 
-       const int ywork = 60 + 2*air + bw;
-       const int workheight = height - ywork - (25 + 2*air);
+       int const ywork = 60 + 2 * air + bw;
+       int const workheight = height - ywork - (25 + 2 * air);
 
        ::current_view = bufferview = new BufferView(this, air, ywork,
-                                                    width - 3*air,
+                                                    width - 3 * air,
                                                     workheight);
 
        //
        // MINIBUFFER
        //
 
-       minibuffer = new MiniBuffer(this, air, height-(25+air), 
-                                   width-(2*air), 25);
+       minibuffer = new MiniBuffer(this, air, height - (25 + air), 
+                                   width - (2 * air), 25);
 
        //
        // TIMERS
@@ -292,16 +290,13 @@ void LyXView::updateLayoutChoice()
        if (toolbar->combox->empty() ||
            (last_textclass != int(buffer()->params.textclass))) {
                toolbar->combox->clear();
-               for (int i = 0;
-                    textclasslist.NameOfLayout(buffer()->
-                        params.textclass, i) != "@@end@@";
-                    i++) {
-                       LyXLayout const & layout = textclasslist.
-                               Style(buffer()->params.textclass, i);
-                       if (layout.obsoleted_by().empty())
-                               toolbar->combox->addline(layout.name().c_str());
+               LyXTextClass const & tc = textclasslist.TextClass(buffer()->params.textclass);
+               for (LyXTextClass::const_iterator cit = tc.begin();
+                    cit != tc.end(); ++cit) {
+                       if ((*cit).obsoleted_by().empty())
+                               toolbar->combox->addline((*cit).name().c_str());
                        else
-                               toolbar->combox->addline(("@N"+layout.name()).c_str());
+                               toolbar->combox->addline(("@N" + (*cit).name()).c_str());
                }
                last_textclass = int(buffer()->params.textclass);
                current_layout = 0;
@@ -323,10 +318,10 @@ void LyXView::UpdateDocumentClassChoice()
        // Update the document class display in the document form
        if (fd_form_document) {
                fl_clear_choice(fd_form_document->choice_class);
-               for (int i = 0;
-                    textclasslist.DescOfClass(i) != "@@end@@"; ++i) {
+               for (LyXTextClassList::const_iterator cit = textclasslist.begin();
+                    cit != textclasslist.end(); ++cit) {
                        fl_addto_choice(fd_form_document->choice_class,
-                                       textclasslist.DescOfClass(i).c_str());
+                                       (*cit).description().c_str());
                }
        }
 }
index 58c6fd83a7aedbe43f01e04d46aae629b0c94e61..efb3142a7138f8e71138f9262c30b1063ac6fd92 100644 (file)
@@ -48,7 +48,7 @@ lyx_SOURCES = \
        Spacing.h \
        TableLayout.C \
        bibforms.h \
-       bmtable.C \
+       bmtable.c \
        bmtable.h \
        broken_headers.h \
        buffer.C \
index 3491478962fd4145516d8b88e7a02016334a6194..c2773abd7c9006306f917619f79c6116d2549ba5 100644 (file)
 
 #include <config.h>
 
-#include <cstdlib>
+#include <stdlib.h>
 #include "bmtable.h"
 #include XPM_H_LOCATION
 
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+  
 typedef struct   {   
    int nx, ny;   /* Dimensions of the table */
    int dx, dy;   /* Size of each item */ 
@@ -484,4 +489,6 @@ void fl_free_bmtable_pixmap(FL_OBJECT *ob)
   }
 }
 
-
+#if defined(__cplusplus)
+}
+#endif
diff --git a/src/bmtable.c b/src/bmtable.c
new file mode 100644 (file)
index 0000000..f1e5288
--- /dev/null
@@ -0,0 +1,494 @@
+/*
+ *  File:        bmtable.c
+ *  Purpose:     Implementation of the XForms object bmtable. 
+ *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
+ *  Created:     November 1995
+ *  Description: A bitmap table uses a single bitmap to simulate a 2d array 
+ *               of bitmap buttons. It can be used to build bitmap menus.
+ *               
+ *  Copyright 1995, 1996 Alejandro Aguilar Sierra 
+ *
+ *  You are free to use and modify this code under the terms of
+ *  the GNU General Public Licence version 2 or later. 
+ *  
+ */ 
+
+#include <config.h>
+
+#include <stdlib.h>
+#include "bmtable.h"
+#include XPM_H_LOCATION
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+  
+typedef struct   {   
+   int nx, ny;   /* Dimensions of the table */
+   int dx, dy;   /* Size of each item */ 
+   int bx, by;   /* Bitmap's position */
+   int bw, bh;   /* Bitmap dimensions */
+   unsigned char const * bdata;  /* Bitmap data */
+   int maxi;     /* Number of items */
+   int i;        /* Current position */
+   int mousebut; /* mouse button pushed */  
+   Pixmap pix;   /* Pixmap from data (temporal) */
+} BMTABLE_SPEC;
+                 
+
+int handle_bitmaptable(FL_OBJECT * ob, int event, FL_Coord mx, 
+                      FL_Coord my, int key, void * xev);
+
+
+FL_OBJECT * fl_create_bmtable(int type, FL_Coord x, FL_Coord y, 
+                             FL_Coord w, FL_Coord h, char const * label)
+{
+   FL_OBJECT * ob;
+   
+   ob = fl_make_object(FL_BMTABLE, type, x, y, w, h, label, handle_bitmaptable);
+   ob->boxtype = FL_BMTABLE_BOXTYPE;
+   ob->spec = fl_calloc(1, sizeof(BMTABLE_SPEC));
+   ((BMTABLE_SPEC *)ob->spec)->pix = 0;
+   ((BMTABLE_SPEC *)ob->spec)->bdata= 0;
+   ((BMTABLE_SPEC *)ob->spec)->mousebut= -1;
+   return ob;
+}
+
+
+FL_OBJECT *fl_add_bmtable(int type, FL_Coord x, FL_Coord y, 
+                             FL_Coord w, FL_Coord h, char const *label)
+{
+   FL_OBJECT *ob;
+   
+   ob = fl_create_bmtable(type, x, y, w, h, label);  
+   fl_add_object(fl_current_form, ob); 
+   
+   return ob;
+}
+
+
+static void draw_bitmaptable(FL_OBJECT *ob)
+{
+       int i, j, lx;
+       FL_Coord mx, my;
+       FL_Coord xx, yy, ww, hh;
+       BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec;
+       GC gc = fl_state[fl_get_vclass()].gc[0];
+       if (!sp) return;
+   
+       /* draw the bounding box first */
+       lx = sp->maxi % sp->nx;
+       fl_drw_box(ob->boxtype, ob->x, ob->y, ob->w, ob->h, ob->col1, ob->bw);
+       if (lx) {
+               i = FL_abs(ob->bw);
+               xx = ob->x+ sp->dx*lx + i;
+               yy = ob->y+ (sp->ny-1)*sp->dy+i;
+               ww = ob->x+ob->w - xx - i;
+               hh = ob->y+ob->h-yy-i;
+               fl_drw_frame(FL_DOWN_FRAME, xx, yy, ww, hh, ob->col1, ob->bw);
+               fl_rectf(xx, yy, ww+i, hh+i, ob->col1);
+       }
+    
+       /* draw the background bitmap */
+       if (sp->bdata)  {
+               if (!sp->pix) {
+                       sp->pix = XCreatePixmapFromBitmapData(fl_display, fl_winget(), 
+                                                             (char*)sp->bdata,
+                                                              sp->bw, sp->bh,
+                                       fl_get_flcolor(ob->lcol), fl_get_flcolor(ob->col1),
+                                                              /*DefaultDepth(fl_display, DefaultScreen(fl_display))*/ fl_state[fl_get_vclass()].depth);
+                       XFlush(fl_display);
+               }
+       }
+       if (sp->pix) {
+               /* Adjust position */ 
+               if (sp->bx < FL_abs(ob->bw) + 1) {
+                       xx = FL_abs(ob->bw) - sp->bx + 1;
+                       mx = ob->x + FL_abs(ob->bw) + 1;
+               } else  {
+                       xx = 0;
+                       mx = ob->x + sp->bx;
+               }
+               if (sp->by < FL_abs(ob->bw) + 1)  {      
+                       yy = FL_abs(ob->bw) - sp->by + 1;
+                       my = ob->y + FL_abs(ob->bw) + 1;
+               } else   {
+                       yy = 0;
+                       my = ob->y + sp->by;
+               }                 
+               ww = (mx + sp->bw < ob->x + ob->w - FL_abs(ob->bw)) ? 
+                       sp->bw: ob->x + ob->w - FL_abs(ob->bw) - mx;
+               hh = (my + sp->bh < ob->y + ob->h - FL_abs(ob->bw)) ?
+                       sp->bh: ob->y + ob->h - FL_abs(ob->bw) - my; 
+      
+               i = FL_abs(ob->bw);
+               j = hh - ((lx) ? sp->dy+2*i: 0);
+               XCopyArea(fl_display, sp->pix, fl_winget(), gc, xx, yy, ww, j, mx, my);
+               XFlush(fl_display);
+               if (lx) {
+                       XCopyArea(fl_display, sp->pix, fl_winget(), gc, xx,
+                                         yy+j, lx*sp->dx-2*i, hh-j, mx, my+j);
+                       XFlush(fl_display);
+               }
+       }
+   
+   
+       /* draw the grid if type > FLAT */
+       if (ob->type > FL_BMTABLE_FLAT)  {
+               mx = ob->x + ob->w; 
+               my = ob->y + ob->h; 
+               ww = ob->w; 
+               for (yy= ob->y; yy<= my; yy+= sp->dy) {
+                       if (ob->boxtype!= FL_FLAT_BOX && (yy == ob->y || yy>my-sp->dy)) 
+                               continue;
+                       if (lx>0 && yy>= my-sp->dy - sp->dy/2)
+                               ww = lx*sp->dx;
+                       fl_diagline(ob->x, yy, ww, 1, FL_BOTTOM_BCOL); 
+                       fl_diagline(ob->x, yy+1, ww-2, 1, FL_TOP_BCOL); 
+               }          
+               hh = ob->h;
+               for (xx= ob->x; xx<= mx; xx+= sp->dx)  {
+                       if (ob->boxtype!= FL_FLAT_BOX && (xx == ob->x || xx>mx-sp->dx))
+                               continue;
+                       if (lx>0 && xx>= ob->x+lx*sp->dx)
+                               hh = (sp->ny-1)*sp->dy;
+                       fl_diagline(xx, ob->y, 1, hh, FL_RIGHT_BCOL);
+                       fl_diagline(xx+1, ob->y+1, 1, hh-2, FL_LEFT_BCOL);
+               }        
+       }  
+   
+       /* Simulate a pushed button */
+       if (ob->pushed && 0 <= sp->i && sp->i < sp->maxi)  {  
+               i = sp->i % sp->nx;
+               j = sp->i/sp->nx;
+               ww = sp->dx-2*FL_abs(ob->bw);
+               hh = sp->dy-2*FL_abs(ob->bw);
+               xx = ob->x + sp->dx*i + FL_abs(ob->bw);
+               yy = ob->y + sp->dy*j + FL_abs(ob->bw);
+               fl_drw_frame(FL_DOWN_FRAME, xx, yy, ww, hh, ob->col1, ob->bw);
+       }
+}
+
+
+int handle_bitmaptable(FL_OBJECT * ob, int event, FL_Coord mx, 
+                                 FL_Coord my, int key, void * xev)
+{
+       int i, j;
+       BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec;
+   
+       switch (event)  {
+    case FL_DRAW: 
+               draw_bitmaptable(ob);
+               break;
+    case FL_MOUSE:
+               if (!ob->belowmouse) {    /* This never happens. Why? */
+                       sp->i = -1;
+                       fl_redraw_object(ob);
+                       break;
+               }
+               i = (mx - ob->x)/sp->dx;  j = (my - ob->y)/sp->dy;
+               if (i>= 0 && i< sp->nx && j>= 0 && j< sp->ny)   {
+                       i += j*sp->nx;
+                       if (i >= sp->maxi) i = -1;
+                       if (sp->i !=  i)  {
+                               sp->i = i;
+                               fl_redraw_object(ob);
+                       }
+               }
+               break;        
+    case FL_PUSH:
+               sp->mousebut = key;
+               i = (mx - ob->x)/sp->dx + ((my - ob->y)/sp->dy)*sp->nx; 
+               if (0 <= i && i < sp->maxi)  {
+                       sp->i =  i;
+                       fl_redraw_object(ob);
+               } else
+                       sp->i =  -1; 
+               break;
+    case FL_RELEASE:    
+               fl_redraw_object(ob);
+               return 1;
+    case FL_FREEMEM:
+           if (sp->pix) {
+                   XFreePixmap(fl_display, sp->pix);
+                   XFlush(fl_display);
+           }
+               fl_free(((BMTABLE_SPEC*)ob->spec));      
+               break;
+       }
+       return 0;
+}
+
+
+/*
+ * The table has nx columns of dx width each and ny rows of dy height each. 
+ * Initially the position of the firts item is supposed to be the same that
+ * the object position (x, y), and the number of items is supposed to be
+ * exactly nx*ny.
+ * 
+ * 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 const * bdata)
+{
+   BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec;
+   if (sp) {
+     sp->nx = nx;
+     sp->ny = ny; 
+     sp->bx = FL_abs(ob->bw);
+     sp->by = FL_abs(ob->bw);
+     sp->dx = ob->w/nx; 
+     sp->dy = ob->h/ny;
+     sp->i = -1;
+     sp->maxi = sp->nx * sp->ny;
+     sp->bw = bw;
+     sp->bh = bh;
+     sp->bdata = bdata;
+   }
+}
+
+
+void fl_set_bmtable_pixmap_data(FL_OBJECT * ob, int nx, int ny,
+                       char ** pdata)
+{
+       BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec;
+       extern Colormap color_map;
+       if (sp) {
+               Pixmap dummy_shapemask = 0;
+#if 0
+               // I can't see why this initalization is needed. (Lgb)
+               XpmAttributes dumb_attributes = {0};
+#else
+               XpmAttributes dumb_attributes;
+#endif
+               sp->nx = nx;
+               sp->ny = ny; 
+               sp->bx = FL_abs(ob->bw);
+               sp->by = FL_abs(ob->bw);
+               sp->dx = ob->w/nx; 
+               sp->dy = ob->h/ny;
+               sp->i = -1;
+               sp->maxi = sp->nx * sp->ny;
+               sp->bdata = 0;
+               dumb_attributes.colormap = color_map;
+               dumb_attributes.closeness = 30000;
+               dumb_attributes.valuemask = XpmColormap | XpmCloseness;
+               if (XCreatePixmapFromData(fl_display, fl_winget(), pdata,
+                                         &(sp->pix), &dummy_shapemask,
+                                         &dumb_attributes) == XpmSuccess) {
+                       sp->bw = dumb_attributes.width;
+                       sp->bh = dumb_attributes.height;
+                       XpmFreeAttributes(&dumb_attributes);
+                       if (dummy_shapemask) {
+                               XFreePixmap(fl_display, dummy_shapemask);
+                       }
+               }
+               XFlush(fl_display);
+       }
+}
+
+
+/*
+ *  This function works only for X11R6 or later
+ */
+#if XlibSpecificationRelease > 5 
+
+void fl_set_bmtable_file(FL_OBJECT * ob, int nx, int ny, char const * filename)
+{      
+   int xh, yh;
+   unsigned int bw, bh;
+   unsigned char * bdata;
+   
+   if(XReadBitmapFileData(filename, &bw, &bh,
+                         &bdata, &xh, &yh) == BitmapSuccess)
+     fl_set_bmtable_data(ob, nx, ny, bw, bh, bdata);
+   XFlush(fl_display);
+}
+
+#else
+
+void fl_set_bmtable_file(FL_OBJECT *, int, int, char const *) 
+{
+  fprintf(stderr, "Set bmtable file: Sorry, I need X11 release 6 to do " 
+          "work!\n");
+}
+
+#endif
+
+
+
+void fl_set_bmtable_pixmap_file(FL_OBJECT *ob, int nx, int ny, char const *filename)
+{      
+       extern Colormap color_map;
+       BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec;
+       if (sp) {
+               Pixmap dummy_shapemask = 0;
+#if 0
+               XpmAttributes dumb_attributes = {0};
+#else
+               XpmAttributes dumb_attributes;
+#endif
+               sp->nx = nx;
+               sp->ny = ny; 
+               sp->bx = FL_abs(ob->bw);
+               sp->by = FL_abs(ob->bw);
+               sp->dx = ob->w/nx; 
+               sp->dy = ob->h/ny;
+               sp->i = -1;
+               sp->maxi = sp->nx * sp->ny;
+               sp->bdata = 0;
+
+               dumb_attributes.colormap = color_map;
+               dumb_attributes.closeness = 30000;
+               dumb_attributes.valuemask = XpmColormap | XpmCloseness;
+   
+               if (XReadPixmapFile(fl_display, fl_winget(), (char *)filename,
+                                   &(sp->pix), &dummy_shapemask,
+                                   &dumb_attributes) == XpmSuccess) {
+                       sp->bw = dumb_attributes.width;
+                       sp->bh = dumb_attributes.height;
+                       XpmFreeAttributes(&dumb_attributes);
+                       if (dummy_shapemask) {
+                               XFreePixmap(fl_display, dummy_shapemask);
+                       }
+               }
+               XFlush(fl_display);
+       }
+}
+
+
+/*
+ * This function allows to adjust the position of the first item and its
+ * size (dx, dy). The input values are incremental, not absolute.
+ */
+void fl_set_bmtable_adjust(FL_OBJECT *ob, int px, int py, int dx, int dy)
+{
+   BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec;   
+   if (sp) {
+     sp->bx += px;
+     sp->by += py;                         
+     sp->dx += dx;
+     sp->dy += dy;
+   }
+}
+
+/* 
+ * This function returns the table's selected position.
+ */
+int fl_get_bmtable(FL_OBJECT *ob)
+{ 
+   if ((BMTABLE_SPEC *)ob->spec)
+     return  ((BMTABLE_SPEC *)ob->spec)->i;
+   else 
+     return 0;
+}
+
+
+/* 
+ * You can change the max number of items if you want.
+ */
+void fl_set_bmtable_maxitems(FL_OBJECT * ob, int i)
+{
+   if (i > 0 && (BMTABLE_SPEC *)ob->spec)
+     ((BMTABLE_SPEC *)ob->spec)->maxi = i;
+}   
+
+
+int fl_get_bmtable_maxitems(FL_OBJECT * ob)
+{
+   if ((BMTABLE_SPEC *)ob->spec)
+     return  ((BMTABLE_SPEC *)ob->spec)->maxi;
+   else
+     return 0;
+}
+
+
+void fl_replace_bmtable_item(FL_OBJECT * ob, int id, int cw, int ch, char * data)
+{
+   fprintf(stderr, "Replace bmtable item: Sorry, not yet implemented!\n");
+}
+
+
+void fl_get_bmtable_item(FL_OBJECT * ob, int id, int * cw, int * ch, char * data)
+{
+   fprintf(stderr, "Get bmtable item: Sorry, not yet implemented!\n");
+}  
+
+void fl_set_bmtable(FL_OBJECT * ob, int pushed, int pos)
+{
+   if ((BMTABLE_SPEC *)ob->spec)
+     ((BMTABLE_SPEC *)ob->spec)->i = (pushed) ? pos: -1;
+}
+
+
+int fl_get_bmtable_numb(FL_OBJECT *ob)
+{
+   if ((BMTABLE_SPEC *)ob->spec)
+     return ((BMTABLE_SPEC *)ob->spec)->mousebut;
+   else
+     return 0;
+}
+
+
+Pixmap fl_get_bmtable_pixmap(FL_OBJECT * ob)
+{
+   if ((BMTABLE_SPEC *)ob->spec)
+     return ((BMTABLE_SPEC *)ob->spec)->pix;
+   else
+     return 0;
+}
+
+
+void fl_draw_bmtable_item(FL_OBJECT * ob, int i, Drawable d, int xx, int yy)
+{
+   int x, y, w, h;
+   GC gc = fl_state[fl_get_vclass()].gc[0];
+   BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec;
+   
+   if (sp && sp->pix) {
+      x = (i % sp->nx)*sp->dx + FL_abs(ob->bw);
+      y = (i/sp->nx)*sp->dy + FL_abs(ob->bw);
+      w = sp->dx-2*FL_abs(ob->bw);
+      h = sp->dy-2*FL_abs(ob->bw);      
+      XCopyArea(fl_display, sp->pix, d, gc, x, y, w, h, xx, yy);
+      XFlush(fl_display);
+   }
+}
+
+/* Free the current bitmap and pixmap in preparation for installing a new one */
+void fl_free_bmtable_bitmap(FL_OBJECT * ob)
+{
+  BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec;
+
+  /* dump the temporary pixmap */
+  if (sp && sp->pix) { 
+    XFreePixmap(fl_display, sp->pix);
+    XFlush(fl_display);
+    sp->pix = 0;
+  }
+
+  /* and free the space taken by bdata etc. */
+  if (sp && sp->bdata) {
+    fl_free((void*)sp->bdata);
+    sp->bdata = 0;
+  }
+}
+
+/* Free the current pixmap in preparation for installing a new one */
+/* This is needed when using data instead of files to set bitmaps  */
+void fl_free_bmtable_pixmap(FL_OBJECT *ob)
+{
+  BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec;
+
+  /* dump the temporary pixmap */
+  if (sp && sp->pix) { 
+    XFreePixmap(fl_display, sp->pix);
+    XFlush(fl_display);
+    sp->pix = 0;
+  }
+}
+
+#if defined(__cplusplus)
+}
+#endif
index 937b8c112b6c546fb1b5c4d9bb56abb7c2f2b25b..4d5a7864e909176bb7ce8a8bb50f31c187c1da5c 100644 (file)
 
 #include FORMS_H_LOCATION
 
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
 ///
 #define FL_BMTABLE 1500
 /// A flat bitmap table
@@ -34,6 +39,7 @@
  */
 #define FL_BMTABLE_BOXTYPE     FL_UP_BOX
 
+
 ///
 FL_OBJECT *fl_create_bmtable(int, FL_Coord, FL_Coord, 
                             FL_Coord, FL_Coord, char const *);
@@ -84,5 +90,9 @@ void fl_free_bmtable_bitmap(FL_OBJECT *ob);
 /** Free the current pixmap in preparation for installing a new one */
 void fl_free_bmtable_pixmap(FL_OBJECT *ob);
 
+#if defined(__cplusplus)
+}
+#endif
+
 #endif  /* BMTABLE_H */
 
index 7f0986cf43e18b32093f6d5afce9ee2be0fa3413..db7befb4fc01e357ec4081f01c0d9c38d33ea2df 100644 (file)
@@ -230,25 +230,25 @@ bool Buffer::insertLyXFile(string const & filen)
 {
        if (filen.empty()) return false;
 
-       string filename = MakeAbsPath(filen);
+       string fname = MakeAbsPath(filen);
 
        // check if file exist
-       FileInfo fi(filename);
+       FileInfo fi(fname);
 
        if (!fi.readable()) {
                WriteAlert(_("Error!"),
                           _("Specified file is unreadable: "),
-                          MakeDisplayPath(filename, 50));
+                          MakeDisplayPath(fname, 50));
                return false;
        }
        
        BeforeChange();
 
-       FilePtr myfile(filename, FilePtr::read);
+       FilePtr myfile(fname, FilePtr::read);
        if (!myfile()) {
                WriteAlert(_("Error!"),
                           _("Cannot open specified file: "),
-                          MakeDisplayPath(filename, 50));
+                          MakeDisplayPath(fname, 50));
                return false;
        }
        LyXLex lex(0, 0);
@@ -1174,45 +1174,45 @@ bool Buffer::readFile(LyXLex & lex, LyXParagraph * par)
                    
 
 // Returns false if unsuccesful
-bool Buffer::writeFile(string const & filename, bool flag)
+bool Buffer::writeFile(string const & fname, bool flag)
 {
        // if flag is false writeFile will not create any GUI
        // warnings, only cerr.
        // Needed for autosave in background or panic save (Matthias 120496)
 
-       if (read_only && (filename == this->filename)) {
+       if (read_only && (fname == filename)) {
                // Here we should come with a question if we should
                // perform the write anyway.
                if (flag)
                        lyxerr << _("Error! Document is read-only: ")
-                              << filename << endl;
+                              << fname << endl;
                else
                        WriteAlert(_("Error! Document is read-only: "),
-                                  filename);
+                                  fname);
                return false;
        }
 
-       FileInfo finfo(filename);
+       FileInfo finfo(fname);
        if (finfo.exist() && !finfo.writable()) {
                // Here we should come with a question if we should
                // try to do the save anyway. (i.e. do a chmod first)
                if (flag)
                        lyxerr << _("Error! Cannot write file: ")
-                              << filename << endl;
+                              << fname << endl;
                else
                        WriteFSAlert(_("Error! Cannot write file: "),
-                                    filename);
+                                    fname);
                return false;
        }
 
-       ofstream ofs(filename.c_str());
+       ofstream ofs(fname.c_str());
        if (!ofs) {
                if (flag)
                        lyxerr << _("Error! Cannot open file: ")
-                              << filename << endl;
+                              << fname << endl;
                else
                        WriteFSAlert(_("Error! Cannot open file: "),
-                                    filename);
+                                    fname);
                return false;
        }
        // The top of the file should not be written by params.
@@ -1242,7 +1242,7 @@ bool Buffer::writeFile(string const & filename, bool flag)
 }
 
 
-void Buffer::writeFileAscii(string const & filename, int linelen) 
+void Buffer::writeFileAscii(string const & fname, int linelen) 
 {
        LyXFont font1, font2;
        Inset * inset;
@@ -1255,9 +1255,9 @@ void Buffer::writeFileAscii(string const & filename, int linelen)
        long fpos = 0;
        bool ref_printed = false;
 
-       ofstream ofs(filename.c_str());
+       ofstream ofs(fname.c_str());
        if (!ofs) {
-               WriteFSAlert(_("Error: Cannot write file:"), filename);
+               WriteFSAlert(_("Error: Cannot write file:"), fname);
                return;
        }
 
@@ -1565,7 +1565,7 @@ void Buffer::writeFileAscii(string const & filename, int linelen)
 }
 
 
-void Buffer::makeLaTeXFile(string const & filename, 
+void Buffer::makeLaTeXFile(string const & fname, 
                           string const & original_path,
                           bool nice, bool only_body)
 {
@@ -1578,9 +1578,9 @@ void Buffer::makeLaTeXFile(string const & filename,
         LyXTextClass const & tclass =
                textclasslist.TextClass(params.textclass);
 
-       ofstream ofs(filename.c_str());
+       ofstream ofs(fname.c_str());
        if (!ofs) {
-               WriteFSAlert(_("Error: Cannot open file: "), filename);
+               WriteFSAlert(_("Error: Cannot open file: "), fname);
                return;
        }
        
@@ -2120,27 +2120,33 @@ bool Buffer::isSGML() const
 void Buffer::sgmlOpenTag(ostream & os, int depth,
                         string const & latexname) const
 {
-       static char * space[] = {" ","  ", "   ", "    ", "     ", "      ",
-                                "       ",
-                                "        ", "         ", "          ",
-                                "          "};
-
+#if 0
+       static char const * space[] = {
+               " ","  ", "   ", "    ", "     ", "      ",
+               "       ",
+               "        ", "         ", "          ",
+               "          "};
        os << space[depth] << "<" << latexname << ">\n";
+#endif
+       os << string(depth, ' ') << "<" << latexname << ">\n";
 }
 
 
 void Buffer::sgmlCloseTag(ostream & os, int depth,
                          string const & latexname) const
 {
+#if 0
        static char * space[] = {" ", "  ", "   ", "    ", "     ",
                                 "      ", "       ", "        ",
                                 "         ", "          ", "          "};
 
        os << space[depth] << "</" << latexname << ">\n";
+#endif
+       os << string(depth, ' ') << "</" << latexname << ">\n";
 }
 
 
-void Buffer::makeLinuxDocFile(string const & filename, int column)
+void Buffer::makeLinuxDocFile(string const & fname, int column)
 {
        LyXParagraph * par = paragraph;
 
@@ -2150,10 +2156,10 @@ void Buffer::makeLinuxDocFile(string const & filename, int column)
 
        int depth = 0;              /* paragraph depth */
 
-       ofstream ofs(filename.c_str());
+       ofstream ofs(fname.c_str());
 
        if (!ofs) {
-               WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), filename);
+               WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
                return;
        }
    
@@ -2723,7 +2729,7 @@ void Buffer::LinuxDocError(LyXParagraph * par, int pos,
 
 enum { MAX_NEST_LEVEL = 25};
 
-void Buffer::makeDocBookFile(string const & filename, int column)
+void Buffer::makeDocBookFile(string const & fname, int column)
 {
        LyXParagraph * par = paragraph;
 
@@ -2741,9 +2747,9 @@ void Buffer::makeDocBookFile(string const & filename, int column)
 
        tex_code_break_column = column; 
 
-       ofstream ofs(filename.c_str());
+       ofstream ofs(fname.c_str());
        if (!ofs) {
-               WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), filename);
+               WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
                return;
        }
    
index db9af3a238b87bf48ff7969ea67a54976529c19b..f1e6895917fd0602bc968d93ce3ac94024d218d9 100644 (file)
@@ -33,6 +33,7 @@
 #include "texrow.h"
 #include "lyxtext.h"
 #include "support/filetools.h"
+#include "lyx_gui_misc.h"
 
 
 class LyXRC;
@@ -40,7 +41,6 @@ class TeXErrors;
 class LaTeXFeatures;
 
 extern void updateAllVisibleBufferRelatedPopups();
-extern void WarnReadonly();
 
 ///
 struct DEPCLEAN {
@@ -252,17 +252,16 @@ public:
        bool isReadonly() { return read_only; }
 
        /// Set buffer read-only flag
-       void setReadonly(bool flag = true) 
-               {
-                       if (read_only != flag) {
-                               read_only = flag; 
-                               updateTitles();
-                               updateAllVisibleBufferRelatedPopups();
-                       }
-                       if (read_only) {
-                               WarnReadonly();
-                       }
+       void setReadonly(bool flag = true) {
+               if (read_only != flag) {
+                       read_only = flag; 
+                       updateTitles();
+                       updateAllVisibleBufferRelatedPopups();
+               }
+               if (read_only) {
+                       WarnReadonly(filename);
                }
+       }
 
        /// returns true if the buffer contains a LaTeX document
        bool isLatex() const;
diff --git a/src/definitions.h b/src/definitions.h
deleted file mode 100644 (file)
index e69de29..0000000
index 475c8a4ac44dbe2e56ee92c274ea43c70953531e..d84a457ea637705e4b67be14eedea2219f39d6d1 100644 (file)
@@ -1285,7 +1285,7 @@ void InsetFig::Edit(int, int)
        // The actual prevention of altering a readonly doc
        // is done in CallbackFig()
        if(current_view->buffer()->isReadonly()) 
-               WarnReadonly();
+               WarnReadonly(current_view->buffer()->fileName());
 
        if (!form) {
                form = create_form_Figure();
index 19f9100170538b30244b03223f433ddd76ca6006..4103ef383521fd02235fe5074b351d8c61065258 100644 (file)
@@ -152,7 +152,7 @@ InsetCitation::~InsetCitation()
 void InsetCitation::Edit(int, int)
 {
        if(current_view->buffer()->isReadonly())
-               WarnReadonly();
+               WarnReadonly(current_view->buffer()->fileName());
 
        if (!citation_form) {
                citation_form = create_form_citation_form();
@@ -257,7 +257,7 @@ string InsetBibKey::getScreenLabel() const
 void InsetBibKey::Edit(int, int)
 {
        if(current_view->buffer()->isReadonly())
-               WarnReadonly();
+               WarnReadonly(current_view->buffer()->fileName());
        
        if (!bibitem_form) {
                bibitem_form = create_form_bibitem_form();
index ebde3c0049cedb57c1f254b5ec1b3594cc762b06..540552af24fa08c4ee0bd4b27d6febc36aca5a7e 100644 (file)
@@ -230,7 +230,7 @@ Inset * InsetInclude::Clone() const
 void InsetInclude::Edit(int, int)
 {
        if(current_view->buffer()->isReadonly())
-               WarnReadonly();
+               WarnReadonly(current_view->buffer()->fileName());
 
        if (!form) {
                 form = create_form_include();
index 1156066e6d14f0a6f99f3d008db96508f828f56a..e393abc4fb0592883168f18dd0e67cb2540d01d1 100644 (file)
@@ -13,7 +13,7 @@
 #include "LaTeXFeatures.h"
 #include "gettext.h"
 #include "LString.h"
-#include "lyx_gui_misc.h" // WarnReadonly()
+#include "lyx_gui_misc.h" // WarnReadonly
  
 extern BufferView * current_view;
 extern void UpdateInset(Inset * inset, bool mark_dirty = true);
@@ -89,7 +89,7 @@ InsetIndex::~InsetIndex()
 void InsetIndex::Edit(int, int)
 {
        if(current_view->buffer()->isReadonly())
-               WarnReadonly();
+               WarnReadonly(current_view->buffer()->fileName());
 
        if (!index_form)
                index_form = create_form_index_form();
index 8ccb50e0ba9042d4bdbfa1fb0e5c1befd591bf9a..24cc383658b850f54c8fbafc9db55ccd99471fb5 100644 (file)
@@ -183,7 +183,7 @@ void InsetInfo::Edit(int, int)
        static int ow = -1, oh;
 
        if(current_view->buffer()->isReadonly())
-               WarnReadonly();
+               WarnReadonly(current_view->buffer()->fileName());
        
        if (!form) {
                FL_OBJECT *obj;
index d6e8cbabe70f35c061513e9c01899baf37206d38..2b6b41484813590d34ecf13342997ee1a4bedd3d 100644 (file)
@@ -112,7 +112,7 @@ void InsetUrl::Edit(int, int)
        static int ow = -1, oh;
 
        if(current_view->buffer()->isReadonly())
-               WarnReadonly();
+               WarnReadonly(current_view->buffer()->fileName());
 
        if (!fd_form_url) {
                fd_form_url = create_form_form_url();
index eebc879f390c03aa9e04f27248228f06c83a3252..c98f6b260f947641eefbeae363c27e4c049e9ce0 100644 (file)
@@ -66,9 +66,9 @@ int Intl::SetSecondary(string const & lang)
 
 void Intl::update()
 {
-       int off, prim, sec;
-       
-       off = prim = sec = 0;
+       int off = 0;
+       int prim = 0;
+       int sec = 0;
        
        if (!keymapon) {
                off = 1;
@@ -219,11 +219,13 @@ void Intl::DispatchCallback(FL_OBJECT * ob, long code)
        if (itl!= 0) itl->Keymap(code);
 }
 
+
 extern "C" void C_Intl_DispatchCallback(FL_OBJECT * ob, long code)
 {
        Intl::DispatchCallback(ob, code);
 }
 
+
 void Intl::InitKeyMapper(bool on)
        /* initialize key mapper */
 {
@@ -291,7 +293,7 @@ void Intl::InitKeyMapper(bool on)
        
        Language->addto(_("other..."));
        Language2->addto(_("other..."));
-       otherkeymap = n+1;
+       otherkeymap = n + 1;
        if (!Language->select_text(prim_lang.c_str())) {
                Language->select(n+1);
                fl_set_input(fd_form_keymap->OtherKeymap, prim_lang.c_str());
@@ -300,7 +302,7 @@ void Intl::InitKeyMapper(bool on)
                trans->SetPrimary(prim_lang);
 
        if (!Language2->select_text(sec_lang.c_str())) {
-               Language2->select(n+1);
+               Language2->select(n + 1);
                fl_set_input(fd_form_keymap->OtherKeymap2, sec_lang.c_str());
        }
        else
@@ -319,6 +321,9 @@ void Intl::Keymap(long code)
        if (lyxerr.debugging(Debug::KBMAP))
                lyxerr << "KeyMap callback: " << code << endl;
 
+       // Did you wonder if it is possible to write spagetti code with
+       // other constructs thatn goto's? Well here we have a nice small
+       // spagetti example using a switch... (Lgb)
        switch (code) {
        case 0:
                /* cancel/hide */
index ca24e92654a4f0d081e2156682944eec3cb2033d..3a491f334df26a9c3f6ff5bd179d0f64479dcef2 100644 (file)
@@ -40,7 +40,7 @@ enum { ModsMask = ShiftMask | ControlMask | Mod1Mask};
    Returns   : length of printed string if ok, 0 otherwise.
 \* ---F------------------------------------------------------------------- */
 static
-void printKeysym( KeySym key, unsigned int mod, string & buf)
+void printKeysym(KeySym key, unsigned int mod, string & buf)
 {
        mod &= ModsMask;
 
@@ -64,7 +64,7 @@ void printKeysym( KeySym key, unsigned int mod, string & buf)
 \* ---F------------------------------------------------------------------- */
 
 static
-void printKeyTab( kb_key * tabPt, string & buf)
+void printKeyTab(kb_key * tabPt, string & buf)
 {
        unsigned int ksym, mod;
        
@@ -131,59 +131,55 @@ int kb_sequence::addkey(KeySym key,
 
 int kb_sequence::parse(char const * s)
 {
+       if(!s[0]) return 1;
+
        int i = 0;
        unsigned int mod = 0, nmod = 0;
-       KeySym key = 0;
-       char tbuf[100];
-       
-       if(!s[0]) return 1;
-       
        while(s[i]) {
                if(s[i] && (s[i]) <= ' ') ++i;
                if(!s[i]) break;
                
-               if(s[i+1] == '-')       { // is implicit that s[i] == true
+               if(s[i + 1] == '-')     { // is implicit that s[i] == true
                        switch(s[i]) {
                        case 's': case 'S':
                                mod |= ShiftMask;
-                               i+= 2;
+                               i += 2;
                                continue;
                        case 'c': case 'C':
                                mod |= ControlMask;
-                               i+= 2;
+                               i += 2;
                                continue;
                        case 'm': case 'M':
                                mod |= Mod1Mask;
-                               i+= 2;
+                               i += 2;
                                continue;
                        default:
-                               return i+1;
+                               return i + 1;
                        }
-               } else if(s[i] == '~' && s[i+1] && s[i+2] == '-') {
-                       switch(s[i+1]) {
+               } else if(s[i] == '~' && s[i + 1] && s[i + 2] == '-') {
+                       switch(s[i + 1]) {
                        case 's': case 'S':
                                nmod |= ShiftMask;
-                               i+= 3;
+                               i += 3;
                                continue;
                        case 'c': case 'C':
                                nmod |= ControlMask;
-                               i+= 3;
+                               i += 3;
                                continue;
                        case 'm': case 'M':
                                nmod |= Mod1Mask;
-                               i+= 3;
+                               i += 3;
                                continue;
                        default:
-                               return i+2;
+                               return i + 2;
                        }
                } else {
-                       int j = 0;
-                       for(j = i; s[j] && s[j] > ' '; ++j)
-                               tbuf[j-i] = s[j];    // (!!!check bounds :-)
+                       string tbuf;
+                       int j = i;
+                       for(; s[j] && s[j] > ' '; ++j)
+                               tbuf += s[j];    // (!!!check bounds :-)
                        
-                       tbuf[j-i] = '\0';
-         
-                       key = XStringToKeysym(tbuf);
+                       KeySym key = XStringToKeysym(tbuf.c_str());
                        if(key == NoSymbol) {
                                lyxerr[Debug::KBMAP]
                                        << "kbmap.C: No such keysym: "
@@ -282,7 +278,7 @@ KeySym kb_sequence::getsym()
        int l = length;
        if(l == 0) return NoSymbol;
        if(l < 0) l = -l;
-       return sequence[l-1];
+       return sequence[l - 1];
 }
 
 
@@ -316,7 +312,7 @@ void kb_sequence::reset()
 {
        delseq();
        curmap = stdmap;
-       if ( length > 0 ) length = -length;
+       if (length > 0) length = -length;
 }
 
 
@@ -368,7 +364,7 @@ int kb_keymap::lookup(KeySym key, unsigned int mod, kb_sequence * seq)
 
 #ifndef NO_HASH
        if(size < 0) {               // --- if hash table ---
-               hashval = ((key&0xff) ^ ((key>>8)&0xff)) % KB_HASHSIZE;
+               hashval = ((key & 0xff) ^ ((key >> 8) & 0xff)) % KB_HASHSIZE;
                tab = htable[hashval];
                if(!tab) {
                        seq->curmap = seq->stdmap;
@@ -381,7 +377,7 @@ int kb_keymap::lookup(KeySym key, unsigned int mod, kb_sequence * seq)
 
        // --- now search the list of keys ---
 
-       for( ; (tab->code & 0xffff) != NoSymbol; ++tab) {
+       for(; (tab->code & 0xffff) != NoSymbol; ++tab) {
                ksym =  tab->code;
                msk1 =  tab->mod      & 0xffff;
                msk0 = (tab->mod >> 16) & 0xffff;
@@ -485,7 +481,7 @@ int kb_keymap::defkey(kb_sequence * seq, int action, int idx /*= 0*/)
        int tsize;
        for(t = tab, tsize = 1; t->code != NoSymbol; ++t, ++tsize) {
                if(code == t->code && modmsk == t->mod) { // -- overwrite binding ---
-                       if(idx+1 == seq->length) {
+                       if(idx + 1 == seq->length) {
                                string buf;
                                seq->print(buf, true);
                                lyxerr[Debug::KEY]
index ad4c598b4c97960d9cc5426d70a0a1ae6f398db0..3926f99bbeb5fa7f51db8414032bd27d5c1943b3 100644 (file)
@@ -338,6 +338,8 @@ class LyXTextClass {
 public:
        ///
        typedef vector<LyXLayout> LayoutList;
+       ///
+       typedef LayoutList::const_iterator const_iterator;
 
        ///
        LyXTextClass (string const & = string(), 
@@ -345,9 +347,9 @@ public:
                      string const & = string());
 
        ///
-       LayoutList::const_iterator begin() const { return layoutlist.begin(); }
+       const_iterator begin() const { return layoutlist.begin(); }
        ///
-       LayoutList::const_iterator end() const { return layoutlist.end(); }
+       const_iterator end() const { return layoutlist.end(); }
        
        ///
        bool Read(string const & filename, bool merge = false);
@@ -507,6 +509,13 @@ class LyXTextClassList {
 public:
        ///
        typedef vector<LyXTextClass> ClassList;
+       ///
+       typedef ClassList::const_iterator const_iterator;
+       ///
+       const_iterator begin() const { return classlist.begin(); }
+       ///
+       const_iterator end() const { return classlist.end(); }
+       
        /// Gets layout structure from layout number and textclass number
        LyXLayout const & Style(ClassList::size_type textclass,
                                LyXTextClass::LayoutList::size_type layout) const;
index 1cd33780bfaa95a3d865e938a21d63f5ad71892a..9305d9afce1de98e66cf0a6cc5010c3e8ec8d3eb 100644 (file)
 #include "banner.xpm"
 #endif
 
-FD_form_title *fd_form_title;
-FD_form_paragraph *fd_form_paragraph;
-FD_form_paragraph_extra *fd_form_paragraph_extra;
-FD_form_search *fd_form_search;
-FD_form_character *fd_form_character;
-FD_form_document *fd_form_document;
-FD_form_paper *fd_form_paper;
-FD_form_table_options *fd_form_table_options;
-FD_form_table_extra *fd_form_table_extra;
-FD_form_quotes *fd_form_quotes;
-FD_form_preamble *fd_form_preamble;
-FD_form_table *fd_form_table;
-FD_form_print *fd_form_print;
-FD_form_sendto *fd_form_sendto;
-FD_form_figure *fd_form_figure;
-FD_form_screen *fd_form_screen;
-FD_form_toc *fd_form_toc;
-FD_form_ref *fd_form_ref;
-FD_LaTeXOptions *fd_latex_options; // from latexoptions.h
-FD_LaTeXLog *fd_latex_log; // from latexoptions.h
-Combox *combo_language;
-
-extern LyXServer *lyxserver;
+FD_form_title * fd_form_title;
+FD_form_paragraph * fd_form_paragraph;
+FD_form_paragraph_extra * fd_form_paragraph_extra;
+FD_form_search * fd_form_search;
+FD_form_character * fd_form_character;
+FD_form_document * fd_form_document;
+FD_form_paper * fd_form_paper;
+FD_form_table_options * fd_form_table_options;
+FD_form_table_extra * fd_form_table_extra;
+FD_form_quotes * fd_form_quotes;
+FD_form_preamble * fd_form_preamble;
+FD_form_table * fd_form_table;
+FD_form_print * fd_form_print;
+FD_form_sendto * fd_form_sendto;
+FD_form_figure * fd_form_figure;
+FD_form_screen * fd_form_screen;
+FD_form_toc * fd_form_toc;
+FD_form_ref * fd_form_ref;
+FD_LaTeXOptions * fd_latex_options; // from latexoptions.h
+FD_LaTeXLog * fd_latex_log; // from latexoptions.h
+Combox * combo_language;
+
+extern LyXServer * lyxserver;
 extern bool finished;  // flag, that we are quitting the program
 extern BufferList bufferlist;
 
@@ -161,8 +161,8 @@ extern "C" int LyX_XErrHandler(Display * display, XErrorEvent * xeev)
 }
 
 
-LyXGUI::LyXGUI(LyX *owner, int *argc, char *argv[], bool GUI)
-       :_owner(owner)
+LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
+       : _owner(owner)
 {
        gui = GUI;
        if (!gui)
@@ -197,7 +197,8 @@ LyXGUI::LyXGUI(LyX *owner, int *argc, char *argv[], bool GUI)
 
 
 // A destructor is always necessary  (asierra-970604)
-LyXGUI::~LyXGUI() {
+LyXGUI::~LyXGUI()
+{
         // Lyxserver was created in this class so should be destroyed
         // here.  asierra-970604
         if (lyxserver) {
@@ -441,20 +442,20 @@ void LyXGUI::create_forms()
        fl_set_counter_precision(fd_form_document->slider_tocdepth, 0);
        fl_addto_form(fd_form_document->form_document);
        combo_language = new Combox(FL_COMBOX_DROPLIST);
-       FL_OBJECT *ob = fd_form_document->choice_language;
+       FL_OBJECT * ob = fd_form_document->choice_language;
        combo_language->add(ob->x, ob->y, ob->w, ob->h, 200);
        combo_language->shortcut("#G", 1);
        fl_end_form();
        int n; // declared here because DEC cxx does not like multiple
               // declarations of variables in for() loops (JMarc)
-        for (n = 0; tex_babel[n][0]; n++) {
+        for (n = 0; tex_babel[n][0]; ++n) {
            combo_language->addto(tex_babel[n]);
        }
 
        // not really necessary, but we can do it anyway.
        fl_addto_choice(fd_form_document->choice_fontsize, "default|10|11|12");
        
-        for (n = 0; tex_fonts[n][0]; n++) {
+        for (n = 0; tex_fonts[n][0]; ++n) {
            fl_addto_choice(fd_form_document->choice_fonts, tex_fonts[n]);
        }
 
@@ -462,7 +463,7 @@ void LyXGUI::create_forms()
                        "default|latin1|latin2|latin5"
                        "|koi8-r|koi8-u|cp866|cp1251");
 
-        for (n = 0; tex_graphics[n][0]; n++) {
+        for (n = 0; tex_graphics[n][0]; ++n) {
            fl_addto_choice(fd_form_document->choice_postscript_driver,
                                        tex_graphics[n]);
        }
@@ -639,7 +640,7 @@ void LyXGUI::runTime()
 }
 
 
-void LyXGUI::regBuf(Buffer *b)
+void LyXGUI::regBuf(Buffer * b)
 {
        lyxViews->view()->buffer(b);
 }
index 70bfeb83b213e55afe5502e18d313a690816bf55..1084810b02ac6e7e39231a21fc8c2a8e2a67e901 100644 (file)
@@ -32,7 +32,7 @@
 #include "insets/insetindex.h"
 #include "LyXView.h"
 
-extern BufferView *current_view;
+extern BufferView * current_view;
 
 extern FD_form_paragraph * fd_form_paragraph;
 extern FD_form_paragraph_extra * fd_form_paragraph_extra;
@@ -305,39 +305,41 @@ void updateAllVisibleBufferRelatedPopups()
 }
 
 // Extract shortcut from <ident>|<shortcut> string
-const char* flyx_shortcut_extract(const char*sc)
+char const * flyx_shortcut_extract(char const * sc)
 {
        // Find '|' in the sc and return the string after that.
-       register char const *sd = sc;
-       while(sd[0]!= 0 && sd[0] != '|') sd++;
+       register char const * sd = sc;
+       while(sd[0]!= 0 && sd[0] != '|') ++sd;
 
        if (sd[0] == '|') {
-               sd++;
+               ++sd;
                //lyxerr << sd << endl;
                return sd;
        }
        return "";
 }
 
+
 // Extract identifier from <ident>|<shortcut> string
-const char* flyx_ident_extract(char const *sc)
+char const * flyx_ident_extract(char const * sc)
 {
-       register char const *se = sc;
-       while(se[0]!= 0 && se[0] != '|') se++;
+       register char const * se = sc;
+       while(se[0]!= 0 && se[0] != '|') ++se;
 
        if (se[0] == 0) return sc;
        
-       char * sb = new char[se-sc + 1];
+       char * sb = new char[se - sc + 1];
        int index = 0;
-       register char const *sd = sc;
+       register char const * sd = sc;
        while (sd != se) {
                sb[index] = sd[0];
-               index++; sd++;
+               ++index; ++sd;
        }
        sb[index] = 0;
        return sb;
 }
 
+
 //
 void WriteAlert(string const & s1, string const & s2, string const & s3)
 {
@@ -375,6 +377,7 @@ bool AskQuestion(string const & s1, string const & s2, string const & s3)
 #endif
 }
 
+
 // Returns 1 for yes, 2 for no, 3 for cancel.
 int AskConfirmation(string const & s1, string const & s2, string const & s3)
 {
@@ -399,7 +402,7 @@ int AskConfirmation(string const & s1, string const & s2, string const & s3)
 // Asks for a text
 string askForText(string const & msg, string const & dflt)
 {
-       const char * tmp;
+       char const * tmp;
        fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")));
        fl_set_resource("flInput.ok.label", idex(_("OK|#O")));
        fl_set_resource("flInput.clear.label", idex(_("Clear|#e")));
@@ -410,12 +413,12 @@ string askForText(string const & msg, string const & dflt)
          return string();
 }
 
+
 // Inform the user that the buffer is read-only, and that changes in the
 // dialog box that is to appear will be ignored.
-void WarnReadonly()
+void WarnReadonly(string const & file)
 {
        WriteAlert(_("Any changes will be ignored"),
                   _("The document is read-only:"),
-                  current_view->buffer()->fileName());
+                  file);
 }
-
index c7291eb142efe9e645d752eeea9b09d9211eb7d1..a8d3eb203d8ac0065923f1ce2cbdb9a551031c93 100644 (file)
@@ -1,13 +1,13 @@
 // -*- C++ -*-
 /* This file is part of
-* ======================================================
-* 
-*           LyX, The Document Processor
-*        
-*           Copyright (C) 1995 1996 Matthias Ettrich
-*           and the LyX Team.
-*
-* ====================================================== */
+ * ======================================================
+ 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 1996 Matthias Ettrich
+ *           Copyright 1995-1999 The LyX Team
+ *
+ * ====================================================== */
 
 // Misc. GUI specific routines
 
@@ -29,12 +29,12 @@ void CloseAllBufferRelatedPopups();
 void updateAllVisibleBufferRelatedPopups();
 
 /// Extract shortcut from <ident>|<shortcut> string
-const char* flyx_shortcut_extract(const char*sc);
+char const * flyx_shortcut_extract(char const * sc);
 /// Make a shortnamed version of the above func
 #define scex flyx_shortcut_extract
 
 /// Extract shortcut from <ident>|<shortcut> string
-const char* flyx_ident_extract(char const *sc);
+char const * flyx_ident_extract(char const * sc);
 /// Make a shortnamed versjon of the above func
 #define idex flyx_ident_extract
 
@@ -57,7 +57,7 @@ int AskConfirmation(string const & s1, string const & s2 = string(),
 string askForText(string const & msg, string const & dflt = string());
 
 /// Informs the user that changes in the coming form will be ignored
-void WarnReadonly();
+void WarnReadonly(string const & file);
 
 // inlined functions
 /// rings the audio bell.
index 2614603acb91852cbf8ddae03f5b879e7c19715a..20be3713c55e4e12b6870a0b1dcbc2ff7c5ee995 100644 (file)
@@ -32,7 +32,7 @@ template<class A> inline void Assert(A * ptr)
 
 #else
 
-template<class A> inline void Assert(A /*assertion*/) {;}
+template<class A> inline void Assert(A /*assertion*/) {}
 
 #endif /* ENABLE_ASSERTIONS */
 
index 573c6a0a36358d8bd362e9e60042fd087adb4fe8..06875d2159097c8322a1233b83991582abdf5471 100644 (file)
@@ -89,14 +89,6 @@ int  strToInt(string const & str)
 
 string lowercase(string const & a)
 {
-#if 0
-       string tmp;
-       string::const_iterator cit = a.begin();
-       for(; cit != a.end(); ++cit) {
-               tmp += static_cast<char>(tolower(*cit));
-       }
-       return tmp;
-#endif
        string tmp(a);
        transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
        return tmp;
@@ -159,14 +151,6 @@ string tostr(bool b)
 }
 
 
-#if 0
-string tostr(float f)
-{
-       return tostr(double(f));
-}
-#endif
-
-
 string tostr(double d)
 {
        // should use string stream
@@ -234,9 +218,15 @@ bool contains(char const * a, char const * b)
 }
 
 
-int countChar(string const & a, char const c)
+unsigned int countChar(string const & a, char const c)
 {
+#ifdef HAVE_STD_COUNT
        return count(a.begin(), a.end(), c);
+#else
+       unsigned int n = 0;
+       count(a.begin(), a.end(), c, n);
+       return n;
+#endif
 }
 
 
index 0769ba26189deba734af16603a1f20b6010ea4bc..f1110316585ca268279ba6d4ec98c1560ffc334a 100644 (file)
@@ -119,7 +119,7 @@ bool contains(string const & a, string const & b);
 bool contains(char const * a, char const * b);
 
 /// Counts how many of character c there is in a
-int countChar(string const & a, char const c);
+unsigned int countChar(string const & a, char const c);
 
 /** Extracts a token from this string at the nth delim.
   Doesn't modify the original string. Similar to strtok.
index d348deedb2dc16111265ce6e567074a02df309d2..4d3339e95edc7b4795e3af400705e3298fdaa09d 100644 (file)
@@ -4,8 +4,8 @@
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *          Copyright (C) 1995-1999 The LyX Team.
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-1999 The LyX Team.
  *
  * ====================================================== */
 
index 5fcfce853936a4abe43da91395004112c92c5003..18fb9d0b51b514972ba310dd78901e67cc4ae1b7 100644 (file)
@@ -1,12 +1,12 @@
 /* This file is part of
-* ====================================================== 
-* 
-*           LyX, The Document Processor
-*       
-*          Copyright (C) 1995 Matthias Ettrich
-*           Copyright (C) 1995-1998 The LyX Team.
-*
-* ====================================================== */
+ * ====================================================== 
+ 
+ *           LyX, The Document Processor
+ *      
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1999 The LyX Team.
+ *
+ * ====================================================== */
 
 #include <config.h>
 #include <cstdlib>
@@ -702,7 +702,7 @@ LyXText::NextBreakPoint(Row * row, int width)
 
 
 /* returns the minimum space a row needs on the screen in pixel */
-int LyXText::Fill(Row * row, int paperwidth)
+int LyXText::Fill(Row * row, int paper_width)
 {
    int w, fill;
    /* get the pure distance */
@@ -767,7 +767,7 @@ int LyXText::Fill(Row * row, int paperwidth)
       }
    }
    
-   fill = paperwidth - w - RightMargin(row);
+   fill = paper_width - w - RightMargin(row);
    return fill;
 }
 
index 70580c4a00e15721c8f4bf0643d4c301f7e63a7b..c012715c5f2d0cf99cced906966f13df39969b32 100644 (file)
@@ -744,10 +744,10 @@ void  LyXText::SetFont(LyXFont font, bool toggleall)
 }
 
 
-void LyXText::RedoHeightOfParagraph(LyXCursor cursor)
+void LyXText::RedoHeightOfParagraph(LyXCursor cur)
 {
-       Row * tmprow = cursor.row;
-       long y = cursor.y - tmprow->baseline;
+       Row * tmprow = cur.row;
+       long y = cur.y - tmprow->baseline;
 
        SetHeightOfRow(tmprow);
        LyXParagraph * first_phys_par = tmprow->par->FirstPhysicalPar();
@@ -768,15 +768,15 @@ void LyXText::RedoHeightOfParagraph(LyXCursor cursor)
        status = LyXText::NEED_MORE_REFRESH;
        refresh_y = y;
        refresh_row = tmprow;
-       SetCursor(cursor.par, cursor.pos);
+       SetCursor(cur.par, cur.pos);
 }
 
 
-void LyXText::RedoDrawingOfParagraph(LyXCursor cursor)
+void LyXText::RedoDrawingOfParagraph(LyXCursor cur)
 {
-       Row * tmprow = cursor.row;
+       Row * tmprow = cur.row;
    
-       long y = cursor.y - tmprow->baseline;
+       long y = cur.y - tmprow->baseline;
        SetHeightOfRow(tmprow);
        LyXParagraph * first_phys_par = tmprow->par->FirstPhysicalPar();
        /* find the first row of the paragraph */
@@ -797,21 +797,21 @@ void LyXText::RedoDrawingOfParagraph(LyXCursor cursor)
                refresh_row = tmprow;
        }
        status = LyXText::NEED_MORE_REFRESH;
-       SetCursor(cursor.par, cursor.pos);
+       SetCursor(cur.par, cur.pos);
 }
 
 
 /* deletes and inserts again all paragaphs between the cursor
 * and the specified par 
 * This function is needed after SetLayout and SetFont etc. */
-void LyXText::RedoParagraphs(LyXCursor cursor, LyXParagraph * endpar)
+void LyXText::RedoParagraphs(LyXCursor cur, LyXParagraph * endpar)
 {
        Row * tmprow2;
        LyXParagraph * tmppar, * first_phys_par;
    
-       Row * tmprow = cursor.row;
+       Row * tmprow = cur.row;
    
-       long y = cursor.y - tmprow->baseline;
+       long y = cur.y - tmprow->baseline;
    
        if (!tmprow->previous){
                first_phys_par = FirstParagraph();   // a trick/hack for UNDO
@@ -3482,27 +3482,25 @@ void LyXText::SetCursorParUndo()
                cursor.par->ParFromPos(cursor.pos)->next); 
 }
 
-void LyXText::RemoveTableRow(LyXCursor * cursor)
+void LyXText::RemoveTableRow(LyXCursor * cur)
 {
-    int
-        cell_act,
-        cell = -1,
-        cell_org = 0,
-        ocell = 0;
+       int cell = -1;
+       int cell_org = 0;
+       int ocell = 0;
     
     /* move to the previous row */
-    cell_act = NumberOfCell(cursor->par, cursor->pos);
+    int cell_act = NumberOfCell(cur->par, cur->pos);
     if (cell < 0)
         cell = cell_act;
-    while (cursor->pos && !cursor->par->IsNewline(cursor->pos-1))
-        cursor->pos--;
-    while (cursor->pos && 
-           !cursor->par->table->IsFirstCell(cell_act)){
-        cursor->pos--;
-        while (cursor->pos && !cursor->par->IsNewline(cursor->pos-1))
-            cursor->pos--;
-            cell--;
-            cell_act--;
+    while (cur->pos && !cur->par->IsNewline(cur->pos - 1))
+        cur->pos--;
+    while (cur->pos && 
+           !cur->par->table->IsFirstCell(cell_act)) {
+        cur->pos--;
+        while (cur->pos && !cur->par->IsNewline(cur->pos - 1))
+            cur->pos--;
+            --cell;
+            --cell_act;
     }
     /* now we have to pay attention if the actual table is the
        main row of TableContRows and if yes to delete all of them */
@@ -3511,25 +3509,25 @@ void LyXText::RemoveTableRow(LyXCursor * cursor)
     do {
         ocell = cell;
         /* delete up to the next row */
-        while (cursor->pos < cursor->par->Last() && 
+        while (cur->pos < cur->par->Last() && 
                (cell_act == ocell
-                || !cursor->par->table->IsFirstCell(cell_act))){
-            while (cursor->pos < cursor->par->Last() &&
-                   !cursor->par->IsNewline(cursor->pos))
-                cursor->par->Erase(cursor->pos);
-            cell++;
-            cell_act++;
-            if (cursor->pos < cursor->par->Last())
-                cursor->par-> Erase(cursor->pos);
+                || !cur->par->table->IsFirstCell(cell_act))) {
+            while (cur->pos < cur->par->Last() &&
+                   !cur->par->IsNewline(cur->pos))
+                cur->par->Erase(cur->pos);
+            ++cell;
+            ++cell_act;
+            if (cur->pos < cur->par->Last())
+                cur->par->Erase(cur->pos);
         }
-        if (cursor->pos && cursor->pos == cursor->par->Last()){
-            cursor->pos--;
-            cursor->par->Erase(cursor->pos); // no newline at the very end!
+        if (cur->pos && cur->pos == cur->par->Last()) {
+            cur->pos--;
+            cur->par->Erase(cur->pos); // no newline at the very end!
         }
-    } while (((cell+1) < cursor->par->table->GetNumberOfCells()) &&
-             !cursor->par->table->IsContRow(cell_org) &&
-             cursor->par->table->IsContRow(cell));
-    cursor->par->table->DeleteRow(cell_org);
+    } while (((cell + 1) < cur->par->table->GetNumberOfCells()) &&
+             !cur->par->table->IsContRow(cell_org) &&
+             cur->par->table->IsContRow(cell));
+    cur->par->table->DeleteRow(cell_org);
     return;
 }
 
index ee3b985ff8b769081166059850969ce06dfc9949..c35a99530fecc39d9ca4b51e8feba77912c599bd 100644 (file)
@@ -64,9 +64,7 @@ Trans::~Trans()
 void Trans::InsertException(Trans::keyexc & exclist, char c,
                            string const & data, bool flag, tex_accent accent)
 {
-       keyexc p;
-
-       p = new Keyexc; 
+       keyexc p = new Keyexc; 
        p->next = exclist;
        p->c = c;
 
@@ -259,12 +257,11 @@ int Trans::Load(LyXLex & lex)
                break;
                case KMAP: {
                        unsigned char key_from;
-                       char * string_to;
 
                        if (lyxerr.debugging(Debug::KBMAP))
                                lyxerr << "KMAP:\t" << lex.text() << endl;
                        if (lex.next(true)) {
-                               key_from= lex.text()[0];
+                               key_from = lex.text()[0];
                                if (lyxerr.debugging(Debug::KBMAP))
                                        lyxerr << "\t`" << lex.text() << "'"
                                               << endl;
@@ -273,7 +270,8 @@ int Trans::Load(LyXLex & lex)
 
                        if (lex.next(true)) {
                                char const * t = lex.text();
-                               string_to = strcpy(new char[strlen(t)+1], t);
+                               char * string_to =
+                                       strcpy(new char[strlen(t)+1], t);
                                keymap_[key_from] = string_to;
                                if (lyxerr.debugging(Debug::KBMAP))
                                        lyxerr << "\t`" << string_to << "'"
index 1b2937f16ab6ad10652fd38421f2196757d76023..e4052f975af862096fd291bddb6752b7854b38e4 100644 (file)
@@ -25,12 +25,7 @@ struct KmodInfo {
        tex_accent accent;
        string allowed;
        KmodException exception_list;    
-
-       
-       //KmodInfo(const KmodInfo&);
        KmodInfo();
-       
-       //KmodInfo& operator= (const KmodInfo&);
 };
 
 #endif
index 02b5719193dbcaa82d5e84002ab96442abc94b9c..26beac92ef2753463adbfbac375118410785afdc 100644 (file)
@@ -26,9 +26,9 @@ extern BufferView * current_view;
 // TransFSMData
 TransFSMData::TransFSMData()
 {
-    deadkey_ = deadkey2_ = 0;
-    deadkey_info_.accent = deadkey2_info_.accent = TEX_NOACCENT;
-    comb_info_ = 0;
+       deadkey_ = deadkey2_ = 0;
+       deadkey_info_.accent = deadkey2_info_.accent = TEX_NOACCENT;
+       comb_info_ = 0;
 }
 
 
@@ -39,175 +39,172 @@ char const TransState::TOKEN_SEP = 4;
 // TransInitState
 TransInitState::TransInitState()
 {
-    init_state_ = this;
+       init_state_ = this;
 }
 
 
 string TransInitState::normalkey(char c, char * t)
 {
-    string res;
-    if (t != 0)
-       res = t;
-    else
-       res = c;
+       string res;
+       if (t)  res = t;
+       else res = c;
        
-    return res;
+       return res;
 }
 
 
 string TransInitState::deadkey(char c, KmodInfo d)
 {
-    deadkey_ = c;
-    deadkey_info_ = d;
-    currentState = deadkey_state_;
-    return string();
+       deadkey_ = c;
+       deadkey_info_ = d;
+       currentState = deadkey_state_;
+       return string();
 }
 
 
 // TransDeadkeyState
 TransDeadkeyState::TransDeadkeyState()
 {
-    deadkey_state_ = this;
+       deadkey_state_ = this;
 }
 
 
 string TransDeadkeyState::normalkey(char c, char * trans)
 {
-    string res;
-    
-    // Check if it is an exception
-    KmodException l = deadkey_info_.exception_list;
-    while(l != 0) {
-       if (l->c == c) {
-           res = l->data;
-           break;
+       string res;
+       
+       // Check if it is an exception
+       KmodException l = deadkey_info_.exception_list;
+       while(l != 0) {
+               if (l->c == c) {
+                       res = l->data;
+                       break;
+               }
+               l = l->next;
        }
-       l = l->next;
-    }
-    if (l == 0) {
-       // Not an exception. Check if it allowed
-       if (current_view->buffer()->params.allowAccents == true ||
-           countChar(deadkey_info_.allowed, c) > 0) {
-           res = DoAccent(c, deadkey_info_.accent);
-       } else {
-           // Not allowed
-           if (deadkey_!= 0)
-               res = deadkey_;
-           res+= TOKEN_SEP;
-           res+= trans;
+       if (l == 0) {
+               // Not an exception. Check if it allowed
+               if (current_view->buffer()->params.allowAccents == true ||
+                   countChar(deadkey_info_.allowed, c) > 0) {
+                       res = DoAccent(c, deadkey_info_.accent);
+               } else {
+                       // Not allowed
+                       if (deadkey_!= 0)
+                               res = deadkey_;
+                       res+= TOKEN_SEP;
+                       res+= trans;
+               }
        }
-    }
-    currentState = init_state_;
-    return res;
+       currentState = init_state_;
+       return res;
 }
 
 
 string TransDeadkeyState::deadkey(char c, KmodInfo d)
 {
-    string res;
-    
-    // Check if the same deadkey was typed twice
-    if (deadkey_ == c) {
-       res = deadkey_;
-       deadkey_ = 0;
-       deadkey_info_.accent = TEX_NOACCENT;
-       currentState = init_state_;
-       return res;
-    }
-    
-    // Check if it is a combination or an exception
-    KmodException l;
-    l = deadkey_info_.exception_list;
-    
-    while(l) {
-       if (l->combined == true && l->accent == d.accent) {
-           deadkey2_ = c;
-           deadkey2_info_ = d;
-           comb_info_ = l;
-           currentState = combined_state_;
-           return string();
+       string res;
+       
+       // Check if the same deadkey was typed twice
+       if (deadkey_ == c) {
+               res = deadkey_;
+               deadkey_ = 0;
+               deadkey_info_.accent = TEX_NOACCENT;
+               currentState = init_state_;
+               return res;
        }
-       if (l->c == c) {
-           res = l->data;
-           deadkey_ = 0;
-           deadkey_info_.accent = TEX_NOACCENT;
-           currentState = init_state_;
-           return res;
+       
+       // Check if it is a combination or an exception
+       KmodException l;
+       l = deadkey_info_.exception_list;
+       
+       while(l) {
+               if (l->combined == true && l->accent == d.accent) {
+                       deadkey2_ = c;
+                       deadkey2_info_ = d;
+                       comb_info_ = l;
+                       currentState = combined_state_;
+                       return string();
+               }
+               if (l->c == c) {
+                       res = l->data;
+                       deadkey_ = 0;
+                       deadkey_info_.accent = TEX_NOACCENT;
+                       currentState = init_state_;
+                       return res;
+               }
+               l = l->next;
        }
        
-       l = l->next;
-    }
-    
-    // Not a combination or an exception. 
-    // Output deadkey1 and keep deadkey2
-    
-    if (deadkey_!= 0)
-       res = deadkey_;
-    deadkey_ = c;
-    deadkey_info_ = d;
-    currentState = deadkey_state_;
-    return res;
+       // Not a combination or an exception. 
+       // Output deadkey1 and keep deadkey2
+       
+       if (deadkey_!= 0)
+               res = deadkey_;
+       deadkey_ = c;
+       deadkey_info_ = d;
+       currentState = deadkey_state_;
+       return res;
 }
 
 
 TransCombinedState::TransCombinedState()
 {
-    combined_state_ = this;
+       combined_state_ = this;
 }
 
 
-string TransCombinedState::normalkey(char c, char *trans)
+string TransCombinedState::normalkey(char c, char * trans)
 {
-    string res;
-    
-    // Check if the key is allowed on the combination
-    if (countChar(comb_info_->data, c) > 0) {
-       string temp;
-       temp = DoAccent(c, deadkey2_info_.accent);
-       res = DoAccent(temp, deadkey_info_.accent);
-       currentState = init_state_;
-    } else {
-       // Not allowed. Output deadkey1 and check deadkey2 + c
-       if (deadkey_!= 0)
-           res+= deadkey_;
-       res+= TOKEN_SEP;
-       deadkey_ = deadkey2_;
-       deadkey_info_ = deadkey2_info_;
-       // Call deadkey state and leave it to setup the FSM
-       res+= deadkey_state_->normalkey(c, trans);
-    }
-    return res;
+       string res;
+       
+       // Check if the key is allowed on the combination
+       if (countChar(comb_info_->data, c) > 0) {
+               string temp;
+               temp = DoAccent(c, deadkey2_info_.accent);
+               res = DoAccent(temp, deadkey_info_.accent);
+               currentState = init_state_;
+       } else {
+               // Not allowed. Output deadkey1 and check deadkey2 + c
+               if (deadkey_ != 0)
+                       res += deadkey_;
+               res += TOKEN_SEP;
+               deadkey_ = deadkey2_;
+               deadkey_info_ = deadkey2_info_;
+               // Call deadkey state and leave it to setup the FSM
+               res += deadkey_state_->normalkey(c, trans);
+       }
+       return res;
 }
 
 
 string TransCombinedState::deadkey(char c, KmodInfo d)
 {
-    // Third key in a row. Output the first one and
-    // reenter with shifted deadkeys
-    string res;
-    if (deadkey_ != 0)
-       res = deadkey_;
-    res += TOKEN_SEP;
-    deadkey_ = deadkey2_;
-    deadkey_info_ = deadkey2_info_;
-    res += deadkey_state_->deadkey(c, d);
-    return res;
+       // Third key in a row. Output the first one and
+       // reenter with shifted deadkeys
+       string res;
+       if (deadkey_ != 0)
+               res = deadkey_;
+       res += TOKEN_SEP;
+       deadkey_ = deadkey2_;
+       deadkey_info_ = deadkey2_info_;
+       res += deadkey_state_->deadkey(c, d);
+       return res;
 }
 
 
 // TransFSM
 TransFSM::TransFSM():
-    TransFSMData(),
-    TransInitState(),
-    TransDeadkeyState(),
-    TransCombinedState()
+       TransFSMData(),
+       TransInitState(),
+       TransDeadkeyState(),
+       TransCombinedState()
 {
-    currentState = init_state_;
+       currentState = init_state_;
 }
 
 
 // TransManager
-    
+
 TransManager::TransManager()
        : active_(0), t1_(new Trans), t2_(new Trans)
 {}
@@ -218,85 +215,85 @@ Trans * TransManager::default_ = new Trans;
 
 TransManager::~TransManager() 
 { 
-    delete t1_;
-    delete t2_;
+       delete t1_;
+       delete t2_;
 }
 
 
 int TransManager::SetPrimary(string const & language)
 {
-    if (t1_->GetName() == language) 
-       return 0;
+       if (t1_->GetName() == language) 
+               return 0;
        
-    return t1_->Load(language);
+       return t1_->Load(language);
 }
 
 
 int TransManager::SetSecondary(string const & language)
 {
-    if (t2_->GetName() == language)
-       return 0;
+       if (t2_->GetName() == language)
+               return 0;
        
-    return t2_->Load(language);
+       return t2_->Load(language);
 }
 
 
 bool TransManager::setCharset(char const * set)
 {
-    return chset_.loadFile(set);
+       return chset_.loadFile(set);
 }
 
 
 void TransManager::EnablePrimary()
 {
-    if (t1_->IsDefined())
-       active_ = t1_;
-
-    lyxerr[Debug::KBMAP] << "Enabling primary keymap" << endl;
+       if (t1_->IsDefined())
+               active_ = t1_;
+       
+       lyxerr[Debug::KBMAP] << "Enabling primary keymap" << endl;
 }
 
 
 void TransManager::EnableSecondary()
 {
-    if (t2_->IsDefined( ))
-       active_ = t2_;
-    lyxerr[Debug::KBMAP] << "Enabling secondary keymap" << endl;
+       if (t2_->IsDefined())
+               active_ = t2_;
+       lyxerr[Debug::KBMAP] << "Enabling secondary keymap" << endl;
 }
 
 
 void TransManager::DisableKeymap()
 {
-    active_ = default_;
-    lyxerr[Debug::KBMAP] << "Disabling keymap" << endl;
+       active_ = default_;
+       lyxerr[Debug::KBMAP] << "Disabling keymap" << endl;
 }
 
 
 void  TransManager::TranslateAndInsert(char c, LyXText * text)
 {
-    string res = active_->process(c, *this);
-    
-    // Process with tokens
-    string temp;
+       string res = active_->process(c, *this);
+       
+       // Process with tokens
+       string temp;
        
-    while(res.length() > 0) {
-       res = split(res, temp, TransState::TOKEN_SEP);
-       insert(temp, text);
-    }
+       while(res.length() > 0) {
+               res = split(res, temp, TransState::TOKEN_SEP);
+               insert(temp, text);
+       }
 }
 
 
 void TransManager::insertVerbatim(string const & str, LyXText * text)
 {      
-    int l = str.length();
+       int l = str.length();
        
-    for (int i = 0; i < l; ++i){
-       if (str[i] == '\"' 
-           && text->GetFont(text->cursor.par,
-                            text->cursor.pos).latex() == LyXFont::OFF)
-           InsertCorrectQuote();
-       else
-           text->InsertChar(str[i]);
-    }
+       for (int i = 0; i < l; ++i){
+               if (str[i] == '\"' 
+                   && text->GetFont(text->cursor.par,
+                                    text->cursor.pos).latex() == LyXFont::OFF)
+                       InsertCorrectQuote();
+               else
+                       text->InsertChar(str[i]);
+       }
 }
 
 
@@ -305,7 +302,7 @@ void TransManager::insert(string str, LyXText * text)
        // Go through the character encoding only if the current 
        // encoding (chset_->name()) matches the current font_norm
        // (lyrxc->font_norm
-
+       
        // Is false to speak about "only if" the current encoding will
        // almost always be equal to font_norm.
        pair<bool, int> enc = chset_.encodeString(str);
@@ -327,30 +324,28 @@ void TransManager::insert(string str, LyXText * text)
 
 void TransManager::deadkey(char c, tex_accent accent, LyXText * t)
 {
-    KmodInfo i;
-    string res;
-    
-    if (c == 0 && active_ != default_) {
-       // A deadkey was pressed that cannot be printed
-       // or a accent command was typed in the minibuffer
-       
-       if (active_->isAccentDefined(accent, i) == true) {
-           res = trans_fsm_.currentState->deadkey(c, i);
-           insert(res, t);
-           return;
+       if (c == 0 && active_ != default_) {
+               // A deadkey was pressed that cannot be printed
+               // or a accent command was typed in the minibuffer
+               KmodInfo i;
+               if (active_->isAccentDefined(accent, i) == true) {
+                       string res = trans_fsm_.currentState->deadkey(c, i);
+                       insert(res, t);
+                       return;
+               }
        }
-    }
-    
-    if (active_ == default_ || c == 0) {
-       i.accent = accent;
-       i.allowed = lyx_accent_table[accent].native;
-       i.data.clear();
-       i.exception_list = 0;
        
-       string res = trans_fsm_.currentState->deadkey(c, i);
-       insert(res, t);
-    } else {
-       // Go through the translation
-       TranslateAndInsert(c, t);
-    }
+       if (active_ == default_ || c == 0) {
+               KmodInfo i;
+               i.accent = accent;
+               i.allowed = lyx_accent_table[accent].native;
+               i.data.clear();
+               i.exception_list = 0;
+               
+               string res = trans_fsm_.currentState->deadkey(c, i);
+               insert(res, t);
+       } else {
+               // Go through the translation
+               TranslateAndInsert(c, t);
+       }
 }
index 7e23cc46dd81c7b721e17915820f942cad25f25a..93cc95adfe0c6ea49a3d8598a6777e530faac967 100644 (file)
@@ -61,38 +61,37 @@ public:
 
 
 /// Init State
-class TransInitState: 
+class TransInitState 
        virtual public TransFSMData,
        public TransState {
 public:
-               ///
-               TransInitState();
-               ///
-               virtual string normalkey(char, char *);
-               ///
-               virtual bool backspace() { return true; }
-               ///
-               virtual string deadkey(char, KmodInfo);
+       ///
+       TransInitState();
+       ///
+       virtual string normalkey(char, char *);
+       ///
+       virtual bool backspace() { return true; }
+       ///
+       virtual string deadkey(char, KmodInfo);
 };
 
 
 /// Deadkey State
-class TransDeadkeyState: 
+class TransDeadkeyState 
        virtual public TransFSMData,
        public TransState {
 public:
-               ///
-               TransDeadkeyState();
-               ///
-               virtual string normalkey(char, char *);
-               ///
-               virtual bool backspace()
-       {
+       ///
+       TransDeadkeyState();
+       ///
+       virtual string normalkey(char, char *);
+       ///
+       virtual bool backspace() {
                currentState = init_state_;
                return false;
        }
-               ///
-               virtual string deadkey(char, KmodInfo);
+       ///
+       virtual string deadkey(char, KmodInfo);
 };
 
 
@@ -101,13 +100,12 @@ class TransCombinedState:
        virtual public TransFSMData,
        public TransState {
 public:
-               ///
-               TransCombinedState();
-               ///
-               virtual string normalkey(char, char *);
-               ///
-               virtual bool backspace()
-       {
+       ///
+       TransCombinedState();
+       ///
+       virtual string normalkey(char, char *);
+       ///
+       virtual bool backspace() {
                // cancel the second deadkey
                deadkey2_ = 0;
                deadkey2_info_.accent = TEX_NOACCENT;
@@ -115,13 +113,13 @@ public:
                
                return false;
        }
-               ///
-               virtual string deadkey(char, KmodInfo);
+       ///
+       virtual string deadkey(char, KmodInfo);
 };
 
 
 ///
-class TransFSM       
+class TransFSM :       
        virtual public TransFSMData,
        public TransInitState,
        public TransDeadkeyState,
@@ -132,9 +130,9 @@ public:
        TransFSM();
 };
 
+
 ///
-class TransManager
-{
+class TransManager {
 private:
        ///
        TransFSM trans_fsm_;
@@ -170,8 +168,7 @@ public:
        ///
        bool setCharset(const char *);
        ///
-       bool backspace()
-       {
+       bool backspace() {
                return trans_fsm_.currentState->backspace();
        }
        ///