a couple of name changes and new functionality in lyxvc and vc-backend

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@302 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 1999-11-09 23:52:04 +00:00
parent a94cb21697
commit 3660343dc7
36 changed files with 1581 additions and 1294 deletions

File diff suppressed because it is too large Load Diff

View File

@ -30,11 +30,11 @@ public:
///
BufferView(LyXView *owner, int ,int ,int, int);
///
Buffer *currentBuffer() { return _buffer; }
Buffer * buffer() const { return buffer_; }
///
FL_OBJECT *getWorkArea() { return work_area; }
FL_OBJECT * getWorkArea() { return work_area; }
///
void setBuffer(Buffer *b);
void buffer(Buffer * b);
///
void resize();
///
@ -58,9 +58,9 @@ public:
///
bool available() const;
///
LyXView *getOwner() { return _owner; }
LyXView * owner() const { return owner_; }
///
LyXScreen *getScreen()
LyXScreen * getScreen()
{
fl_set_timer(timer_cursor, 0.4);
return screen;
@ -77,7 +77,7 @@ private:
///
void create_view(int, int, int, int);
///
Inset * checkInsetHit(int &x, int &y);
Inset * checkInsetHit(int & x, int & y);
///
int ScrollUp(long time);
///
@ -89,46 +89,46 @@ private:
public:
/// A callback for the up arrow in the scrollbar.
static void UpCB(FL_OBJECT *ob, long);
static void UpCB(FL_OBJECT * ob, long);
/// A callback for the slider in the scrollbar.
static void ScrollCB(FL_OBJECT *ob, long);
static void ScrollCB(FL_OBJECT * ob, long);
/// A callback for the down arrow in the scrollbar.
static void DownCB(FL_OBJECT *ob, long);
static void DownCB(FL_OBJECT * ob, long);
///
static void CursorToggleCB(FL_OBJECT *ob, long);
static void CursorToggleCB(FL_OBJECT * ob, long);
/** Work area free object handler
*/
static int work_area_handler(FL_OBJECT *, int event,
FL_Coord, FL_Coord, int key, void *xev);
private:
///
int WorkAreaMotionNotify(FL_OBJECT *ob,
int WorkAreaMotionNotify(FL_OBJECT * ob,
Window win,
int w, int h,
XEvent *ev, void *d);
XEvent * ev, void * d);
///
int WorkAreaSelectionNotify(FL_OBJECT *, Window win,
int /*w*/, int /*h*/,
XEvent *event, void */*d*/);
XEvent * event, void * /*d*/);
///
int WorkAreaButtonPress(FL_OBJECT *ob,
int WorkAreaButtonPress(FL_OBJECT * ob,
Window win,
int w, int h,
XEvent *ev, void *d);
XEvent * ev, void * d);
///
int WorkAreaButtonRelease(FL_OBJECT *ob,
int WorkAreaButtonRelease(FL_OBJECT * ob,
Window win,
int w, int h,
XEvent *ev, void *d);
XEvent * ev, void * d);
///
LyXView *_owner;
LyXView * owner_;
///
Buffer *_buffer;
Buffer * buffer_;
///
LyXScreen *screen;
LyXScreen * screen;
///
long current_scrollbar_value;
///
@ -138,17 +138,17 @@ private:
///
bool work_area_focus;
///
FL_OBJECT *work_area;
FL_OBJECT * work_area;
///
FL_OBJECT *figinset_canvas;
FL_OBJECT * figinset_canvas;
///
FL_OBJECT *scrollbar;
FL_OBJECT * scrollbar;
///
FL_OBJECT *button_down;
FL_OBJECT * button_down;
///
FL_OBJECT *button_up;
FL_OBJECT * button_up;
///
FL_OBJECT *timer_cursor;
FL_OBJECT * timer_cursor;
///
BackStack backstack;
///

View File

