the current_view patch

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7140 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-06-10 14:39:45 +00:00
parent 8dea72a38c
commit 309c18fbeb
21 changed files with 132 additions and 123 deletions

View File

@ -53,7 +53,6 @@ src/frontends/qt2/QExternal.C
src/frontends/qt2/QExternalDialog.C
src/frontends/qt2/QFloat.C
src/frontends/qt2/QGraphics.C
src/frontends/qt2/QGraphicsDialog.C
src/frontends/qt2/QInclude.C
src/frontends/qt2/QLPrintDialog.C
src/frontends/qt2/QLog.C
@ -133,6 +132,7 @@ src/frontends/xforms/xformsBC.h
src/frontends/xforms/xforms_helpers.C
src/gettext.h
src/importer.C
src/insets/graphicinset.C
src/insets/inset.C
src/insets/insetbibtex.C
src/insets/insetcaption.C
@ -151,7 +151,6 @@ src/insets/insetmarginal.C
src/insets/insetminipage.C
src/insets/insetnote.C
src/insets/insetoptarg.C
src/insets/insetparent.C
src/insets/insetref.C
src/insets/insettabular.C
src/insets/insettext.C

View File

@ -1,3 +1,33 @@
2003-06-10 Lars Gullik Bjønnes <larsbj@lyx.org>
* text2.C (cutSelection): adjust
(pasteSelection): adjust
* messages.C: handle get of empty string
* main.C (main): use sync_with_stdio(false)
* lyxfunc.C (dispatch): adjust
* lyx_cb.[Ch] (MenuWrite): remove unneeded BufferView arg
(WriteAs): remove unneeded BufferView arg.
* bufferparams.h: use correct types on papersize, papersize2 and
paperpackage.
* bufferparams.C (readToken): adjust for type
(writeLaTeX): add missing cases to switch.
* bufferlist.C (quitWriteBuffer): adjust
(close): adjust
* buffer.C (asciiParagraph): remove some commented code.
* CutAndPaste.C: remove current_view extern variable.
(cutSelection): add BufferParams arg.
(eraseSelection): add BufferParams arg.
(pasteSelection): add Buffer const & arg
2003-06-07 John Levon <levon@movementarian.org>
* buffer.C:
@ -16,7 +46,7 @@
2003-06-06 Alfredo Braunstein <abraunst@libero.it>
* BufferView_pimpl.C (dispatch): use Dialogs::visible
2003-06-04 Angus Leeming <leeming@lyx.org>
* buffer.C: bump format to 224.

View File

