X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView.C;h=a9abd9ff9cc6112a7fc83383395c17a3d6888347;hb=a858be7332e331e0244e4dba7b0931b6072ffd3d;hp=ff27c73eb25353a4b2240bc9ac720b84dc9a1d81;hpb=27de1486ca34aaad446adb798d71a77d6f6304da;p=lyx.git diff --git a/src/BufferView.C b/src/BufferView.C index ff27c73eb2..a9abd9ff9c 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -1,21 +1,24 @@ // -*- C++ -*- /* 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 -#include +#include +#include + #include -#include #include +#include "support/lstrings.h" + #ifdef __GNUG__ #pragma implementation #endif @@ -30,7 +33,7 @@ #include "lyxscreen.h" #include "up.xpm" #include "down.xpm" -#include "error.h" +#include "debug.h" #include "lyxdraw.h" #include "lyx_gui_misc.h" #include "BackStack.h" @@ -38,12 +41,6 @@ #include "lyx_cb.h" #include "gettext.h" -// $Id: BufferView.C,v 1.1 1999/09/27 18:44:36 larsbj Exp $ - -#if !defined(lint) && !defined(WITH_WARNINGS) -static char vcid[] = "$Id: BufferView.C,v 1.1 1999/09/27 18:44:36 larsbj Exp $"; -#endif /* lint */ - extern BufferList bufferlist; void sigchldhandler(pid_t pid, int *status); @@ -93,7 +90,7 @@ BufferView::~BufferView() void BufferView::setBuffer(Buffer *b) { - lyxerr.debug("Setting buffer in BufferView"); + lyxerr.debug() << "Setting buffer in BufferView" << endl; if (_buffer) { _buffer->InsetSleep(); _buffer->delUser(this); @@ -115,7 +112,7 @@ void BufferView::setBuffer(Buffer *b) } if (_buffer) { - lyxerr.debug(LString(" Buffer addr: ") + PTR_AS_INT(_buffer)); + lyxerr.debug() << " Buffer addr: " << _buffer << endl; _buffer->addUser(this); _owner->getMenus()->showMenus(); // If we don't have a text object for this, we make one @@ -130,7 +127,7 @@ void BufferView::setBuffer(Buffer *b) updateAllVisibleBufferRelatedPopups(); _buffer->InsetWakeup(); } else { - lyxerr.debug(" No Buffer!"); + lyxerr.debug() << " No Buffer!" << endl; _owner->getMenus()->hideMenus(); //workAreaExpose(); updateScrollbar(); @@ -169,7 +166,7 @@ static bool lgb_hack = false; void BufferView::redraw() { - lyxerr.debug("BufferView::redraw()"); + lyxerr.debug() << "BufferView::redraw()" << endl; lgb_hack = true; fl_redraw_object(work_area); fl_redraw_object(scrollbar); @@ -258,7 +255,7 @@ void BufferView::updateScrollbar() void BufferView::redoCurrentBuffer() { - lyxerr.debug("BufferView::redoCurrentBuffer"); + lyxerr.debug() << "BufferView::redoCurrentBuffer" << endl; if (_buffer && _buffer->text) { resize(); _owner->updateLayoutChoice(); @@ -268,7 +265,7 @@ void BufferView::redoCurrentBuffer() int BufferView::resizeCurrentBuffer() { - lyxerr.debug("resizeCurrentBuffer"); + lyxerr.debug() << "resizeCurrentBuffer" << endl; LyXParagraph *par = 0; LyXParagraph *selstartpar = 0; @@ -367,6 +364,29 @@ void BufferView::gotoError() _buffer->text->cursor; } +// Just a bunch of C wrappers around static members of BufferView +extern "C" void C_BufferView_UpCB(FL_OBJECT *ob, long buf) { + BufferView::UpCB(ob,buf); +} + +extern "C" void C_BufferView_DownCB(FL_OBJECT *ob, long buf) { + BufferView::DownCB(ob,buf); +} + +extern "C" void C_BufferView_ScrollCB(FL_OBJECT *ob, long buf) { + BufferView::ScrollCB(ob,buf); +} + +extern "C" void C_BufferView_CursorToggleCB(FL_OBJECT *ob, long buf) { + BufferView::CursorToggleCB(ob,buf); +} + +extern "C" int C_BufferView_work_area_handler(FL_OBJECT *ob, int event, + FL_Coord, FL_Coord, + int key, void *xev) { + return BufferView::work_area_handler(ob, event, 0, 0, key, xev); +} + void BufferView::create_view(int xpos, int ypos, int width, int height) { @@ -395,9 +415,9 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) xpos +bw, ypos+bw, width-15-2*bw /* scrollbarwidth */, height-2*bw,"", - work_area_handler); + C_BufferView_work_area_handler); obj->wantkey = FL_KEY_TAB; - obj->u_vdata = (void*) this; /* This is how we pass the BufferView + obj->u_vdata = this; /* This is how we pass the BufferView to the work_area_handler. */ fl_set_object_boxtype(obj,FL_DOWN_BOX); fl_set_object_resize(obj, FL_RESIZE_ALL); @@ -421,7 +441,7 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) fl_set_object_color(obj,FL_MCOL,FL_BLUE); fl_set_object_resize(obj, FL_RESIZE_ALL); fl_set_object_gravity(obj,NorthEastGravity, NorthEastGravity); - fl_set_object_callback(obj,UpCB,(long)this); + fl_set_object_callback(obj,C_BufferView_UpCB,(long)this); fl_set_pixmapbutton_data(obj, up_xpm); #if FL_REVISION >85 @@ -439,7 +459,7 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) fl_set_object_boxtype(obj, FL_UP_BOX); fl_set_object_resize(obj, FL_RESIZE_ALL); fl_set_object_gravity(obj, NorthEastGravity, SouthEastGravity); - fl_set_object_callback(obj,ScrollCB,(long)this); + fl_set_object_callback(obj,C_BufferView_ScrollCB,(long)this); // down - scrollbar button #if FL_REVISION > 85 @@ -455,7 +475,7 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) fl_set_object_color(obj,FL_MCOL,FL_BLUE); fl_set_object_resize(obj, FL_RESIZE_ALL); fl_set_object_gravity(obj, SouthEastGravity, SouthEastGravity); - fl_set_object_callback(obj,DownCB,(long)this); + fl_set_object_callback(obj,C_BufferView_DownCB,(long)this); fl_set_pixmapbutton_data(obj, down_xpm); fl_set_border_width(-bw); @@ -471,8 +491,8 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) // timer_cursor timer_cursor = obj = fl_add_timer(FL_HIDDEN_TIMER, 0,0,0,0,"Timer"); - fl_set_object_callback(obj,CursorToggleCB,0); - obj->u_vdata = (void*) this; + fl_set_object_callback(obj,C_BufferView_CursorToggleCB,0); + obj->u_vdata = this; } @@ -896,16 +916,6 @@ int BufferView::WorkAreaButtonPress(FL_OBJECT *ob, Window, // Hit above or below the table? if (doit) { - long y_tmp = y + screen->first; - Row* row = _buffer->text->GetRowNearY(y_tmp); -#if 0 - // Isn't this empty code anyway? (Lgb) - if (row->par != _buffer->text->cursor.par) - doit = true; - } - - if (doit) { -#endif if (!_buffer->text->selection) { screen->ToggleSelection(); _buffer->text->ClearSelection(); @@ -955,18 +965,6 @@ int BufferView::WorkAreaButtonPress(FL_OBJECT *ob, Window, // Right click on a footnote flag opens float menu if (button == 3) { -#if 0 - // Isn't this empty code anyway? (Lgb) - if (_buffer->text->cursor.par->footnoteflag == - LyXParagraph::OPEN_FOOTNOTE) { - selection_possible = false; - lyxerr.debug("LyX: Sorry not implemented yet."); - return 0; - } - } - - if (button == 3) { -#endif selection_possible = false; return 0; } @@ -1006,10 +1004,10 @@ int BufferView::WorkAreaButtonPress(FL_OBJECT *ob, Window, int diff = ev->xbutton.time - lastTime; int scroll = int(1.0 + (4.0/(abs(diff)+1.0))*200.0); switch (button) { - case 5: + case 4: ScrollUp(scroll); break; - case 4: + case 5: ScrollDown(scroll); break; } @@ -1353,13 +1351,13 @@ void BufferView::CursorToggleCB(FL_OBJECT *ob, long) Window tmpwin; int tmp; XGetInputFocus(fl_display, &tmpwin, &tmp); - lyxerr.debug(LString("tmpwin: ") + int(tmpwin)); - lyxerr.debug(LString("window: ") - + int(view->_owner->getForm()->window)); - lyxerr.debug(LString("work_area_focus: ") - + int(view->work_area_focus)); - lyxerr.debug(LString("lyx_focus : ") - + int(view->lyx_focus)); + if (lyxerr.debugging()) { + lyxerr << "tmpwin: " << tmpwin + << "\nwindow: " << view->_owner->getForm()->window + << "\nwork_area_focus: " << view->work_area_focus + << "\nlyx_focus : " << view->lyx_focus + << endl; + } if (tmpwin != view->_owner->getForm()->window) { view->lyx_focus = false; goto skip_timer; @@ -1516,8 +1514,10 @@ void BufferView::savePosition() void BufferView::restorePosition() { + if (backstack->empty()) return; + int x, y; - LString fname = backstack->pop(&x, &y); + string fname = backstack->pop(&x, &y); BeforeChange(); Buffer *b = (bufferlist.exists(fname)) ? bufferlist.getBuffer(fname): @@ -1526,4 +1526,3 @@ void BufferView::restorePosition() currentBuffer()->text->SetCursorFromCoordinates(x, y); currentBuffer()->update(0); } -