@ -196,14 +196,14 @@ void FontLoader::getFontinfo(LyXFont::FONT_FAMILY family,
}
/// Do load font
XFontStruct* FontLoader::doLoad(LyXFont::FONT_FAMILY family,
XFontStruct * FontLoader::doLoad(LyXFont::FONT_FAMILY family,
LyXFont::FONT_SERIES series,
LyXFont::FONT_SHAPE shape,
LyXFont::FONT_SIZE size)
{
getFontinfo(family,series,shape);
int fsize = (int) ( (lyxrc->font_sizes[size] * lyxrc->dpi *
(lyxrc->zoom/100.0) ) / 72.27 + 0.5 );
int fsize = int( (lyxrc->font_sizes[size] * lyxrc->dpi *
(lyxrc->zoom/100.0) ) / 72.27 + 0.5 );
string font = fontinfo[family][series][shape]->getFontname(fsize);
@ -216,10 +216,10 @@ XFontStruct* FontLoader::doLoad(LyXFont::FONT_FAMILY family,
minibuffer->Store();
minibuffer->Set(_("Loading font into X-Server..."));
XFontStruct* fs = XLoadQueryFont(fl_display, font.c_str());
XFontStruct * fs = XLoadQueryFont(fl_display, font.c_str());
if (fs == 0) {
if (font=="fixed") {
if (font == "fixed") {
lyxerr << "We're doomed. Can't get 'fixed' font." << endl;
} else {
lyxerr << "Could not get font. Using 'fixed'." << endl;

View File

@ -7,7 +7,7 @@
* Copyright 1995 Matthias Ettrich
* Copyright 1995-1999 the LyX Team.
*
* ======================================================*/
* ====================================================== */
#include <config.h>
@ -25,7 +25,8 @@
extern LyXRC * lyxrc;
LaTeXFeatures::LaTeXFeatures(int n)
LaTeXFeatures::LaTeXFeatures(int n)
: layout(n, false)
{
// packages
color = false;
@ -66,15 +67,10 @@ LaTeXFeatures::LaTeXFeatures(int n)
LyXParagraphIndent = false;
NeedLyXFootnoteCode = false;
NeedLyXMinipageIndent = false;
// layouts
layout = new bool[n];
for (int i = n; i--;)
layout[i] = false;
}
string LaTeXFeatures::getPackages(BufferParams const &params)
string LaTeXFeatures::getPackages(BufferParams const & params)
{
string packages;
LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
@ -232,9 +228,10 @@ string LaTeXFeatures::getTClassPreamble(BufferParams const & params)
LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
string tcpreamble = tclass.preamble();
for (LyXTextClass::LayoutList::const_iterator cit = tclass.begin();
cit != tclass.end(); ++cit) {
tcpreamble += (*cit).preamble();
for (unsigned int i = 0; i < tclass.numLayouts(); ++i) {
if (layout[i]) {
tcpreamble += tclass[i].preamble();
}
}
return tcpreamble;

View File

@ -17,6 +17,8 @@
#pragma interface
#endif
#include <vector>
#include "LString.h"
class BufferParams;
@ -31,10 +33,6 @@ class LyXTextClass;
struct LaTeXFeatures {
///
LaTeXFeatures(int n) ;
///
~LaTeXFeatures() {
delete[] layout;
}
/// The packaes needed by the document
string getPackages(BufferParams const &params);
/// The macros definitions needed by the document
@ -118,7 +116,7 @@ struct LaTeXFeatures {
//@Man: Layouts
//@{
bool *layout;
vector<bool> layout;
//@}
//@Man: Special features

View File

@ -22,14 +22,14 @@ void ShowLatexLog()
bool use_build = false;
static int ow = -1, oh;
filename = current_view->currentBuffer()->getFileName();
filename = current_view->buffer()->getFileName();
if (!filename.empty()) {
fname = SpaceLess(ChangeExtension(filename, ".log", true));
bname = SpaceLess(ChangeExtension(filename,
lyxrc->literate_extension + ".out", true));
path = OnlyPath(filename);
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = current_view->currentBuffer()->tmppath;
path = current_view->buffer()->tmppath;
}
FileInfo f_fi(path + fname), b_fi(path + bname);
if (b_fi.exist())

View File

@ -52,7 +52,7 @@ void SendtoApplyCB(FL_OBJECT *, long)
string command = fl_get_input(fd_form_sendto->input_cmd);
if (command.empty())
return;
Buffer *buffer = current_view->currentBuffer();
Buffer * buffer = current_view->buffer();
if (fl_get_button(fd_form_sendto->radio_ftype_dvi) ||
fl_get_button(fd_form_sendto->radio_ftype_ps)) {
ProhibitInput();

View File

@ -31,11 +31,11 @@
#include "layout.h"
#include "lyxtext.h"
extern FD_form_document *fd_form_document;
FD_form_main *fd_form_main; /* a pointer to the one in LyXView
extern FD_form_document * fd_form_document;
FD_form_main * fd_form_main; /* a pointer to the one in LyXView
should be removed as soon as possible */
MiniBuffer *minibuffer;/* a pointer to the one in LyXView
MiniBuffer * minibuffer;/* a pointer to the one in LyXView
should be removed as soon as possible */
extern void AutoSave();
@ -44,7 +44,7 @@ extern void QuitLyX();
int current_layout = 0;
// This is very temporary
BufferView *current_view;
BufferView * current_view;
extern "C" int C_LyXView_atCloseMainFormCB(FL_FORM *, void *);
@ -52,7 +52,7 @@ LyXView::LyXView(int width, int height)
{
fd_form_main = create_form_form_main(width,height);
fl_set_form_atclose(_form, C_LyXView_atCloseMainFormCB, 0);
lyxerr.debug() << "Initializing LyXFunc" << endl;
lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
lyxfunc = new LyXFunc(this);
intl = new Intl;
}
@ -70,31 +70,31 @@ LyXView::~LyXView()
/// Redraw the main form.
void LyXView::redraw() {
lyxerr.debug() << "LyXView::redraw()" << endl;
lyxerr[Debug::INFO] << "LyXView::redraw()" << endl;
fl_redraw_form(_form);
minibuffer->Activate();
}
// Callback for update timer
void LyXView::UpdateTimerCB(FL_OBJECT *ob, long)
void LyXView::UpdateTimerCB(FL_OBJECT * ob, long)
{
LyXView *view = (LyXView*) ob->u_vdata;
LyXView * view = static_cast<LyXView*>(ob->u_vdata);
if (!view->currentView()->available())
return;
if (!view->currentView()->getScreen() || !updatetimer)
return;
view->currentView()->getScreen()->HideCursor();
view->currentBuffer()->update(-2);
view->buffer()->update(-2);
/* This update can happen, even when the work area has lost
* the focus. So suppress the cursor in that case */
updatetimer = 0;
}
// Wrapper for the above
extern "C" void C_LyXView_UpdateTimerCB(FL_OBJECT *ob, long data) {
LyXView::UpdateTimerCB(ob,data);
extern "C" void C_LyXView_UpdateTimerCB(FL_OBJECT * ob, long data) {
LyXView::UpdateTimerCB(ob, data);
}
@ -102,12 +102,12 @@ extern "C" void C_LyXView_UpdateTimerCB(FL_OBJECT *ob, long data) {
// Callback for autosave timer
void LyXView::AutosaveTimerCB(FL_OBJECT *, long)
{
lyxerr.debug() << "Running AutoSave()" << endl;
lyxerr[Debug::INFO] << "Running AutoSave()" << endl;
AutoSave();
}
// Wrapper for the above
extern "C" void C_LyXView_AutosaveTimerCB(FL_OBJECT *ob, long data) {
extern "C" void C_LyXView_AutosaveTimerCB(FL_OBJECT * ob, long data) {
LyXView::AutosaveTimerCB(ob, data);
}
@ -127,9 +127,10 @@ int LyXView::atCloseMainFormCB(FL_FORM *, void *)
return FL_IGNORE;
}
// Wrapper for the above
extern "C" int C_LyXView_atCloseMainFormCB(FL_FORM *form, void *p) {
return LyXView::atCloseMainFormCB(form,p);
extern "C" int C_LyXView_atCloseMainFormCB(FL_FORM * form, void * p) {
return LyXView::atCloseMainFormCB(form, p);
}
@ -139,7 +140,7 @@ void LyXView::setPosition(int x, int y)
}
void LyXView::show(int place, int border, char const* title)
void LyXView::show(int place, int border, char const * title)
{
fl_show_form(_form, place, border, title);
minibuffer->Init();
@ -147,7 +148,7 @@ void LyXView::show(int place, int border, char const* title)
}
FD_form_main *LyXView::create_form_form_main(int width, int height)
FD_form_main * LyXView::create_form_form_main(int width, int height)
/* to make this work as it should, .lyxrc should have been
* read first; OR maybe this one should be made dynamic.
* Hmmmm. Lgb.
@ -156,7 +157,7 @@ FD_form_main *LyXView::create_form_form_main(int width, int height)
* are presented (and rightly so) in GUI popups. Asger.
*/
{
FL_OBJECT *obj;
FL_OBJECT * obj;
FD_form_main *fdui = (FD_form_main *)
fl_calloc(1, sizeof(FD_form_main));
@ -165,9 +166,9 @@ FD_form_main *LyXView::create_form_form_main(int width, int height)
// the main form
_form = fdui->form_main = fl_bgn_form(FL_NO_BOX, width, height);
fdui->form_main->u_vdata = (void*) this;
obj = fl_add_box(FL_FLAT_BOX,0,0,width,height,"");
fl_set_object_color(obj,FL_MCOL,FL_MCOL);
fdui->form_main->u_vdata = this;
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;
@ -221,7 +222,7 @@ FD_form_main *LyXView::create_form_form_main(int width, int height)
fdui->timer_update = obj = fl_add_timer(FL_HIDDEN_TIMER,
0,0,0,0,"Timer");
fl_set_object_callback(obj,C_LyXView_UpdateTimerCB,0);
obj->u_vdata = (void*) this;
obj->u_vdata = this;
//
// Misc
@ -248,7 +249,7 @@ FD_form_main *LyXView::create_form_form_main(int width, int height)
return fdui;
}
extern "C" int C_LyXView_KeyPressMask_raw_callback(FL_FORM *fl, void *xev);
extern "C" int C_LyXView_KeyPressMask_raw_callback(FL_FORM * fl, void * xev);
void LyXView::init()
{
@ -283,7 +284,7 @@ void LyXView::updateLayoutChoice()
// this has a bi-effect that the layouts are not showed when no
// document is loaded.
if (bufferview==0 || bufferview->currentBuffer()==0) {
if (bufferview == 0 || bufferview->buffer()==0) {
toolbar->combox->clear();
toolbar->combox->Redraw();
return;
@ -291,26 +292,26 @@ void LyXView::updateLayoutChoice()
// If textclass is different, we need to update the list
if (toolbar->combox->empty() ||
(last_textclass != int(currentBuffer()->params.textclass))) {
(last_textclass != int(buffer()->params.textclass))) {
toolbar->combox->clear();
for (int i = 0;
textclasslist.NameOfLayout(currentBuffer()->
textclasslist.NameOfLayout(buffer()->
params.textclass, i) !="@@end@@";
i++) {
LyXLayout const & layout = textclasslist.
Style(currentBuffer()->params.textclass, i);
Style(buffer()->params.textclass, i);
if (layout.obsoleted_by().empty())
toolbar->combox->addline(layout.name().c_str());
else
toolbar->combox->addline(("@N"+layout.name()).c_str());
}
last_textclass = int(currentBuffer()->params.textclass);
last_textclass = int(buffer()->params.textclass);
current_layout = 0;
}
// we need to do this.
toolbar->combox->Redraw();
char layout = currentBuffer()->text->cursor.par->GetLayout();
char layout = buffer()->text->cursor.par->GetLayout();
if (layout != current_layout){
toolbar->combox->select(layout + 1);
@ -321,7 +322,7 @@ void LyXView::updateLayoutChoice()
void LyXView::UpdateDocumentClassChoice()
{
/* update the document class display in the document form */
// update the document class display in the document form
int i;
if (fd_form_document) {
fl_clear_choice(fd_form_document->choice_class);
@ -337,38 +338,38 @@ void LyXView::UpdateDocumentClassChoice()
// as FL_KEYBOARD events :-( Matthias 280596
int LyXView::KeyPressMask_raw_callback(FL_FORM *fl, void *xev)
{
LyXView *view = (LyXView*) fl->u_vdata;
LyXView * view = static_cast<LyXView*>(fl->u_vdata);
int retval = 0; // 0 means XForms should have a look at this event
// funny. Even though the raw_callback is registered with KeyPressMask,
// also KeyRelease-events are passed through:-(
// [It seems that xforms puts them in pairs... (JMarc)]
if (((XEvent*)xev)->type == KeyPress
if (static_cast<XEvent*>(xev)->type == KeyPress
&& view->bufferview->getWorkArea()->focus
&& view->bufferview->getWorkArea()->active)
retval = view->getLyXFunc()->processKeyEvent((XEvent*)xev);
retval = view->getLyXFunc()
->processKeyEvent(static_cast<XEvent*>(xev));
return retval;
}
// wrapper for the above
extern "C" int C_LyXView_KeyPressMask_raw_callback(FL_FORM *fl, void *xev)
extern "C" int C_LyXView_KeyPressMask_raw_callback(FL_FORM * fl, void * xev)
{
return LyXView::KeyPressMask_raw_callback(fl, xev);
}
// Updates the title of the window with the filename of the current document
void LyXView::updateWindowTitle() {
static string last_title="LyX";
static string last_title = "LyX";
string title = "LyX";
if (currentView()->available()) {
string cur_title = currentBuffer()->getFileName();
string cur_title = buffer()->getFileName();
if (!cur_title.empty()){
title += ": " + OnlyFilename(cur_title);
if (!currentBuffer()->isLyxClean())
if (!buffer()->isLyxClean())
title += _(" (Changed)");
if (currentBuffer()->isReadonly())
if (buffer()->isReadonly())
title += _(" (read only)");
}
}

View File

@ -31,13 +31,13 @@ class Intl;
///
struct FD_form_main {
///
FL_FORM *form_main;
FL_FORM * form_main;
///
FL_OBJECT *timer_autosave;
FL_OBJECT * timer_autosave;
///
FL_OBJECT *timer_update;
FL_OBJECT * timer_update;
///
void *vdata;
void * vdata;
///
long ldata;
};
@ -70,7 +70,7 @@ public:
void redraw();
/// returns the buffer currently shown in the main form.
Buffer * currentBuffer(){ return bufferview->currentBuffer();}
Buffer * buffer() const { return bufferview->buffer(); }
///
BufferView * currentView() { return bufferview; }

View File

@ -168,6 +168,8 @@ lyx_SOURCES = \
trans_mgr.C \
trans_mgr.h \
undo.h \
vc-backend.C \
vc-backend.h \
version.h \
vms_defines.h \
vspace.C \

View File

@ -112,7 +112,7 @@ bool UpdateLayoutPaper()
update = false;
if (update) {
BufferParams * params = &current_view->currentBuffer()->params;
BufferParams * params = &current_view->buffer()->params;
fl_set_choice(fd_form_paper->choice_papersize2,
params->papersize2 + 1);
@ -148,7 +148,7 @@ bool UpdateLayoutPaper()
fl_set_focus_object(fd_form_paper->form_paper,
fd_form_paper->choice_papersize2);
fl_hide_object(fd_form_paper->text_warning);
if (current_view->currentBuffer()->isReadonly()) {
if (current_view->buffer()->isReadonly()) {
DisablePaperLayout();
fl_set_object_label(fd_form_paper->text_warning,
_("Document is read-only."
@ -184,7 +184,7 @@ void PaperApplyCB(FL_OBJECT *, long)
if (! current_view->available())
return;
BufferParams * params = &current_view->currentBuffer()->params;
BufferParams * params = &current_view->buffer()->params;
FD_form_paper const * fd = fd_form_paper;
@ -204,9 +204,9 @@ void PaperApplyCB(FL_OBJECT *, long)
params->headheight = fl_get_input(fd->input_head_height);
params->headsep = fl_get_input(fd->input_head_sep);
params->footskip = fl_get_input(fd->input_foot_skip);
current_view->currentBuffer()->setPaperStuff();
current_view->buffer()->setPaperStuff();
minibuffer->Set(_("Paper layout set"));
current_view->currentBuffer()->markDirty();
current_view->buffer()->markDirty();
return;
}

View File

@ -76,7 +76,7 @@ bool UpdateParagraphExtra()
bool update = false;
if (current_view->getScreen() && current_view->available()) {
update = true;
LyXParagraph* par = current_view->currentBuffer()->text->cursor.par;
LyXParagraph * par = current_view->buffer()->text->cursor.par;
EnableParagraphExtra();
@ -137,7 +137,7 @@ bool UpdateParagraphExtra()
}
fl_hide_object(fd_form_paragraph_extra->text_warning);
if (current_view->currentBuffer()->isReadonly()) {
if (current_view->buffer()->isReadonly()) {
DisableParagraphExtra();
fl_set_object_label(fd_form_paragraph_extra->text_warning,
_("Document is read-only. No changes to layout permitted."));
@ -165,12 +165,10 @@ void ParagraphExtraOpen(FL_OBJECT *, long)
void ParagraphExtraApplyCB(FL_OBJECT *, long)
{
if (current_view->getScreen() && current_view->available()) {
const FD_form_paragraph_extra* fd = fd_form_paragraph_extra;
const char
*width = fl_get_input(fd->input_pextra_width),
*widthp = fl_get_input(fd->input_pextra_widthp);
LyXText
*text = current_view->currentBuffer()->text;
FD_form_paragraph_extra const * fd = fd_form_paragraph_extra;
const char * width = fl_get_input(fd->input_pextra_width);
const char * widthp = fl_get_input(fd->input_pextra_widthp);
LyXText * text = current_view->buffer()->text;
int type = PEXTRA_NONE;
int alignment = 0;
bool
@ -195,7 +193,7 @@ void ParagraphExtraApplyCB(FL_OBJECT *, long)
}
text->SetParagraphExtraOpt(type,width,widthp,alignment,hfill,
start_minipage);
current_view->currentBuffer()->update(1);
current_view->buffer()->update(1);
minibuffer->Set(_("ParagraphExtra layout set"));
}
return;

View File

@ -43,21 +43,20 @@ bool UpdateLayoutTable(int flag)
if (!current_view->getScreen() || !current_view->available())
update = false;
if (update && current_view->currentBuffer()->text->cursor.par->table) {
if (update && current_view->buffer()->text->cursor.par->table) {
int
align,
cell,
column,row;
char
buf[12];
string
pwidth, special;
LyXTable *table = current_view->currentBuffer()->text->cursor.par->table;
LyXTable * table = current_view->buffer()->text->cursor.par->table;
cell = current_view->currentBuffer()->text->
NumberOfCell(current_view->currentBuffer()->text->cursor.par,
current_view->currentBuffer()->text->cursor.pos);
int cell = current_view->buffer()->text->
NumberOfCell(current_view->buffer()->text->cursor.par,
current_view->buffer()->text->cursor.pos);
ActCell = cell;
column = table->column_of_cell(cell)+1;
fl_set_object_label(fd_form_table_options->text_warning,"");
@ -108,7 +107,7 @@ bool UpdateLayoutTable(int flag)
fl_set_input_cursorpos(fd_form_table_extra->input_special_alignment,
extra_col_cursor_x, 0); // restore the cursor
}
if (current_view->currentBuffer()->isReadonly())
if (current_view->buffer()->isReadonly())
fl_deactivate_object(fd_form_table_extra->input_special_alignment);
special = table->GetAlignSpecial(cell,LyXTable::SET_SPECIAL_MULTI);
if (flag)
@ -118,12 +117,12 @@ bool UpdateLayoutTable(int flag)
fl_set_input_cursorpos(fd_form_table_extra->input_special_multialign,
extra_multicol_cursor_x, 0); // restore the cursor
}
if (current_view->currentBuffer()->isReadonly())
if (current_view->buffer()->isReadonly())
fl_deactivate_object(fd_form_table_extra->input_special_multialign);
pwidth = table->GetPWidth(cell);
if (flag)
fl_set_input(fd_form_table_options->input_column_width,pwidth.c_str());
if (current_view->currentBuffer()->isReadonly())
if (current_view->buffer()->isReadonly())
fl_deactivate_object(fd_form_table_options->input_column_width);
if (!pwidth.empty()) {
fl_activate_object(fd_form_table_options->radio_linebreak_cell);
@ -264,7 +263,6 @@ void TableOptionsCB(FL_OBJECT *ob, long)
LyXTable
*table = 0;
int
cell,
s,
num = 0;
string
@ -273,14 +271,14 @@ void TableOptionsCB(FL_OBJECT *ob, long)
if (!current_view->available()
||
!(table = current_view->currentBuffer()->text->cursor.par->table))
!(table = current_view->buffer()->text->cursor.par->table))
{
MenuLayoutTable(0);
return;
}
cell = current_view->currentBuffer()->text->
NumberOfCell(current_view->currentBuffer()->text->cursor.par,
current_view->currentBuffer()->text->cursor.pos);
int cell = current_view->buffer()->text->
NumberOfCell(current_view->buffer()->text->cursor.par,
current_view->buffer()->text->cursor.pos);
if (ActCell != cell) {
MenuLayoutTable(0);
fl_set_object_label(fd_form_table_options->text_warning,
@ -292,7 +290,7 @@ void TableOptionsCB(FL_OBJECT *ob, long)
}
// No point in processing directives that you can't do anything with
// anyhow, so exit now if the buffer is read-only.
if (current_view->currentBuffer()->isReadonly()) {
if (current_view->buffer()->isReadonly()) {
MenuLayoutTable(0);
return;
}
@ -431,16 +429,16 @@ void TableOptionsCB(FL_OBJECT *ob, long)
return;
if (current_view->available()){
current_view->getScreen()->HideCursor();
if (!current_view->currentBuffer()->text->selection){
if (!current_view->buffer()->text->selection){
BeforeChange();
current_view->currentBuffer()->update(-2);
current_view->buffer()->update(-2);
}
if ((num == LyXTable::SET_SPECIAL_COLUMN) ||
(num == LyXTable::SET_SPECIAL_MULTI))
current_view->currentBuffer()->text->TableFeatures(num,special);
current_view->buffer()->text->TableFeatures(num,special);
else
current_view->currentBuffer()->text->TableFeatures(num);
current_view->currentBuffer()->update(1);
current_view->buffer()->text->TableFeatures(num);
current_view->buffer()->update(1);
}
if (num == LyXTable::DELETE_TABLE) {
fl_set_focus_object(fd_form_table_options->form_table_options,
@ -483,12 +481,12 @@ void SetPWidthCB(FL_OBJECT *ob, long)
}
if (current_view->available()){
current_view->getScreen()->HideCursor();
if (!current_view->currentBuffer()->text->selection){
if (!current_view->buffer()->text->selection){
BeforeChange();
current_view->currentBuffer()->update(-2);
current_view->buffer()->update(-2);
}
current_view->currentBuffer()->text->TableFeatures(LyXTable::SET_PWIDTH,str);
current_view->currentBuffer()->update(1);
current_view->buffer()->text->TableFeatures(LyXTable::SET_PWIDTH,str);
current_view->buffer()->update(1);
}
MenuLayoutTable(0); // update for alignment
}

View File

@ -102,6 +102,7 @@ extern void FreeUpdateTimer();
Buffer::Buffer(string const & file, LyXRC *lyxrc, bool ronly)
{
lyxerr[Debug::INFO] << "Buffer::Buffer()" << endl;
filename = file;
filepath = OnlyPath(file);
paragraph = 0;
@ -115,8 +116,7 @@ Buffer::Buffer(string const & file, LyXRC *lyxrc, bool ronly)
read_only = ronly;
inset_slept = false;
users = 0;
lyxvc.setBuffer(this);
lyxerr.debug() << "Buffer::Buffer()" << endl;
lyxvc.buffer(this);
if (read_only || (lyxrc && lyxrc->use_tempdir)) {
tmppath = CreateBufferTmpDir();
} else tmppath.clear();
@ -125,14 +125,14 @@ Buffer::Buffer(string const & file, LyXRC *lyxrc, bool ronly)
Buffer::~Buffer()
{
lyxerr.debug() << "Buffer::~Buffer()" << endl;
lyxerr[Debug::INFO] << "Buffer::~Buffer()" << endl;
// here the buffer should take care that it is
// saved properly, before it goes into the void.
// make sure that views using this buffer
// forgets it.
if (users)
users->setBuffer(0);
users->buffer(0);
if (!tmppath.empty()) {
DestroyBufferTmpDir(tmppath);
@ -169,7 +169,7 @@ bool Buffer::saveParamsAsDefaults()
// Should work on a list
void Buffer::updateTitles()
{
if (users) users->getOwner()->updateWindowTitle();
if (users) users->owner()->updateWindowTitle();
}
@ -177,7 +177,7 @@ void Buffer::updateTitles()
// Should work on a list
void Buffer::resetAutosaveTimers()
{
if (users) users->getOwner()->resetAutosaveTimer();
if (users) users->owner()->resetAutosaveTimer();
}
@ -3209,7 +3209,7 @@ int Buffer::runLaTeX()
}
Path p(path); // path to LaTeX file
users->getOwner()->getMiniBuffer()->Set(_("Running LaTeX..."));
users->owner()->getMiniBuffer()->Set(_("Running LaTeX..."));
// Remove all error insets
bool a = removeAutoInsets();
@ -3221,14 +3221,15 @@ int Buffer::runLaTeX()
// do the LaTex run(s)
TeXErrors terr;
LaTeX latex(lyxrc->latex_command, name, filepath);
int res = latex.run(terr,users->getOwner()->getMiniBuffer()); // running latex
int res = latex.run(terr,
users->owner()->getMiniBuffer()); // running latex
// check return value from latex.run().
if ((res & LaTeX::NO_LOGFILE)) {
WriteAlert(_("LaTeX did not work!"),
_("Missing log file:"), name);
} else if ((res & LaTeX::ERRORS)) {
users->getOwner()->getMiniBuffer()->Set(_("Done"));
users->owner()->getMiniBuffer()->Set(_("Done"));
// Insert all errors as errors boxes
insertErrors(terr);
@ -3237,7 +3238,7 @@ int Buffer::runLaTeX()
// to view a dirty dvi too.
} else {
//no errors or any other things to think about so:
users->getOwner()->getMiniBuffer()->Set(_("Done"));
users->owner()->getMiniBuffer()->Set(_("Done"));
markDviClean();
}
@ -3273,7 +3274,7 @@ int Buffer::runLiterate()
}
Path p(path); // path to Literate file
users->getOwner()->getMiniBuffer()->Set(_("Running Literate..."));
users->owner()->getMiniBuffer()->Set(_("Running Literate..."));
// Remove all error insets
bool a = removeAutoInsets();
@ -3289,14 +3290,14 @@ int Buffer::runLiterate()
lyxrc->literate_command, lyxrc->literate_error_filter,
lyxrc->build_command, lyxrc->build_error_filter);
TeXErrors terr;
int res = literate.weave(terr, users->getOwner()->getMiniBuffer());
int res = literate.weave(terr, users->owner()->getMiniBuffer());
// check return value from literate.weave().
if ((res & Literate::NO_LOGFILE)) {
WriteAlert(_("Literate command did not work!"),
_("Missing log file:"), name);
} else if ((res & Literate::ERRORS)) {
users->getOwner()->getMiniBuffer()->Set(_("Done"));
users->owner()->getMiniBuffer()->Set(_("Done"));
// Insert all errors as errors boxes
insertErrors(terr);
@ -3305,7 +3306,7 @@ int Buffer::runLiterate()
// to view a dirty dvi too.
} else {
//no errors or any other things to think about so:
users->getOwner()->getMiniBuffer()->Set(_("Done"));
users->owner()->getMiniBuffer()->Set(_("Done"));
markDviClean();
}
@ -3341,7 +3342,7 @@ int Buffer::buildProgram()
}
Path p(path); // path to Literate file
users->getOwner()->getMiniBuffer()->Set(_("Building Program..."));
users->owner()->getMiniBuffer()->Set(_("Building Program..."));
// Remove all error insets
bool a = removeAutoInsets();
@ -3357,14 +3358,14 @@ int Buffer::buildProgram()
lyxrc->literate_command, lyxrc->literate_error_filter,
lyxrc->build_command, lyxrc->build_error_filter);
TeXErrors terr;
int res = literate.build(terr, users->getOwner()->getMiniBuffer());
int res = literate.build(terr, users->owner()->getMiniBuffer());
// check return value from literate.build().
if ((res & Literate::NO_LOGFILE)) {
WriteAlert(_("Build did not work!"),
_("Missing log file:"), name);
} else if ((res & Literate::ERRORS)) {
users->getOwner()->getMiniBuffer()->Set(_("Done"));
users->owner()->getMiniBuffer()->Set(_("Done"));
// Insert all errors as errors boxes
insertErrors(terr);
@ -3372,7 +3373,7 @@ int Buffer::buildProgram()
// command run ends up with errors.
} else {
//no errors or any other things to think about so:
users->getOwner()->getMiniBuffer()->Set(_("Done"));
users->owner()->getMiniBuffer()->Set(_("Done"));
markNwClean();
}
@ -3408,7 +3409,7 @@ int Buffer::runChktex()
}
Path p(path); // path to LaTeX file
users->getOwner()->getMiniBuffer()->Set(_("Running chktex..."));
users->owner()->getMiniBuffer()->Set(_("Running chktex..."));
// Remove all error insets
bool a = removeAutoInsets();
@ -3673,7 +3674,7 @@ void Buffer::update(signed char f)
{
if (!users) return;
users->getOwner()->updateLayoutChoice();
users->owner()->updateLayoutChoice();
if (!text->selection && f > -3)
text->sel_cursor = text->cursor;
@ -3690,7 +3691,7 @@ void Buffer::update(signed char f)
if (f==1 || f==-1) {
if (isLyxClean()) {
markDirty();
users->getOwner()->getMiniBuffer()->setTimer(4);
users->owner()->getMiniBuffer()->setTimer(4);
} else {
markDirty();
}

View File

@ -61,8 +61,8 @@ bool updateBulletForm()
}
if (!current_view->available()) {
update = false;
} else if (current_view->currentBuffer()->isReadonly()
|| current_view->currentBuffer()->isLinuxDoc()) {
} else if (current_view->buffer()->isReadonly()
|| current_view->buffer()->isLinuxDoc()) {
fl_deactivate_object (fd_form_bullet->button_ok);
fl_deactivate_object (fd_form_bullet->button_apply);
fl_set_object_lcol (fd_form_bullet->button_ok, FL_INACTIVE);
@ -85,10 +85,10 @@ bool updateBulletForm()
// any settings that need doing each time
fl_set_button(fd_form_bullet->radio_bullet_depth_1, 1);
fl_set_input(fd_form_bullet->input_bullet_latex,
current_view->currentBuffer()
current_view->buffer()
->params.user_defined_bullets[0].c_str());
fl_set_choice(fd_form_bullet->choice_bullet_size,
current_view->currentBuffer()
current_view->buffer()
->params.user_defined_bullets[0].getSize() + 2);
} else {
if (fd_form_bullet->form_bullet->visible) {
@ -110,15 +110,15 @@ void BulletOKCB(FL_OBJECT *ob, long data)
void BulletApplyCB(FL_OBJECT * /*ob*/, long /*data*/ )
{
/* update the bullet settings */
BufferParams & param = current_view->currentBuffer()->params;
// update the bullet settings
BufferParams & param = current_view->buffer()->params;
// a little bit of loop unrolling
param.user_defined_bullets[0] = param.temp_bullets[0];
param.user_defined_bullets[1] = param.temp_bullets[1];
param.user_defined_bullets[2] = param.temp_bullets[2];
param.user_defined_bullets[3] = param.temp_bullets[3];
current_view->currentBuffer()->markDirty();
current_view->buffer()->markDirty();
}
@ -126,7 +126,7 @@ void BulletCancelCB(FL_OBJECT * /*ob*/, long /*data*/ )
{
fl_hide_form(fd_form_bullet->form_bullet);
// this avoids confusion when reopening
BufferParams & param = current_view->currentBuffer()->params;
BufferParams & param = current_view->buffer()->params;
param.temp_bullets[0] = param.user_defined_bullets[0];
param.temp_bullets[1] = param.user_defined_bullets[1];
param.temp_bullets[2] = param.user_defined_bullets[2];
@ -136,8 +136,8 @@ void BulletCancelCB(FL_OBJECT * /*ob*/, long /*data*/ )
void InputBulletLaTeXCB(FL_OBJECT *, long)
{
/* fill-in code for callback */
BufferParams & param = current_view->currentBuffer()->params;
// fill-in code for callback
BufferParams & param = current_view->buffer()->params;
param.temp_bullets[current_bullet_depth].setText(
fl_get_input(fd_form_bullet->input_bullet_latex));
@ -146,7 +146,7 @@ void InputBulletLaTeXCB(FL_OBJECT *, long)
void ChoiceBulletSizeCB(FL_OBJECT * ob, long /*data*/ )
{
BufferParams & param = current_view->currentBuffer()->params;
BufferParams & param = current_view->buffer()->params;
// convert from 1-6 range to -1-4
param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
@ -155,7 +155,7 @@ void ChoiceBulletSizeCB(FL_OBJECT * ob, long /*data*/ )
}
void BulletDepthCB(FL_OBJECT *ob, long data)
void BulletDepthCB(FL_OBJECT * ob, long data)
{
/* Should I do the following: */
/* 1. change to the panel that the current bullet belongs in */
@ -165,7 +165,7 @@ void BulletDepthCB(FL_OBJECT *ob, long data)
/* */
/* I'm inclined to just go with 3 and 4 at the moment and */
/* maybe try to support the others later */
BufferParams & param = current_view->currentBuffer()->params;
BufferParams & param = current_view->buffer()->params;
switch (fl_get_button_numb(ob)) {
case 3:
@ -242,7 +242,7 @@ void BulletBMTableCB(FL_OBJECT *ob, long /*data*/ )
/* to that extracted from the current chosen position of the BMTable */
/* Don't forget to free the button's old pixmap first. */
BufferParams & param = current_view->currentBuffer()->params;
BufferParams & param = current_view->buffer()->params;
int bmtable_button = fl_get_bmtable(ob);
/* try to keep the button held down till another is pushed */

View File

@ -236,7 +236,7 @@ extern "C" void C_Intl_DispatchCallback(FL_OBJECT *ob,long code)
void Intl::InitKeyMapper(bool on)
/* initialize key mapper */
{
lyxerr[Debug::KBMAP] << "Initializing key mappings..." << endl;
lyxerr[Debug::INIT] << "Initializing key mappings..." << endl;
if (prim_lang.empty() && sec_lang.empty())
keymapon = false;

File diff suppressed because it is too large Load Diff

View File

@ -325,9 +325,9 @@ void LyXGUI::init()
void LyXGUI::create_forms()
{
lyxerr.debug() << "Initializing LyXView..." << endl;
lyxerr[Debug::INIT] << "Initializing LyXView..." << endl;
lyxViews = new LyXView(width, height);
lyxerr.debug() << "Initializing LyXView...done" << endl;
lyxerr[Debug::INIT] << "Initializing LyXView...done" << endl;
// From here down should be done by somebody else. (Lgb)
@ -641,5 +641,5 @@ void LyXGUI::runTime()
void LyXGUI::regBuf(Buffer *b)
{
lyxViews->currentView()->setBuffer(b);
lyxViews->currentView()->buffer(b);
}

View File

@ -242,7 +242,7 @@ void updateAllVisibleBufferRelatedPopups()
RefUpdateCB(0,0);
}
#endif
if (current_view->currentBuffer()->isReadonly()) {
if (current_view->buffer()->isReadonly()) {
// a little crude perhaps but it works. ARRae
if (fd_form_character->form_character->visible) {
fl_hide_form(fd_form_character->form_character);
@ -410,6 +410,6 @@ void WarnReadonly()
{
WriteAlert(_("Any changes will be ignored"),
_("The document is read-only:"),
current_view->currentBuffer()->getFileName());
current_view->buffer()->getFileName());
}

View File

@ -66,19 +66,19 @@ LyX::LyX(int * argc, char * argv[])
// Global bindings (this must be done as early as possible.) (Lgb)
toplevel_keymap = new kb_keymap;
lyxerr.debug() << "Initializing lyxrc" << endl;
lyxerr[Debug::INIT] << "Initializing lyxrc" << endl;
lyxrc = new LyXRC;
// Make the GUI object, and let it take care of the
// command line arguments that concerns it.
lyxerr.debug() << "Initializing LyXGUI..." << endl;
lyxerr[Debug::INIT] << "Initializing LyXGUI..." << endl;
lyxGUI = new LyXGUI(this, argc, argv, gui);
lyxerr.debug() << "Initializing LyXGUI...done" << endl;
lyxerr[Debug::INIT] << "Initializing LyXGUI...done" << endl;
// Initialization of LyX (reads lyxrc and more)
lyxerr.debug() << "Initializing LyX::init..." << endl;
lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
init(argc, argv);
lyxerr.debug() << "Initializing LyX::init...done" << endl;
lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
lyxGUI->init();
@ -87,13 +87,13 @@ LyX::LyX(int * argc, char * argv[])
// the only thing left on the command line should be
// filenames.
if ((*argc)==2)
lyxerr.debug() << "Opening document..." << endl;
lyxerr[Debug::INFO] << "Opening document..." << endl;
else if ((*argc)>2)
lyxerr.debug() << "Opening documents..." << endl;
lyxerr[Debug::INFO] << "Opening documents..." << endl;
Buffer * last_loaded = 0;
for (int argi = (*argc) - 1; argi >= 1; argi--) {
for (int argi = (*argc) - 1; argi >= 1; --argi) {
Buffer * loadb = bufferlist.loadLyXFile(argv[argi]);
if (loadb != 0) {
last_loaded = loadb;
@ -169,7 +169,7 @@ void LyX::init(int */*argc*/, char **argv)
<< _("If you have problems, try starting LyX with an absolute path.")
<< endl;
}
lyxerr.debug() << "Path of binary: " << binpath << endl;
lyxerr[Debug::INIT] << "Path of binary: " << binpath << endl;
//
// Determine system directory.
@ -323,7 +323,7 @@ void LyX::init(int */*argc*/, char **argv)
Screen * scr=(DefaultScreenOfDisplay(fl_get_display()));
lyxrc->dpi = ((HeightOfScreen(scr)* 25.4 / HeightMMOfScreen(scr)) +
(WidthOfScreen(scr)* 25.4 / WidthMMOfScreen(scr))) / 2;
lyxerr.debug() << "DPI setting detected to be "
lyxerr[Debug::INFO] << "DPI setting detected to be "
<< lyxrc->dpi+0.5 << endl;
//

View File

@ -141,10 +141,10 @@ void SetSelectionOverLenChars(LyXText *lt, int len)
void LyXFindReplace1::StartSearch()
{
LyXFindReplace0::StartSearch();
SetReplaceEnabled(!current_view->currentBuffer()->isReadonly());
SetReplaceEnabled(!current_view->buffer()->isReadonly());
searchForward = true;
if (lsSearch.empty())
SetSearchString(GetSelectionOrWordAtCursor(current_view->currentBuffer()->text));
SetSearchString(GetSelectionOrWordAtCursor(current_view->buffer()->text));
}
@ -155,7 +155,7 @@ void LyXFindReplace1::SearchReplaceCB()
if (!current_view->getScreen())
return;
if (current_view->currentBuffer()->isReadonly())
if (current_view->buffer()->isReadonly())
return;
// CutSelection cannot cut a single space, so we have to stop
@ -171,17 +171,17 @@ void LyXFindReplace1::SearchReplaceCB()
string const replacestring = ReplaceString();
current_view->getScreen()->HideCursor();
current_view->currentBuffer()->update(-2);
current_view->buffer()->update(-2);
ltCur = current_view->currentBuffer()->text;
ltCur = current_view->buffer()->text;
if (ltCur->selection) {
// clear the selection (if there is any)
current_view->getScreen()->ToggleSelection(false);
current_view->currentBuffer()->text->
current_view->buffer()->text->
ReplaceSelectionWithString(replacestring.c_str());
current_view->currentBuffer()->text->
current_view->buffer()->text->
SetSelectionOverString(replacestring.c_str());
current_view->currentBuffer()->update(1);
current_view->buffer()->update(1);
}
// jump to next match:
@ -196,7 +196,7 @@ void LyXFindReplace1::SearchReplaceAllCB()
if (!current_view->getScreen())
return;
if (current_view->currentBuffer()->isReadonly())
if (current_view->buffer()->isReadonly())
return;
// CutSelection cannot cut a single space, so we have to stop
@ -214,20 +214,20 @@ void LyXFindReplace1::SearchReplaceAllCB()
current_view->getScreen()->HideCursor();
// start at top
current_view->currentBuffer()->text->ClearSelection();
current_view->currentBuffer()->text->CursorTop();
current_view->buffer()->text->ClearSelection();
current_view->buffer()->text->CursorTop();
int replace_count = 0;
do {
ltCur = current_view->currentBuffer()->text;
ltCur = current_view->buffer()->text;
if (ltCur->selection) {
current_view->currentBuffer()->update(-2);
current_view->buffer()->update(-2);
current_view->getScreen()->ToggleSelection(false);
current_view->currentBuffer()->text->
current_view->buffer()->text->
ReplaceSelectionWithString(replacestring.c_str());
current_view->currentBuffer()->text->
current_view->buffer()->text->
SetSelectionOverString(replacestring.c_str());
current_view->currentBuffer()->update(1);
current_view->buffer()->update(1);
replace_count++;
}
} while( SearchCB(true) );
@ -259,8 +259,8 @@ bool LyXFindReplace1::SearchCB(bool fForward)
return(false);
current_view->getScreen()->HideCursor();
current_view->currentBuffer()->update(-2);
ltCur = current_view->currentBuffer()->text;
current_view->buffer()->update(-2);
ltCur = current_view->buffer()->text;
if (ltCur->selection)
ltCur->cursor = fForward ? ltCur->sel_end_cursor :
ltCur->sel_start_cursor;
@ -270,14 +270,14 @@ bool LyXFindReplace1::SearchCB(bool fForward)
if (!ValidSearchData() ||
(fForward ? SearchForward(ltCur) : SearchBackward(ltCur))) {
current_view->currentBuffer()->update(-2);
current_view->buffer()->update(-2);
// clear the selection (if there is any)
current_view->getScreen()->ToggleSelection();
current_view->currentBuffer()->text->ClearSelection();
current_view->buffer()->text->ClearSelection();
// set the new selection
SetSelectionOverLenChars(current_view->currentBuffer()->text, iLenSelected);
SetSelectionOverLenChars(current_view->buffer()->text, iLenSelected);
current_view->getScreen()->ToggleSelection(false);
minibuffer->Set(_("Found."));
result = true;

File diff suppressed because it is too large Load Diff

View File

@ -35,12 +35,12 @@ void InitLyXLookup(Display* display, Window window)
// This part could be done before opening display
setlocale(LC_CTYPE,"");
if (!XSupportsLocale()) {
lyxerr.debug("InitLyXLookup: X does not support this locale.");
lyxerr.debug() << "InitLyXLookup: X does not support this locale." << endl;
return;
}
if (!XSetLocaleModifiers("")) {
lyxerr.debug("InitLyXLookup: Could not set modifiers "
"for this locale.");
lyxerr.debug() << "InitLyXLookup: Could not set modifiers "
"for this locale." << endl;
return;
}
@ -54,15 +54,15 @@ void InitLyXLookup(Display* display, Window window)
0);
if (!xic) {
lyxerr.debug("InitLyXLookup: could not create "
"an input context");
lyxerr.debug() << "InitLyXLookup: could not create "
"an input context" << endl;
XCloseIM (xim);
xim = 0;
}
}
else
lyxerr.debug("InitLyXLookup: could not open "
"an input method.");
lyxerr.debug() << "InitLyXLookup: could not open "
"an input method." << endl;
}
@ -152,8 +152,8 @@ int LyXLookupString(XEvent *event,
return 0;
}
if (event->type != KeyPress)
lyxerr <<"LyXLookupString: wrong event type"
+string(event->type));
lyxerr << "LyXLookupString: wrong event type"
<< event->type << endl;
Status status_return;
result = XmbLookupString(xic, &event->xkey, buffer_return,
@ -189,7 +189,8 @@ int LyXLookupString(XEvent *event,
void CloseLyXLookup()
{
if (xic) {
lyxerr.debug("CloseLyXLookup: destroying input context");
lyxerr.debug() << "CloseLyXLookup: destroying input context"
<< endl;
XDestroyIC(xic);
XCloseIM(xim);
}

View File

@ -4,29 +4,25 @@
#pragma implementation
#endif
#include <unistd.h>
#include FORMS_H_LOCATION
#include "lyxvc.h"
#include "vc-backend.h"
#include "debug.h"
#include "lyx_gui_misc.h"
#include "bufferlist.h"
#include "support/syscall.h"
#include "support/path.h"
#include "support/filetools.h"
#include "support/FileInfo.h"
#include "buffer.h"
#include "gettext.h"
#include "LyXView.h"
#include "support/filetools.h"
#include "lyxfunc.h"
#include "latexoptions.h"
extern BufferList bufferlist;
extern void MenuWrite(Buffer *);
#include "LyXView.h"
LyXVC::LyXVC()
{
backend = UNKNOWN_VCS;
_owner = 0;
vcs = 0;
browser = 0;
owner_ = 0;
}
@ -37,39 +33,27 @@ LyXVC::~LyXVC()
fl_hide_form(browser->LaTeXLog);
fl_free_form(browser->LaTeXLog);
}
if (vcs) {
delete vcs;
}
}
bool LyXVC::file_found_hook(string const & fn)
{
string tmp(fn);
FileInfo f;
// Check if *,v exists.
tmp += ",v";
lyxerr[Debug::LYXVC] << "Checking if file is under vc: "
<< tmp << endl;
if (f.newFile(tmp).readable()) {
lyxerr[Debug::LYXVC] << "Yes it is under vc." << endl;
master = tmp;
backend = RCS_VCS;
scanMaster();
string found_file;
// Check if file is under RCS
if (!(found_file = RCS::find_file(fn)).empty()) {
vcs = new RCS(found_file);
vcs->owner(owner_);
return true;
}
// Check if file is under CVS
if (!(found_file = CVS::find_file(fn)).empty()) {
vcs = new CVS(found_file, fn);
vcs->owner(owner_);
return true;
} else {
// Check if RCS/*,v exists.
tmp = AddName(AddPath(OnlyPath(fn), "RCS"), fn);
tmp += ",v";
lyxerr[Debug::LYXVC] << "Checking if file is under vc: "
<< tmp << endl;
if (f.newFile(tmp).readable()) {
lyxerr[Debug::LYXVC] << "Yes it is under vc."<< endl;
master = tmp;
backend = RCS_VCS;
scanMaster();
return true;
}
}
// If either one, return true
// file is not under any VCS.
return false;
}
@ -82,98 +66,34 @@ bool LyXVC::file_not_found_hook(string const &)
}
void LyXVC::scanMaster()
void LyXVC::buffer(Buffer * buf)
{
lyxerr[Debug::LYXVC] << "LyXVC: This file is a VC file." << endl;
LyXLex lex(0, 0);
lex.setFile(master);
string token;
bool read_enough = false;
while (lex.IsOK() && !read_enough) {
lex.next();
token = lex.GetString();
lyxerr[Debug::LYXVC] <<"LyXVC::scanMaster: current lex text: `"
<< token << "'" << endl;
if (token.empty())
continue;
else if (token == "head") {
// get version here
lex.next();
string tmv = strip(lex.GetString(), ';');
version = tmv;
} else if (contains(token, "access")
|| contains(token, "symbols")
|| contains(token, "strict")) {
// nothing
} else if (contains(token, "locks")) {
// get locker here
if (contains(token, ";")) {
locker = "Unlocked";
vcstat = UNLOCKED;
continue;
}
string tmpt, s1, s2;
do {
lex.next();
s1 = strip(tmpt = lex.GetString(), ';');
// tmp is now in the format <user>:<version>
s1 = split(s1, s2, ':');
// s2 is user, and s1 is version
if (s1 == version) {
locker = s2;
vcstat = LOCKED;
break;
}
} while (!contains(tmpt, ";"));
} else if (token == "comment") {
// we don't need to read any further than this.
read_enough = true;
} else {
// unexpected
lyxerr[Debug::LYXVC]
<< "LyXVC::scanMaster(): unexpected token"
<< endl;
}
}
owner_ = buf;
}
void LyXVC::setBuffer(Buffer * buf)
{
_owner = buf;
}
//
// I will probably add some backend_xxxx functions later to perform the
// version control system specific commands. Something like:
// void backend_revert(<params>) {
// if (backend == "RCS") {
// } else if (backend == "CVS") {
// } else if (backend == "SCCS") {
// }
//
// But for 0.12 we will only support RCS.
//
void LyXVC::registrer()
{
// it is very likely here that the vcs is not created yet...
// so... we use RCS as default, later this should perhaps be
// a lyxrc option.
if (!vcs) {
vcs = new RCS(owner_->getFileName());
vcs->owner(owner_);
}
// If the document is changed, we might want to save it
if (!_owner->isLyxClean() &&
if (!vcs->owner()->isLyxClean() &&
AskQuestion(_("Changes in document:"),
MakeDisplayPath(_owner->getFileName(),50),
MakeDisplayPath(vcs->owner()->getFileName(),50),
_("Save document and proceed?"))) {
MenuWrite(_owner);
vcs->owner()->getUser()->owner()
->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
}
// Maybe the save fails, or we answered "no". In both cases,
// the document will be dirty, and we abort.
if (!_owner->isLyxClean()) {
if (!vcs->owner()->isLyxClean()) {
return;
}
@ -185,56 +105,49 @@ void LyXVC::registrer()
WriteAlert(_("Info"), _("This document has NOT been registered."));
return;
}
string cmd = "ci -q -u -i -t-\"";
cmd += tmp;
cmd += "\" \"";
cmd += OnlyFilename(_owner->getFileName());
cmd += "\"";
doVCCommand(cmd);
_owner->getUser()->getOwner()->getLyXFunc()->Dispatch("buffer-reload");
vcs->registrer(tmp);
}
void LyXVC::checkIn()
{
// If the document is changed, we might want to save it
if (!_owner->isLyxClean() &&
if (!vcs->owner()->isLyxClean() &&
AskQuestion(_("Changes in document:"),
MakeDisplayPath(_owner->getFileName(),50),
MakeDisplayPath(vcs->owner()->getFileName(),50),
_("Save document and proceed?"))) {
MenuWrite(_owner);
vcs->owner()->getUser()->owner()
->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
}
// Maybe the save fails, or we answered "no". In both cases,
// the document will be dirty, and we abort.
if (!_owner->isLyxClean()) {
if (!vcs->owner()->isLyxClean()) {
return;
}
lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl;
_owner->getUser()->getOwner()->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
string tmp = askForText(_("LyX VC: Log Message"));
if (tmp.empty()) tmp = "(no log msg)";
doVCCommand("ci -q -u -m\"" + tmp + "\" \""
+ OnlyFilename(_owner->getFileName()) + "\"");
_owner->getUser()->getOwner()->getLyXFunc()->Dispatch("buffer-reload");
vcs->checkIn(tmp);
}
void LyXVC::checkOut()
{
lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl;
if (!_owner->isLyxClean()
if (!vcs->owner()->isLyxClean()
&& !AskQuestion(_("Changes in document:"),
MakeDisplayPath(_owner->getFileName(),50),
MakeDisplayPath(vcs->owner()->getFileName(),50),
_("Ignore changes and proceed with check out?"))) {
return;
}
_owner->markLyxClean();
doVCCommand("co -q -l \""
+ OnlyFilename(_owner->getFileName()) + "\"");
_owner->getUser()->getOwner()->getLyXFunc()->Dispatch("buffer-reload");
vcs->checkOut();
}
@ -247,32 +160,27 @@ void LyXVC::revert()
if (AskQuestion(_("When you revert, you will loose all changes made"),
_("to the document since the last check in."),
_("Do you still want to do it?"))) {
doVCCommand("co -f -u" + getVersion() + " \""
+ OnlyFilename(_owner->getFileName()) + "\"");
// We ignore changes and just reload!
_owner->markLyxClean();
_owner->getUser()->getOwner()->
getLyXFunc()->Dispatch("buffer-reload");
vcs->revert();
}
}
void LyXVC::undoLast()
{
lyxerr[Debug::LYXVC] << "LyXVC: undoLast" << endl;
doVCCommand("rcs -o" + getVersion() + " \""
+ OnlyFilename(_owner->getFileName()) + "\"");
vcs->undoLast();
}
void LyXVC::toggleReadOnly()
{
switch (vcstat) {
case UNLOCKED:
switch (vcs->stat()) {
case VCS::UNLOCKED:
lyxerr[Debug::LYXVC] << "LyXVC: toggle to locked" << endl;
checkOut();
break;
case LOCKED:
case VCS::LOCKED:
lyxerr[Debug::LYXVC] << "LyXVC: toggle to unlocked" << endl;
checkIn();
break;
}
@ -281,23 +189,23 @@ void LyXVC::toggleReadOnly()
bool LyXVC::inUse()
{
if (!master.empty())
return true;
if (vcs) return true;
return false;
}
string const LyXVC::getVersion() const
string const & LyXVC::version() const
{
return version;
return vcs->version();
}
string const LyXVC::getLocker() const
string const & LyXVC::locker() const
{
return locker;
return vcs->locker();
}
// This is a hack anyway so I'll put it here in the mean time.
void LyXVC::logClose(FL_OBJECT * obj, long)
{
@ -354,14 +262,14 @@ void LyXVC::viewLog(string const & fil)
if (!fl_load_browser(browser->browser_latexlog, fil.c_str()))
fl_add_browser_line(browser->browser_latexlog,
_("No RCS History!"));
_("No VC History!"));
if (browser->LaTeXLog->visible) {
fl_raise_form(browser->LaTeXLog);
} else {
fl_show_form(browser->LaTeXLog,
FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
_("RCS History"));
_("VC History"));
if (ow < 0) {
ow = browser->LaTeXLog->w;
oh = browser->LaTeXLog->h;
@ -374,18 +282,7 @@ void LyXVC::viewLog(string const & fil)
void LyXVC::showLog()
{
string tmpf = tmpnam(0);
doVCCommand("rlog \""
+ OnlyFilename(_owner->getFileName()) + "\" > " + tmpf);
vcs->getLog(tmpf);
viewLog(tmpf);
unlink(tmpf.c_str());
}
int LyXVC::doVCCommand(string const & cmd)
{
lyxerr[Debug::LYXVC] << "doVCCommand: " << cmd << endl;
Systemcalls one;
Path p(_owner->filepath);
int ret = one.startscript(Systemcalls::System, cmd);
return ret;
}

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
#ifndef _LYX_VC_H_
#define _LYX_VC_H_
#ifndef LYX_VC_H
#define LYX_VC_H
#ifdef __GNUG__
#pragma interface
@ -10,22 +10,23 @@
#include "LString.h"
#include "latexoptions.h"
class VCS;
class Buffer;
/** Version Control for LyX. This is the class giving the verison control
features to LyX. It is
intended to support different kinds of version control, but at this point
we will only support RCS. Later CVS is a likely candidate for support.
The support in LyX is based loosely upon the version control in GNU Emacs,
but is not as extensive as that one. See examples/VC.lyx for a simple
tutorial and manual for the use of the version control system in LyX.
LyXVC use this algorithm when it searches for VC files:
for RCS it searches for <filename>,v and RCS/<filename>,v similar
should be done for CVS. By doing this there doesn't need to be any
special support for VC in the lyx format, and this is especially good
when the lyx format will be a subset of LaTeX.
*/
/** Version Control for LyX.
This is the class giving the verison control features to LyX. It is
intended to support different kinds of version control, but at this point
we will only support RCS. Later CVS is a likely candidate for support.
The support in LyX is based loosely upon the version control in GNU Emacs,
but is not as extensive as that one. See examples/VC.lyx for a simple
tutorial and manual for the use of the version control system in LyX.
LyXVC use this algorithm when it searches for VC files:
for RCS it searches for <filename>,v and RCS/<filename>,v similar
should be done for CVS. By doing this there doesn't need to be any
special support for VC in the lyx format, and this is especially good
when the lyx format will be a subset of LaTeX.
*/
class LyXVC {
public:
///
@ -51,9 +52,7 @@ public:
static bool file_not_found_hook(string const & fn);
///
void scanMaster();
///
void setBuffer(Buffer*);
void buffer(Buffer *);
/// Register the document as an VC file.
void registrer();
@ -83,60 +82,25 @@ public:
bool inUse();
/// Returns the version number.
string const getVersion() const;
string const & version() const;
/// Returns the userid of the person who has locked the doc.
string const getLocker() const;
string const & locker() const;
///
static void logClose(FL_OBJECT*, long);
static void logClose(FL_OBJECT *, long);
///
static void logUpdate(FL_OBJECT*, long);
static void logUpdate(FL_OBJECT *, long);
protected:
private:
///
int doVCCommand(string const&);
Buffer * owner_;
/** The master VC file. For RCS this is *,v or RCS/ *,v. master should
have full path.
*/
string master;
/** The version of the VC file. I am not sure if this can be a
string of if it must be a
float/int. */
string version;
/// The user currently keeping the lock on the VC file.
string locker;
///
VCS * vcs;
///
enum VCStatus {
///
UNLOCKED,
///
LOCKED
};
/// The status of the VC controlled file.
VCStatus vcstat;
///
enum Backend {
///
UNKNOWN_VCS,
///
RCS_VCS
};
/// The VC backend used. (so far this can only be RCS)
Backend backend;
/// The buffer using this VC
Buffer *_owner;
///
FD_LaTeXLog *browser; // FD_LaTeXLog is just a browser with a
FD_LaTeXLog * browser; // FD_LaTeXLog is just a browser with a
// close button. Unfortunately we can not use the standard callbacks.
};

View File

@ -458,7 +458,7 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
fl_set_button(ob, 0);
fl_redraw_object(ob);
Buffer * tmpbuffer = men->_view->currentBuffer();
Buffer * tmpbuffer = men->_view->buffer();
LyXFunc * tmpfunc = men->_view->getLyXFunc();
bool LinuxDoc = tmpbuffer->isLinuxDoc();
@ -673,7 +673,7 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
case 18: // The first item with lastfiles.
default:
men->currentView()
->setBuffer(bufferlist
->buffer(bufferlist
.loadLyXFile((*lastfiles)[choice - 18]));
break;
}
@ -789,7 +789,7 @@ void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
case 6: // The first item with lastfiles.
default:
men->currentView()
->setBuffer(bufferlist
->buffer(bufferlist
.loadLyXFile((*lastfiles)[choice - 6]));
break;
}
@ -810,7 +810,7 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
fl_set_button(ob, 0);
fl_redraw_object(ob);
Buffer * tmpbuffer = men->_view->currentBuffer();
Buffer * tmpbuffer = men->_view->buffer();
LyXFunc * tmpfunc = men->_view->getLyXFunc();
// Floats & Insets submenu
@ -1135,7 +1135,7 @@ void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
fl_set_button(ob, 0);
fl_redraw_object(ob);
Buffer * tmpbuffer = men->_view->currentBuffer();
Buffer * tmpbuffer = men->_view->buffer();
LyXFunc * tmpfunc = men->_view->getLyXFunc();
int LayoutMenu = fl_newpup(FL_ObjWin(ob));
@ -1225,7 +1225,7 @@ void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
fl_set_button(ob, 0);
fl_redraw_object(ob);
Buffer * tmpbuffer = men->_view->currentBuffer();
Buffer * tmpbuffer = men->_view->buffer();
LyXFunc * tmpfunc = men->_view->getLyXFunc();
int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
@ -1428,7 +1428,7 @@ void Menus::ShowMathMenu(FL_OBJECT * ob, long)
fl_set_button(ob, 0);
fl_redraw_object(ob);
Buffer * tmpbuffer = men->_view->currentBuffer();
Buffer * tmpbuffer = men->_view->buffer();
LyXFunc * tmpfunc = men->_view->getLyXFunc();
int MathMenu = fl_defpup(FL_ObjWin(ob),
@ -1662,7 +1662,7 @@ void Menus::MenuDocu(string const & docname)
string fname = i18nLibFileSearch("doc", docname, "lyx");
_view->getMiniBuffer()->Set(_("Opening help file"),
MakeDisplayPath(fname),"...");
currentView()->setBuffer(bufferlist.loadLyXFile(fname,false));
currentView()->buffer(bufferlist.loadLyXFile(fname,false));
if (docname == "Reference")
_view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
@ -1671,5 +1671,5 @@ void Menus::MenuDocu(string const & docname)
void Menus::handleBufferMenu(int choice)
{
currentView()->setBuffer(bufferlist.getBuffer(choice));
currentView()->buffer(bufferlist.getBuffer(choice));
}

View File

@ -30,20 +30,20 @@ extern string keyseqOptions(int l=190);
extern string keyseqStr(int l=190);
extern LyXAction lyxaction;
void MiniBuffer::TimerCB(FL_OBJECT *, long tmp)
void MiniBuffer::TimerCB(FL_OBJECT * ob, long)
{
MiniBuffer *obj= (MiniBuffer*)tmp;
MiniBuffer * obj = static_cast<MiniBuffer*>(ob->u_vdata);
obj->Init();
}
extern "C" void C_MiniBuffer_TimerCB(FL_OBJECT *ob, long data)
extern "C" void C_MiniBuffer_TimerCB(FL_OBJECT * ob, long data)
{
MiniBuffer::TimerCB(ob, data);
}
void MiniBuffer::ExecutingCB(FL_OBJECT *ob, long)
void MiniBuffer::ExecutingCB(FL_OBJECT * ob, long)
{
MiniBuffer *obj = (MiniBuffer*)ob->u_vdata;
MiniBuffer * obj = static_cast<MiniBuffer*>(ob->u_vdata);
lyxerr.debug() << "Getting ready to execute: " << obj->cur_cmd << endl;
fl_set_focus_object(obj->owner->getForm(),
obj->owner->currentView()->getWorkArea());
@ -68,7 +68,7 @@ void MiniBuffer::ExecutingCB(FL_OBJECT *ob, long)
<< "\nArg : " << arg << endl;
// Dispatch only returns requested data for a few commands (ale)
string res=obj->owner->getLyXFunc()->Dispatch(function.c_str(),
string res = obj->owner->getLyXFunc()->Dispatch(function.c_str(),
arg.c_str());
lyxerr.debug() << "Minibuffer Res: " << res << endl;
obj->shows_no_match = false;
@ -76,19 +76,19 @@ void MiniBuffer::ExecutingCB(FL_OBJECT *ob, long)
return ;
}
extern "C" void C_MiniBuffer_ExecutingCB(FL_OBJECT *ob, long data)
extern "C" void C_MiniBuffer_ExecutingCB(FL_OBJECT * ob, long data)
{
MiniBuffer::TimerCB(ob, data);
}
// This is not as dirty as it seems, the hidden buttons removed by this
// function were just kludges for an uncomplete keyboard callback (ale)
int MiniBuffer::peek_event(FL_OBJECT *ob, int event, FL_Coord, FL_Coord,
int MiniBuffer::peek_event(FL_OBJECT * ob, int event, FL_Coord, FL_Coord,
int key, void */*xev*/)
{
MiniBuffer *mini = (MiniBuffer*)ob->u_vdata;
MiniBuffer * mini = static_cast<MiniBuffer*>(ob->u_vdata);
if (event==FL_KEYBOARD){
if (event == FL_KEYBOARD){
switch (key) {
case XK_Down:
mini->history_idx++;
@ -105,7 +105,7 @@ int MiniBuffer::peek_event(FL_OBJECT *ob, int event, FL_Coord, FL_Coord,
case XK_Tab:
{
// complete or increment the command
const char *s = lyxaction.getApproxFuncName(fl_get_input(ob));
char const * s = lyxaction.getApproxFuncName(fl_get_input(ob));
if (s && s[0])
fl_set_input(ob, s);
return 1;
@ -130,9 +130,9 @@ int MiniBuffer::peek_event(FL_OBJECT *ob, int event, FL_Coord, FL_Coord,
return 0;
}
extern "C" int C_MiniBuffer_peek_event(FL_OBJECT *ob, int event,
extern "C" int C_MiniBuffer_peek_event(FL_OBJECT * ob, int event,
FL_Coord, FL_Coord,
int key, void *xev)
int key, void * xev)
{
return MiniBuffer::peek_event(ob,event,0,0,key,xev);
}
@ -146,10 +146,10 @@ void MiniBuffer::ExecCommand()
}
FL_OBJECT *MiniBuffer::add(int type, FL_Coord x, FL_Coord y,
FL_OBJECT * MiniBuffer::add(int type, FL_Coord x, FL_Coord y,
FL_Coord w, FL_Coord h)
{
FL_OBJECT *obj;
FL_OBJECT * obj;
the_buffer = obj = fl_add_input(type,x,y,w,h,text.c_str());
fl_set_object_boxtype(obj,FL_DOWN_BOX);
@ -161,12 +161,13 @@ FL_OBJECT *MiniBuffer::add(int type, FL_Coord x, FL_Coord y,
// To intercept Up, Down, Table for history
fl_set_object_prehandler(obj, C_MiniBuffer_peek_event);
obj->u_vdata = (void*)this;
obj->u_vdata = this;
obj->wantkey = FL_KEY_TAB;
// timer
timer = fl_add_timer(FL_HIDDEN_TIMER, 0,0,0,0, "Timer");
fl_set_object_callback(timer, C_MiniBuffer_TimerCB, (long)this);
fl_set_object_callback(timer, C_MiniBuffer_TimerCB, 0);
timer->u_vdata = this;
fl_set_input(the_buffer, text.c_str());
return obj;
@ -210,23 +211,23 @@ void MiniBuffer::Init()
// Else, show the buffer state.
else if (owner->currentView()->available()) {
string nicename =
MakeDisplayPath(owner->currentBuffer()->
MakeDisplayPath(owner->buffer()->
getFileName());
// Should we do this instead? (kindo like emacs)
// leaves more room for other information
text = "LyX: ";
text += nicename;
if (owner->currentBuffer()->lyxvc.inUse()) {
text += " [RCS:";
text += owner->currentBuffer()->lyxvc.getVersion();
if (owner->buffer()->lyxvc.inUse()) {
text += " [";
text += owner->buffer()->lyxvc.version();
text += ' ';
text += owner->currentBuffer()->lyxvc.getLocker();
if (owner->currentBuffer()->isReadonly())
text += owner->buffer()->lyxvc.locker();
if (owner->buffer()->isReadonly())
text += " (RO)";
text += ']';
} else if (owner->currentBuffer()->isReadonly())
} else if (owner->buffer()->isReadonly())
text += " [RO]";
if (!owner->currentBuffer()->isLyxClean())
if (!owner->buffer()->isLyxClean())
text += _(" (Changed)");
} else {
if (text != _("Welcome to LyX!")) // this is a hack

View File

@ -454,7 +454,7 @@ void LyXParagraph::validate(LaTeXFeatures & features)
if (layout.needprotect
&& next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
features.NeedLyXFootnoteCode = true;
if ((current_view->currentBuffer()->params.paragraph_separation == LYX_PARSEP_INDENT) &&
if ((current_view->buffer()->params.paragraph_separation == LYX_PARSEP_INDENT) &&
(pextra_type == PEXTRA_MINIPAGE))
features.NeedLyXMinipageIndent = true;
if (table && table->NeedRotating())
@ -3735,7 +3735,7 @@ void LyXParagraph::SimpleTeXSpecialChars(string & file, TexRow & texrow,
case '°': case '±': case '²': case '³':
case '×': case '÷': case '¹': case 'ª':
case 'º': case '¬': case 'µ':
if (current_view->currentBuffer()->params.inputenc == "latin1") {
if (current_view->buffer()->params.inputenc == "latin1") {
file += "\\ensuremath{";
file += c;
file += '}';
@ -3806,7 +3806,7 @@ void LyXParagraph::SimpleTeXSpecialChars(string & file, TexRow & texrow,
break;
case '£':
if (current_view->currentBuffer()->params.inputenc == "default") {
if (current_view->buffer()->params.inputenc == "default") {
file += "\\pounds{}";
column += 8;
} else {
@ -4048,7 +4048,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(string & file, TexRow & texrow,
// flags when footnotetext should be appended to file.
static bool minipage_open = false;
static int minipage_open_depth = 0;
char par_sep = current_view->currentBuffer()->params.paragraph_separation;
char par_sep = current_view->buffer()->params.paragraph_separation;
lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
if (IsDummy())
@ -4347,7 +4347,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(string & file, TexRow & texrow,
texrow.newline();
}
BufferParams * params = &current_view->currentBuffer()->params;
BufferParams * params = &current_view->buffer()->params;
bool footer_in_body = true;
switch (footnotekind) {
case LyXParagraph::FOOTNOTE:

View File

@ -325,13 +325,13 @@ void create_ispell_pipe(string const & lang)
argv[argc++] = tmp;
}
if (lyxrc->isp_use_input_encoding &&
current_view->currentBuffer()->params.inputenc != "default") {
current_view->buffer()->params.inputenc != "default") {
tmp = new char[3];
string("-T").copy(tmp, 2); tmp[2] = '\0';
argv[argc++] = tmp; // Input encoding
tmp = new char[current_view->currentBuffer()->params.inputenc.length() + 1];
current_view->currentBuffer()->params.inputenc.copy(tmp, current_view->currentBuffer()->params.inputenc.length());
tmp[current_view->currentBuffer()->params.inputenc.length()] = '\0';
tmp = new char[current_view->buffer()->params.inputenc.length() + 1];
current_view->buffer()->params.inputenc.copy(tmp, current_view->buffer()->params.inputenc.length());
tmp[current_view->buffer()->params.inputenc.length()] = '\0';
argv[argc++] = tmp;
}
@ -585,7 +585,7 @@ void ShowSpellChecker()
fl_set_object_lcol(fd_form_spell_check->input, FL_BLACK);
fl_set_object_lcol(fd_form_spell_check->browser, FL_BLACK);
// activate replace only if the file is not read-only
if (!current_view->currentBuffer()->isReadonly()) {
if (!current_view->buffer()->isReadonly()) {
fl_activate_object(fd_form_spell_check->replace);
fl_set_object_lcol(fd_form_spell_check->replace, FL_BLACK);
}
@ -596,7 +596,7 @@ void ShowSpellChecker()
fl_set_object_lcol(fd_form_spell_check->options, FL_INACTIVE);
fl_set_object_lcol(fd_form_spell_check->start, FL_INACTIVE);
ret = RunSpellChecker(current_view->currentBuffer()->GetLanguage());
ret = RunSpellChecker(current_view->buffer()->GetLanguage());
// deactivate insert, accept, replace, and stop
fl_deactivate_object(fd_form_spell_check->insert);

View File

@ -629,7 +629,8 @@ lyxstring & lyxstring::assign(iterator first, iterator last)
lyxstring::const_reference lyxstring::operator[](size_type pos) const
{
Assert(pos <= rep->sz); // OURS!
return pos == rep->sz ? '\0' : rep->s[pos];
static char helper = '\0';
return pos == rep->sz ? helper : rep->s[pos];
}

View File

@ -31,9 +31,9 @@ void LaTeXOptionsOK(FL_OBJECT *ob, long data)
void LaTeXOptionsApply(FL_OBJECT *, long)
{
if (fl_get_button(fd_latex_options->accents))
current_view->currentBuffer()->params.allowAccents = true;
current_view->buffer()->params.allowAccents = true;
else
current_view->currentBuffer()->params.allowAccents = false;
current_view->buffer()->params.allowAccents = false;
}
void LaTeXOptionsCancel(FL_OBJECT *, long)

View File

@ -1807,8 +1807,8 @@ void LyXText::TableFeatures(int feature)
return;
}
case LyXTable::DELETE_ROW:
if (current_view->currentBuffer()->the_locking_inset)
UnlockInset(current_view->currentBuffer()->the_locking_inset);
if (current_view->buffer()->the_locking_inset)
UnlockInset(current_view->buffer()->the_locking_inset);
RemoveTableRow(&cursor);
RedoParagraph();
return;
@ -1821,8 +1821,8 @@ void LyXText::TableFeatures(int feature)
#endif
int cell_org = actCell;
int cell = 0;
if (current_view->currentBuffer()->the_locking_inset)
UnlockInset(current_view->currentBuffer()->the_locking_inset);
if (current_view->buffer()->the_locking_inset)
UnlockInset(current_view->buffer()->the_locking_inset);
do {
if (!pos || (cursor.par->IsNewline(pos-1))){
if (cursor.par->table->DeleteCellIfColumnIsDeleted(cell, cell_org)){

View File

@ -97,7 +97,7 @@ string TransDeadkeyState::normalkey(char c,char *trans)
}
if (l==0) {
// Not an exception. Check if it allowed
if (current_view->currentBuffer()->params.allowAccents==true ||
if (current_view->buffer()->params.allowAccents==true ||
countChar(deadkey_info_.allowed, c) > 0) {
res=DoAccent(c,deadkey_info_.accent);
} else {

306
src/vc-backend.C Normal file
View File

@ -0,0 +1,306 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <fstream>
#include "vc-backend.h"
#include "debug.h"
#include "support/FileInfo.h"
#include "support/LRegex.h"
#include "support/LSubstring.h"
#include "support/path.h"
#include "buffer.h"
#include "LyXView.h"
#include "lyxfunc.h"
int VCS::doVCCommand(string const & cmd)
{
lyxerr[Debug::LYXVC] << "doVCCommand: " << cmd << endl;
Systemcalls one;
Path p(owner_->filepath);
int ret = one.startscript(Systemcalls::System, cmd);
return ret;
}
RCS::RCS(string const & m)
{
master_ = m;
scanMaster();
}
string RCS::find_file(string const & file)
{
string tmp(file);
// Check if *,v exists.
tmp += ",v";
FileInfo f;
lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
<< tmp << endl;
if (f.newFile(tmp).readable()) {
lyxerr[Debug::LYXVC] << "Yes " << file
<< " is under rcs." << endl;
return tmp;
} else {
// Check if RCS/*,v exists.
tmp = AddName(AddPath(OnlyPath(file), "RCS"), file);
tmp += ",v";
lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
<< tmp << endl;
if (f.newFile(tmp).readable()) {
lyxerr[Debug::LYXVC] << "Yes " << file
<< " it is under rcs."<< endl;
return tmp;
}
}
return string();
}
void RCS::scanMaster()
{
lyxerr[Debug::LYXVC] << "LyXVC::RCS: scanMaster." << endl;
ifstream ifs(master_.c_str());
string token;
bool read_enough = false;
while (!read_enough && ifs >> token) {
lyxerr[Debug::LYXVC]
<< "LyXVC::scanMaster: current lex text: `"
<< token << "'" << endl;
if (token.empty())
continue;
else if (token == "head") {
// get version here
string tmv;
ifs >> tmv;
tmv = strip(tmv, ';');
version_ = tmv;
lyxerr[Debug::LYXVC] << "LyXVC: version found to be "
<< tmv << endl;
} else if (contains(token, "access")
|| contains(token, "symbols")
|| contains(token, "strict")) {
// nothing
} else if (contains(token, "locks")) {
// get locker here
if (contains(token, ";")) {
locker_ = "Unlocked";
vcstat = UNLOCKED;
continue;
}
string tmpt, s1, s2;
do {
ifs >> tmpt;
s1 = strip(tmpt, ';');
// tmp is now in the format <user>:<version>
s1 = split(s1, s2, ':');
// s2 is user, and s1 is version
if (s1 == version_) {
locker_ = s2;
vcstat = LOCKED;
break;
}
} while (!contains(tmpt, ";"));
} else if (token == "comment") {
// we don't need to read any further than this.
read_enough = true;
} else {
// unexpected
lyxerr[Debug::LYXVC]
<< "LyXVC::scanMaster(): unexpected token"
<< endl;
}
}
version_ = "RCS: " + version_;
}
void RCS::registrer(string const & msg)
{
string cmd = "ci -q -u -i -t-\"";
cmd += msg;
cmd += "\" \"";
cmd += OnlyFilename(owner_->getFileName());
cmd += "\"";
doVCCommand(cmd);
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
}
void RCS::checkIn(string const & msg)
{
doVCCommand("ci -q -u -m\"" + msg + "\" \""
+ OnlyFilename(owner_->getFileName()) + "\"");
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
}
void RCS::checkOut()
{
owner_->markLyxClean();
doVCCommand("co -q -l \""
+ OnlyFilename(owner_->getFileName()) + "\"");
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
}
void RCS::revert()
{
doVCCommand("co -f -u" + version() + " \""
+ OnlyFilename(owner_->getFileName()) + "\"");
// We ignore changes and just reload!
owner_->markLyxClean();
owner_->getUser()->owner()
->getLyXFunc()->Dispatch("buffer-reload");
}
void RCS::undoLast()
{
lyxerr[Debug::LYXVC] << "LyXVC: undoLast" << endl;
doVCCommand("rcs -o" + version() + " \""
+ OnlyFilename(owner_->getFileName()) + "\"");
}
void RCS::getLog(string const & tmpf)
{
doVCCommand("rlog \""
+ OnlyFilename(owner_->getFileName()) + "\" > " + tmpf);
}
CVS::CVS(string const & m, string const & f)
{
master_ = m;
file_ = f;
scanMaster();
}
string CVS::find_file(string const & file)
{
// First we look for the CVS/Entries in the same dir
// where we have file.
string dir = OnlyPath(file);
string tmpf = "/" + OnlyFilename(file) + "/";
dir += "/CVS/Entries";
lyxerr[Debug::LYXVC] << "LyXVC: checking in `" << dir
<< "' for `" << tmpf << "'" << endl;
FileInfo f(dir);
if (f.readable()) {
// Ok we are at least in a CVS dir. Parse the CVS/Entries
// and see if we can find this file. We do a fast and
// dirty parse here.
ifstream ifs(dir.c_str());
string line;
while (getline(ifs, line)) {
lyxerr[Debug::LYXVC] << "\tEntries: " << line << endl;
if (contains(line, tmpf)) return dir;
}
}
return string();
}
void CVS::scanMaster()
{
lyxerr[Debug::LYXVC] << "LyXVC::CVS: scanMaster. \n Checking: "
<< master_ << endl;
// Ok now we do the real scan...
ifstream ifs(master_.c_str());
string tmpf = "/" + OnlyFilename(file_) + "/";
lyxerr[Debug::LYXVC] << "\tlooking for `" << tmpf << "'" << endl;
string line;
while(getline(ifs, line)) {
lyxerr[Debug::LYXVC] << "\t line: " << line << endl;
if (contains(line, tmpf)) {
// Ok extract the fields.
LRegex reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
LRegex::SubMatches const & sm = reg.exec(line);
//sm[0]; // whole matched string
//sm[1]; // filename
version_ = "CVS: ";
version_ += LSubstring(line, sm[2].first,
sm[2].second);
string file_date = LSubstring(line, sm[3].first,
sm[3].second);
//sm[4]; // options
//sm[5]; // tag or tagdate
FileInfo fi(file_);
time_t mod = fi.getModificationTime();
string mod_date = strip(asctime(gmtime(&mod)), '\n');
lyxerr[Debug::LYXVC]
<< "Date in Entries: `" << file_date
<< "'\nModification date of file: `"
<< mod_date << "'" << endl;
if (file_date == mod_date) {
locker_ = "Unlocked";
vcstat = UNLOCKED;
} else {
// Here we should also to some more checking
// to see if there are conflicts or not.
locker_ = "Locked";
vcstat = LOCKED;
}
#if 0
for (LRegex::SubMatches::const_iterator cit = sm.begin();
cit != sm.end(); ++cit) {
if ((*cit).first != string::npos)
lyxerr << string(line, (*cit).first,
(*cit).second) << endl;
}
#endif
break;
}
}
}
void CVS::registrer(string const & msg)
{
// cvs add
}
void CVS::checkIn(string const & msg)
{
// cvs commit
}
void CVS::checkOut()
{
// cvs update
}
void CVS::revert()
{
// not sure how to do this...
// rm file
// cvs update
}
void CVS::undoLast()
{
// merge the current with the previous version
// in a reverse patch kind of way, so that the
// result is to revert the last changes.
}
void CVS::getLog(string const &)
{
}

124
src/vc-backend.h Normal file
View File

@ -0,0 +1,124 @@
// -*- C++ -*-
#ifndef VC_BACKEND_H
#define VC_BACKEND_H
#ifdef __GNUG__
#pragma interface
#endif
#include "LString.h"
#include "support/syscall.h"
class Buffer;
///
class VCS {
public:
///
enum VCStatus {
///
UNLOCKED,
///
LOCKED
};
///
virtual ~VCS() {}
///
virtual void scanMaster() = 0;
///
virtual void registrer(string const & msg) = 0;
///
virtual void checkIn(string const & msg) = 0;
///
virtual void checkOut() = 0;
///
virtual void revert() = 0;
///
virtual void undoLast() = 0;
///
virtual void getLog(string const &) = 0;
///
string const & version() const { return version_; }
///
string const & locker() const { return locker_; }
///
void owner(Buffer * b) { owner_ = b; }
///
Buffer * owner() const { return owner_; }
///
VCStatus stat() const { return vcstat; }
protected:
///
int doVCCommand(string const &);
/** The master VC file. For RCS this is *,v or RCS/ *,v. master should
have full path.
*/
string master_;
/// The status of the VC controlled file.
VCStatus vcstat;
/** The version of the VC file. I am not sure if this can be a
string of if it must be a
float/int. */
string version_;
/// The user currently keeping the lock on the VC file.
string locker_;
/// The buffer using this VC
Buffer * owner_;
};
///
class RCS : public VCS {
public:
///
RCS(string const & m);
///
static string find_file(string const & file);
///
virtual void scanMaster();
///
virtual void registrer(string const & msg);
///
virtual void checkIn(string const & msg);
///
virtual void checkOut();
///
virtual void revert();
///
virtual void undoLast();
///
virtual void getLog(string const &);
private:
};
///
class CVS : public VCS {
public:
///
CVS(string const & m, string const & f);
///
static string find_file(string const & file);
///
virtual void scanMaster();
///
virtual void registrer(string const & msg);
///
virtual void checkIn(string const & msg);
///
virtual void checkOut();
///
virtual void revert();
///
virtual void undoLast();
///
virtual void getLog(string const &);
private:
string file_;
};
#endif

View File

@ -473,7 +473,7 @@ string VSpace::asLatexCommand() const
switch (kin) {
case NONE: return string();
case DEFSKIP:
return current_view->currentBuffer()->params.getDefSkip().asLatexCommand();
return current_view->buffer()->params.getDefSkip().asLatexCommand();
case SMALLSKIP: return kp ? "\\vspace*{\\smallskipamount}"
: "\\smallskip{}";
case MEDSKIP: return kp ? "\\vspace*{\\medskipamount}"
@ -492,7 +492,7 @@ string VSpace::asLatexCommand() const
int VSpace::inPixels() const
{
// Height of a normal line in pixels (zoom factor considered)
int height = current_view->currentBuffer()->text->DefaultHeight(); // [pixels]
int height = current_view->buffer()->text->DefaultHeight(); // [pixels]
// Zoom factor specified by user in percent
float const zoom = lyxrc->zoom / 100.0; // [percent]
@ -507,7 +507,7 @@ int VSpace::inPixels() const
case NONE: return 0;
case DEFSKIP:
return current_view->currentBuffer()->params.getDefSkip().inPixels();
return current_view->buffer()->params.getDefSkip().inPixels();
// This is how the skips are normally defined by
// LateX. But there should be some way to change