@ -39,8 +39,6 @@ using std::for_each;
using lyx::pos_type;
using lyx::textclass_type;
extern BufferView * current_view;
// Jürgen, note that this means that you cannot currently have a list
// of selections cut/copied. So IMHO later we should have a
// list/vector/deque that we could store
@ -66,19 +64,21 @@ limited_stack<pair<ParagraphList, textclass_type> > cuts(10);
} // namespace anon
PitPosPair CutAndPaste::cutSelection(ParagraphList & pars,
PitPosPair CutAndPaste::cutSelection(BufferParams const & params,
ParagraphList & pars,
ParagraphList::iterator startpit,
ParagraphList::iterator endpit,
int startpos, int endpos,
textclass_type tc, bool doclear)
{
copySelection(startpit, endpit, startpos, endpos, tc);
return eraseSelection(pars, startpit, endpit, startpos,
return eraseSelection(params, pars, startpit, endpit, startpos,
endpos, doclear);
}
PitPosPair CutAndPaste::eraseSelection(ParagraphList & pars,
PitPosPair CutAndPaste::eraseSelection(BufferParams const & params,
ParagraphList & pars,
ParagraphList::iterator startpit,
ParagraphList::iterator endpit,
int startpos, int endpos, bool doclear)
@ -138,10 +138,7 @@ PitPosPair CutAndPaste::eraseSelection(ParagraphList & pars,
if (all_erased &&
(startpit->hasSameLayout(*boost::next(startpit)) ||
boost::next(startpit)->empty())) {
#warning current_view used here.
// should we pass buffer or buffer->params around?
Buffer * buffer = current_view->buffer();
mergeParagraph(buffer->params, pars, startpit);
mergeParagraph(params, pars, startpit);
// this because endpar gets deleted here!
endpit = startpit;
endpos = startpos;
@ -196,16 +193,18 @@ bool CutAndPaste::copySelection(ParagraphList::iterator startpit,
pair<PitPosPair, ParagraphList::iterator>
CutAndPaste::pasteSelection(ParagraphList & pars,
CutAndPaste::pasteSelection(Buffer const & buffer,
ParagraphList & pars,
ParagraphList::iterator pit, int pos,
textclass_type tc,
ErrorList & errorlist)
{
return pasteSelection(pars, pit, pos, tc, 0, errorlist);
return pasteSelection(buffer, pars, pit, pos, tc, 0, errorlist);
}
pair<PitPosPair, ParagraphList::iterator>
CutAndPaste::pasteSelection(ParagraphList & pars,
CutAndPaste::pasteSelection(Buffer const & buffer,
ParagraphList & pars,
ParagraphList::iterator pit, int pos,
textclass_type tc, size_t cut_index,
ErrorList & errorlist)
@ -258,7 +257,7 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
tmpbuf->erase(i--);
}
} else {
LyXFont f1 = tmpbuf->getFont(current_view->buffer()->params, i, outerFont(pit, pars));
LyXFont f1 = tmpbuf->getFont(buffer.params, i, outerFont(pit, pars));
LyXFont f2 = f1;
if (!pit->checkInsertChar(f1)) {
tmpbuf->erase(i--);
@ -288,17 +287,17 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
case Inset::INCLUDE_CODE: {
InsetInclude * ii = static_cast<InsetInclude*>(lit->inset);
InsetInclude::Params ip = ii->params();
ip.masterFilename_ = current_view->buffer()->fileName();
ip.masterFilename_ = buffer.fileName();
ii->set(ip);
break;
}
case Inset::TABULAR_CODE: {
InsetTabular * it = static_cast<InsetTabular*>(lit->inset);
it->buffer(current_view->buffer());
it->buffer(const_cast<Buffer*>(&buffer));
break;
}
default:
break; // nothing
}
@ -310,7 +309,7 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
// Open the paragraph for inserting the buf
// if necessary.
if (pit->size() > pos || boost::next(pit) == pars.end()) {
breakParagraphConservative(current_view->buffer()->params,
breakParagraphConservative(buffer.params,
pars, pit, pos);
paste_the_end = true;
}
@ -328,7 +327,7 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
if (boost::next(pit) == last_paste)
last_paste = pit;
mergeParagraph(current_view->buffer()->params, pars, pit);
mergeParagraph(buffer.params, pars, pit);
// Store the new cursor position.
pit = last_paste;
@ -339,15 +338,15 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
if (boost::next(last_paste) != pars.end() &&
paste_the_end) {
if (boost::next(last_paste)->hasSameLayout(*last_paste)) {
mergeParagraph(current_view->buffer()->params, pars,
mergeParagraph(buffer.params, pars,
last_paste);
} else if (boost::next(last_paste)->empty()) {
boost::next(last_paste)->makeSameLayout(*last_paste);
mergeParagraph(current_view->buffer()->params, pars,
mergeParagraph(buffer.params, pars,
last_paste);
} else if (last_paste->empty()) {
last_paste->makeSameLayout(*boost::next(last_paste));
mergeParagraph(current_view->buffer()->params, pars,
mergeParagraph(buffer.params, pars,
last_paste);
} else
boost::next(last_paste)->stripLeadingSpaces();

View File

@ -23,29 +23,33 @@ class ErrorList;
///
namespace CutAndPaste {
///
PitPosPair cutSelection(ParagraphList & pars,
ParagraphList::iterator startpit,
ParagraphList::iterator endpit,
int start, int end, lyx::textclass_type tc,
bool doclear = false);
PitPosPair cutSelection(BufferParams const & params,
ParagraphList & pars,
ParagraphList::iterator startpit,
ParagraphList::iterator endpit,
int start, int end, lyx::textclass_type tc,
bool doclear = false);
///
PitPosPair eraseSelection(ParagraphList & pars,
ParagraphList::iterator startpit,
ParagraphList::iterator endpit,
int start, int end, bool doclear = false);
PitPosPair eraseSelection(BufferParams const & params,
ParagraphList & pars,
ParagraphList::iterator startpit,
ParagraphList::iterator endpit,
int start, int end, bool doclear = false);
///
bool copySelection(ParagraphList::iterator startpit,
ParagraphList::iterator endpit,
int start, int end, lyx::textclass_type tc);
///
std::pair<PitPosPair, ParagraphList::iterator>
pasteSelection(ParagraphList & pars,
pasteSelection(Buffer const & buffer,
ParagraphList & pars,
ParagraphList::iterator pit, int pos,
lyx::textclass_type tc, ErrorList &);
///
std::pair<PitPosPair, ParagraphList::iterator>
pasteSelection(ParagraphList & pars,
pasteSelection(Buffer const & buffer,
ParagraphList & pars,
ParagraphList::iterator pit, int pos,
lyx::textclass_type tc,
size_t cuts_indexm, ErrorList &);

View File

@ -731,27 +731,10 @@ string const Buffer::asciiParagraph(Paragraph const & par,
bool noparbreak) const
{
ostringstream buffer;
Paragraph::depth_type depth = 0;
int ltype = 0;
Paragraph::depth_type ltype_depth = 0;
bool ref_printed = false;
// if (!par->previous()) {
#if 0
// begins or ends a deeper area ?
if (depth != par->params().depth()) {
if (par->params().depth() > depth) {
while (par->params().depth() > depth) {
++depth;
}
} else {
while (par->params().depth() < depth) {
--depth;
}
}
}
#else
depth = par.params().depth();
#endif
Paragraph::depth_type depth = par.params().depth();
// First write the layout
string const & tmp = par.layout()->name();

View File

@ -48,8 +48,6 @@ using std::find_if;
using std::for_each;
using std::mem_fun;
extern BufferView * current_view;
BufferList::BufferList()
{}
@ -81,9 +79,9 @@ bool BufferList::quitWriteBuffer(Buffer * buf)
bool succeeded;
if (buf->isUnnamed())
succeeded = WriteAs(current_view, buf);
succeeded = WriteAs(buf);
else
succeeded = MenuWrite(current_view, buf);
succeeded = MenuWrite(buf);
if (!succeeded)
return false;
@ -180,7 +178,7 @@ bool BufferList::close(Buffer * buf, bool ask)
if (ret == 0) {
if (buf->isUnnamed()) {
if (!WriteAs(current_view, buf))
if (!WriteAs(buf))
return false;
} else if (buf->save()) {
lastfiles->newFile(buf->fileName());

View File

@ -165,14 +165,14 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
if (tmpret == -1)
++tmpret;
else
papersize2 = tmpret;
papersize2 = VMARGIN_PAPER_TYPE(tmpret);
} else if (token == "\\paperpackage") {
int tmpret = lex.findToken(string_paperpackages);
if (tmpret == -1) {
++tmpret;
paperpackage = BufferParams::PACKAGE_NONE;
} else
paperpackage = tmpret;
paperpackage = PAPER_PACKAGES(tmpret);
} else if (token == "\\use_geometry") {
lex.nextToken();
use_geometry = lex.getInteger();
@ -473,6 +473,9 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
if (!use_geometry &&
(paperpackage == PACKAGE_NONE)) {
switch (papersize) {
case PAPER_A3PAPER:
clsoptions << "a3paper,";
break;
case PAPER_A4PAPER:
clsoptions << "a4paper,";
break;
@ -491,6 +494,8 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
case PAPER_LEGALPAPER:
clsoptions << "legalpaper,";
break;
case PAPER_DEFAULT:
break;
}
}
@ -589,6 +594,8 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
// At the very beginning the text parameters.
if (paperpackage != PACKAGE_NONE) {
switch (paperpackage) {
case PACKAGE_NONE:
break;
case PACKAGE_A4:
os << "\\usepackage{a4}\n";
texrow.newline();

View File

@ -154,13 +154,13 @@ public:
/* this are for the PaperLayout */
/// the general papersize (papersize2 or paperpackage
char papersize; // add apprip. signedness
PAPER_SIZE papersize;
/// the selected Geometry papersize
char papersize2; // add approp. signedness
VMARGIN_PAPER_TYPE papersize2;
/// a special paperpackage .sty-file
char paperpackage; // add approp. signedness
PAPER_PACKAGES paperpackage;
///
PAPER_ORIENTATION orientation; // add approp. signedness
PAPER_ORIENTATION orientation;
///
bool use_geometry;
///

View File

@ -24,6 +24,7 @@
#include "iconpalette.h"
// needless to say, this can't last for long
#warning FIXME Current_view used here!
extern BufferView * current_view;
@ -58,24 +59,28 @@ void QMath::build_dialog()
void QMath::subscript()
{
#warning FIXME Current_view used here!
current_view->owner()->dispatch(FuncRequest(LFUN_SUBSCRIPT));
}
void QMath::superscript()
{
#warning FIXME Current_view used here!
current_view->owner()->dispatch(FuncRequest(LFUN_SUPERSCRIPT));
}
void QMath::insert(string const & name)
{
#warning FIXME Current_view used here!
current_view->owner()->dispatch(FuncRequest(LFUN_INSERT_MATH, '\\' + name));
}
void QMath::insertCubeRoot()
{
#warning FIXME Current_view used here!
current_view->owner()->dispatch(FuncRequest(LFUN_INSERT_MATH, "\\root"));
current_view->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "3"));
current_view->owner()->dispatch(FuncRequest(LFUN_RIGHT));
@ -84,17 +89,20 @@ void QMath::insertCubeRoot()
void QMath::insertMatrix(string const & str)
{
#warning FIXME Current_view used here!
current_view->owner()->dispatch(FuncRequest(LFUN_INSERT_MATRIX, str));
}
void QMath::insertDelim(string const & str)
{
#warning FIXME Current_view used here!
current_view->owner()->dispatch(FuncRequest(LFUN_MATH_DELIM, str));
}
void QMath::toggleDisplay()
{
#warning FIXME Current_view used here!
current_view->owner()->dispatch(FuncRequest(LFUN_MATH_DISPLAY));
}

View File

@ -3,7 +3,7 @@
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bjornes
* \author Lars Gullik Bjønnes
* \author John Levon
*
* Full author contact details are available in file CREDITS
@ -47,7 +47,7 @@ int const statusbar_timer_value = 3000;
} // namespace anon
// FIXME: this has to go away
#warning FIXME Current_view is used here!
BufferView * current_view;
qfont_loader fontloader;
@ -61,6 +61,7 @@ QtView::QtView(unsigned int width, unsigned int height)
qApp->setMainWidget(this);
bufferview_.reset(new BufferView(this, 0, 0, width, height));
#warning FIXME Current_view is used here!
::current_view = bufferview_.get();
menubar_.reset(new Menubar(this, menubackend));

View File

@ -1,3 +1,10 @@
2003-06-10 Lars Gullik Bjønnes <larsbj@lyx.org>
* XFormsView.C: remvoe current_view global variable.
(create_form_form_main): and the usage
* FormDocument.C: adjust for type
2003-06-10 Angus Leeming <leeming@lyx.org>
* FormExternal.C (input, updateComboChange):

View File

@ -702,10 +702,10 @@ bool FormDocument::class_apply(BufferParams &params)
void FormDocument::paper_apply(BufferParams & params)
{
params.papersize2 = char(fl_get_choice(paper_->choice_papersize) - 1);
params.papersize2 = BufferParams::VMARGIN_PAPER_TYPE(fl_get_choice(paper_->choice_papersize) - 1);
params.paperpackage =
char(fl_get_choice(paper_->choice_paperpackage) - 1);
BufferParams::PAPER_PACKAGES(fl_get_choice(paper_->choice_paperpackage) - 1);
// set params.papersize from params.papersize2 and params.paperpackage
params.setPaperStuff();

View File

@ -37,9 +37,6 @@ using std::endl;
//extern void AutoSave(BufferView *);
extern void QuitLyX();
// This is very temporary
BufferView * current_view;
extern "C" {
static
@ -149,7 +146,6 @@ void XFormsView::create_form_form_main(int width, int height)
bufferview_.reset(new BufferView(this, air, ywork,
width - 3 * air, workheight));
::current_view = bufferview_.get();
minibuffer_.reset(new XMiniBuffer(*controlcommand_,
air, height - (25 + air), width - (2 * air), 25));

View File

@ -1,3 +1,7 @@
2003-06-10 Lars Gullik Bjønnes <larsbj@lyx.org>
* insettext.C (appendParagraphs): remove some commented code.
2003-06-10 Angus Leeming <leeming@lyx.org>
* graphicinset.[Ch] (params): removed.
@ -205,7 +209,7 @@
* insetert.C (clone): remove const_cast
* delete commented same_id functions from a lot of files.
* delete commented same_id functions from a lot of files.
2003-05-28 John Levon <levon@movementarian.org>

View File

@ -2593,40 +2593,6 @@ void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
#warning FIXME Check if Changes stuff needs changing here. (Lgb)
// And it probably does. You have to take a look at this John. (Lgb)
#warning John, have a look here. (Lgb)
#if 0
BufferParams const & bparams = buffer->params;
Paragraph * buf;
Paragraph * tmpbuf = newpar;
Paragraph * lastbuffer = buf = new Paragraph(*tmpbuf, false);
if (bparams.tracking_changes)
buf->cleanChanges();
while (tmpbuf->next()) {
tmpbuf = tmpbuf->next();
lastbuffer->next(new Paragraph(*tmpbuf, false));
lastbuffer->next()->previous(lastbuffer);
lastbuffer = lastbuffer->next();
if (bparams.tracking_changes)
lastbuffer->cleanChanges();
}
lastbuffer = &*(paragraphs.begin());
while (lastbuffer->next())
lastbuffer = lastbuffer->next();
if (!newpar->empty() && !lastbuffer->empty() &&
!lastbuffer->isSeparator(lastbuffer->size() - 1))
{
lastbuffer->insertChar(lastbuffer->size(), ' ');
}
// make the buf exactly the same layout than our last paragraph
buf->makeSameLayout(lastbuffer);
// paste it!
lastbuffer->next(buf);
buf->previous(lastbuffer);
mergeParagraph(buffer->params, paragraphs, lastbuffer);
#else
ParagraphList::iterator pit = plist.begin();
ParagraphList::iterator ins = paragraphs.insert(paragraphs.end(), *pit);
++pit;
@ -2637,8 +2603,6 @@ void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
paragraphs.push_back(*pit);
}
#endif
reinitLyXText();
}

View File

@ -75,7 +75,7 @@ void ShowMessage(Buffer const * buf,
// Menu callbacks
//
bool MenuWrite(BufferView * bv, Buffer * buffer)
bool MenuWrite(Buffer * buffer)
{
if (buffer->save()) {
lastfiles->newFile(buffer->fileName());
@ -92,13 +92,13 @@ bool MenuWrite(BufferView * bv, Buffer * buffer)
text, 0, 1, _("&Rename"), _("&Cancel"));
if (ret == 0)
return WriteAs(bv, buffer);
return WriteAs(buffer);
return false;
}
bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename)
bool WriteAs(Buffer * buffer, string const & filename)
{
string fname = buffer->fileName();
string const oldname = fname;
@ -153,7 +153,7 @@ bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename)
bool unnamed = buffer->isUnnamed();
buffer->setUnnamed(false);
if (!MenuWrite(bv, buffer)) {
if (!MenuWrite(buffer)) {
buffer->setFileName(oldname);
buffer->setUnnamed(unnamed);
return false;

View File

@ -16,10 +16,9 @@ void ShowMessage(Buffer const * buf,
string const & msg2 = string(),
string const & msg3 = string());
///
bool MenuWrite(BufferView * bv, Buffer * buffer);
bool MenuWrite(Buffer * buffer);
/// write the given file, or ask if no name given
bool WriteAs(BufferView * bv, Buffer * buffer,
string const & filename = string());
bool WriteAs(Buffer * buffer, string const & filename = string());
///
void QuitLyX();
///

View File

@ -1056,14 +1056,14 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
string const str = bformat(_("Saving document %1$s..."),
MakeDisplayPath(owner->buffer()->fileName()));
owner->message(str);
MenuWrite(view(), owner->buffer());
MenuWrite(owner->buffer());
owner->message(str + _(" done."));
} else
WriteAs(view(), owner->buffer());
WriteAs(owner->buffer());
break;
case LFUN_WRITEAS:
WriteAs(view(), owner->buffer(), argument);
WriteAs(owner->buffer(), argument);
break;
case LFUN_MENURELOAD: {

View File

@ -13,8 +13,12 @@
#include "gettext.h"
#include "support/os.h"
#include <ios>
int main(int argc, char * argv[])
{
std::ios::sync_with_stdio(false);
os::init(&argc, &argv);
// initialize for internationalized version *EK*

View File

@ -102,6 +102,9 @@ public:
string const get(string const & m) const
{
if (m.empty())
return m;
char * old = strdup(setlocale(LC_ALL, 0));
char * n = setlocale(LC_ALL, lang_.c_str());
const char* msg = gettext(m.c_str());

View File

@ -1333,12 +1333,14 @@ void LyXText::cutSelection(bool doclear, bool realcut)
int endpos = selection.end.pos();
boost::tie(endpit, endpos) = realcut ?
CutAndPaste::cutSelection(ownerParagraphs(),
CutAndPaste::cutSelection(bv()->buffer()->params,
ownerParagraphs(),
selection.start.par(), endpit,
selection.start.pos(), endpos,
bv()->buffer()->params.textclass,
doclear)
: CutAndPaste::eraseSelection(ownerParagraphs(),
: CutAndPaste::eraseSelection(bv()->buffer()->params,
ownerParagraphs(),
selection.start.par(), endpit,
selection.start.pos(), endpos,
doclear);
@ -1406,7 +1408,8 @@ void LyXText::pasteSelection()
ErrorList el;
boost::tie(ppp, endpit) =
CutAndPaste::pasteSelection(ownerParagraphs(),
CutAndPaste::pasteSelection(*bv()->buffer(),
ownerParagraphs(),
cursor.par(), cursor.pos(),
bv()->buffer()->params.textclass,
el);