mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
more fixes and updates
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@292 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
dfe1bc44b4
commit
65e9b99a59
24
ChangeLog
24
ChangeLog
@ -1,3 +1,27 @@
|
||||
1999-11-05 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/bufferlist.C: use a vector to store the buffers in. This is
|
||||
an internal change and should not affect any other thing.
|
||||
|
||||
* src/BufferView.C (waitForX): use XSync instead of the lengthy
|
||||
stuff in waitForX.
|
||||
|
||||
* src/text.C (Fill): fix potential bug, one off bug.
|
||||
|
||||
1999-11-04 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/Makefile.am (lyx_main.o): add more files it depends on.
|
||||
|
||||
* src/lyx_cb.C (addNewlineAndDepth): parameters in wrong order.
|
||||
|
||||
* src/support/lyxstring.C: use size_t for the reference count,
|
||||
size, reserved memory and xtra.
|
||||
(internal_compare): new private member function. Now the compare
|
||||
functions should work for std::strings that have embedded '\0'
|
||||
characters.
|
||||
(compare): all compare functions rewritten to use
|
||||
internal_compare.
|
||||
|
||||
1999-11-03 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/support/lyxstring.C (compare): pass c_str()
|
||||
|
@ -9,26 +9,17 @@
|
||||
#
|
||||
# This is all the files that contains internationalization strings.
|
||||
|
||||
src/BufferView.C
|
||||
src/Chktex.C
|
||||
src/FontLoader.C
|
||||
src/LaTeX.C
|
||||
src/LaTeXLog.C
|
||||
src/Literate.C
|
||||
src/LyXAction.C
|
||||
src/LyXSendto.C
|
||||
src/LyXView.C
|
||||
src/PaperLayout.C
|
||||
src/ParagraphExtra.C
|
||||
src/TableLayout.C
|
||||
src/buffer.C
|
||||
src/bufferlist.C
|
||||
src/BufferView.C
|
||||
src/bullet_forms.C
|
||||
src/bullet_forms_cb.C
|
||||
src/Chktex.C
|
||||
src/combox.C
|
||||
src/credits.C
|
||||
src/credits_form.C
|
||||
src/filedlg.C
|
||||
src/FontLoader.C
|
||||
src/form1.C
|
||||
src/gettext.h
|
||||
src/insets/figinset.C
|
||||
@ -49,21 +40,27 @@ src/insets/inseturl.C
|
||||
src/insets/lyxinset.h
|
||||
src/intl.C
|
||||
src/kbmap.C
|
||||
src/LaTeX.C
|
||||
src/LaTeXLog.C
|
||||
src/latexoptions.C
|
||||
src/layout.C
|
||||
src/layout_forms.C
|
||||
src/Literate.C
|
||||
src/LyXAction.C
|
||||
src/lyx.C
|
||||
src/lyx_cb.C
|
||||
src/lyxfont.C
|
||||
src/lyxfr0.C
|
||||
src/lyxfr1.C
|
||||
src/lyxfunc.C
|
||||
src/lyx_gui.C
|
||||
src/lyx_gui_misc.C
|
||||
src/lyx_main.C
|
||||
src/lyx_sendfax.C
|
||||
src/lyx_sendfax_main.C
|
||||
src/lyxfont.C
|
||||
src/lyxfr0.C
|
||||
src/lyxfr1.C
|
||||
src/lyxfunc.C
|
||||
src/LyXSendto.C
|
||||
src/lyxvc.C
|
||||
src/LyXView.C
|
||||
src/mathed/formula.C
|
||||
src/mathed/formula.h
|
||||
src/mathed/formulamacro.C
|
||||
@ -72,12 +69,15 @@ src/mathed/math_panel.C
|
||||
src/menus.C
|
||||
src/minibuffer.C
|
||||
src/minibuffer.h
|
||||
src/PaperLayout.C
|
||||
src/paragraph.C
|
||||
src/ParagraphExtra.C
|
||||
src/print_form.C
|
||||
src/sp_form.C
|
||||
src/spellchecker.C
|
||||
src/sp_form.C
|
||||
src/support/filetools.C
|
||||
src/support/lyxlib.h
|
||||
src/support/path.h
|
||||
src/text.C
|
||||
src/TableLayout.C
|
||||
src/text2.C
|
||||
src/text.C
|
||||
|
@ -520,6 +520,7 @@ void BufferView::UpCB(FL_OBJECT * ob, long)
|
||||
static
|
||||
void waitForX()
|
||||
{
|
||||
#if 0
|
||||
static Window w = 0;
|
||||
static Atom a = 0;
|
||||
if (!a)
|
||||
@ -539,6 +540,8 @@ void waitForX()
|
||||
XChangeProperty(fl_display, w, a, a, 8,
|
||||
PropModeAppend, reinterpret_cast<unsigned char*>(""), 0);
|
||||
XWindowEvent(fl_display, w, PropertyChangeMask, &ev);
|
||||
#endif
|
||||
XSync(fl_get_display(), 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -173,7 +173,10 @@ lyx_SOURCES = \
|
||||
vspace.C \
|
||||
vspace.h
|
||||
|
||||
lyx_main.o: lyx_main.C lyx_main.h config.h version.h debug.h gettext.h
|
||||
lyx_main.o: lyx_main.C lyx_main.h config.h version.h debug.h gettext.h \
|
||||
lyx_gui.h lyx_gui_misc.h lyxrc.h support/path.h support/filetools.h \
|
||||
bufferlist.h debug.h support/FileInfo.h lastfiles.h intl.h \
|
||||
lyxserver.h layout.h gettext.h
|
||||
$(CXXCOMPILE) -DLYX_DIR=\"$(LYX_DIR)\" -DTOP_SRCDIR=\"$(top_srcdir)\" \
|
||||
-DLYX_NAME=\"$(PACKAGE)\" -c $(top_srcdir)/src/lyx_main.C
|
||||
|
||||
|
27
src/buffer.C
27
src/buffer.C
@ -159,7 +159,7 @@ bool Buffer::saveParamsAsDefaults()
|
||||
// Use the current buffer's parameters as default
|
||||
defaults.params.Copy(params);
|
||||
// add an empty paragraph. Is this enough?
|
||||
defaults.paragraph = new LyXParagraph();
|
||||
defaults.paragraph = new LyXParagraph;
|
||||
|
||||
return defaults.writeFile(defaults.filename,false);
|
||||
}
|
||||
@ -258,7 +258,7 @@ bool Buffer::insertLyXFile(string const & filen)
|
||||
// if par = 0 normal behavior
|
||||
// else insert behavior
|
||||
// Returns false if "\the_end" is not read for formats >= 2.13. (Asger)
|
||||
bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par)
|
||||
bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph * par)
|
||||
{
|
||||
string tmptok;
|
||||
Inset * inset = 0;
|
||||
@ -277,7 +277,10 @@ bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par)
|
||||
string pretoken;
|
||||
|
||||
if(!par) {
|
||||
par = new LyXParagraph();
|
||||
par = new LyXParagraph;
|
||||
#ifdef NEW_TEXT
|
||||
par->text.reserve(500);
|
||||
#endif
|
||||
} else {
|
||||
text->BreakParagraph();
|
||||
return_par = text->FirstParagraph();
|
||||
@ -326,8 +329,15 @@ bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par)
|
||||
} else if (token == "\\layout") {
|
||||
if (!return_par)
|
||||
return_par = par;
|
||||
else
|
||||
else {
|
||||
#ifdef NEW_TEXT
|
||||
par->text.resize(par->text.size());
|
||||
#endif
|
||||
par = new LyXParagraph(par);
|
||||
#ifdef NEW_TEXT
|
||||
par->text.reserve(500);
|
||||
#endif
|
||||
}
|
||||
pos = 0;
|
||||
lex.EatLine();
|
||||
string layoutname = lex.GetString();
|
||||
@ -354,8 +364,15 @@ bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par)
|
||||
} else if (token == "\\end_float") {
|
||||
if (!return_par)
|
||||
return_par = par;
|
||||
else
|
||||
else {
|
||||
#ifdef NEW_TEXT
|
||||
par->text.resize(par->text.size());
|
||||
#endif
|
||||
par = new LyXParagraph(par);
|
||||
#ifdef NEW_TEXT
|
||||
par->text.reserve(500);
|
||||
#endif
|
||||
}
|
||||
footnotekind = LyXParagraph::FOOTNOTE;
|
||||
footnoteflag = LyXParagraph::NO_FOOTNOTE;
|
||||
pos = 0;
|
||||
|
322
src/bufferlist.C
322
src/bufferlist.C
@ -33,8 +33,8 @@
|
||||
#include "lyx_cb.h"
|
||||
#include "gettext.h"
|
||||
|
||||
extern BufferView *current_view;
|
||||
extern MiniBuffer *minibuffer;
|
||||
extern BufferView * current_view;
|
||||
extern MiniBuffer * minibuffer;
|
||||
extern void SmallUpdate(signed char);
|
||||
extern void BeforeChange();
|
||||
extern int RunLinuxDoc(int, string const &);
|
||||
@ -43,15 +43,17 @@ extern int RunLinuxDoc(int, string const &);
|
||||
// Class BufferStorage
|
||||
//
|
||||
|
||||
#ifndef NEW_STORE
|
||||
BufferStorage::BufferStorage()
|
||||
{
|
||||
// Initialize the buffer array
|
||||
for (int i=NUMBER_OF_BUFFERS-1; i >=0; i--) {
|
||||
buffer[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NEW_STORE
|
||||
bool BufferStorage::isEmpty()
|
||||
{
|
||||
for (int i=NUMBER_OF_BUFFERS-1; i >=0; i--) {
|
||||
@ -59,23 +61,43 @@ bool BufferStorage::isEmpty()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void BufferStorage::release(Buffer* buf)
|
||||
void BufferStorage::release(Buffer * buf)
|
||||
{
|
||||
int i=0;
|
||||
for (i=0; i<NUMBER_OF_BUFFERS; i++)
|
||||
#ifdef NEW_STORE
|
||||
for(Container::iterator it = container.begin();
|
||||
it != container.end(); ++it) {
|
||||
if ((*it) == buf) {
|
||||
Buffer * tmpbuf = (*it);
|
||||
container.erase(it);
|
||||
delete tmpbuf;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
int i = 0;
|
||||
for (i = 0; i < NUMBER_OF_BUFFERS; i++)
|
||||
if (buffer[i] == buf) break;
|
||||
Buffer *tmpbuf = buffer[i];
|
||||
Buffer * tmpbuf = buffer[i];
|
||||
buffer[i] = 0;
|
||||
delete tmpbuf;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Buffer* BufferStorage::newBuffer(string const &s,
|
||||
LyXRC *lyxrc,
|
||||
Buffer * BufferStorage::newBuffer(string const & s,
|
||||
LyXRC * lyxrc,
|
||||
bool ronly)
|
||||
{
|
||||
#ifdef NEW_STORE
|
||||
Buffer * tmpbuf = new Buffer(s, lyxrc, ronly);
|
||||
tmpbuf->params.useClassDefaults();
|
||||
lyxerr.debug() << "Assigning to buffer "
|
||||
<< container.size() + 1 << endl;
|
||||
container.push_back(tmpbuf);
|
||||
return tmpbuf;
|
||||
#else
|
||||
int i=0;
|
||||
while (i < NUMBER_OF_BUFFERS - 1
|
||||
&& buffer[i]) i++;
|
||||
@ -83,19 +105,21 @@ Buffer* BufferStorage::newBuffer(string const &s,
|
||||
buffer[i]->params.useClassDefaults();
|
||||
lyxerr.debug() << "Assigning to buffer " << i << endl;
|
||||
return buffer[i];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_STORE
|
||||
//
|
||||
// Class BufferStrorage_Iter
|
||||
//
|
||||
|
||||
Buffer* BufferStorage_Iter::operator() ()
|
||||
Buffer * BufferStorage_Iter::operator() ()
|
||||
{
|
||||
int i=0;
|
||||
for (i=index; i < BufferStorage::NUMBER_OF_BUFFERS; i++) {
|
||||
int i = 0;
|
||||
for (i = index; i < BufferStorage::NUMBER_OF_BUFFERS; i++) {
|
||||
if (cs->buffer[i]) {
|
||||
index = i+1;
|
||||
index = i + 1;
|
||||
return cs->buffer[i];
|
||||
}
|
||||
}
|
||||
@ -103,19 +127,20 @@ Buffer* BufferStorage_Iter::operator() ()
|
||||
}
|
||||
|
||||
|
||||
Buffer* BufferStorage_Iter::operator[] (int a)
|
||||
Buffer * BufferStorage_Iter::operator[] (int a)
|
||||
{
|
||||
// a is >=1
|
||||
if (a<=0) return 0;
|
||||
if (a <= 0) return 0;
|
||||
|
||||
int i=0;
|
||||
int i = 0;
|
||||
while (a--) {
|
||||
while(!cs->buffer[i++]);
|
||||
}
|
||||
if (i-1 < BufferStorage::NUMBER_OF_BUFFERS)
|
||||
return cs->buffer[i-1];
|
||||
if (i - 1 < BufferStorage::NUMBER_OF_BUFFERS)
|
||||
return cs->buffer[i - 1];
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
@ -127,26 +152,43 @@ BufferList::BufferList()
|
||||
}
|
||||
|
||||
|
||||
BufferList::~BufferList()
|
||||
bool BufferList::empty()
|
||||
{
|
||||
// I am sure something should be done here too.
|
||||
return bstore.empty();
|
||||
}
|
||||
|
||||
|
||||
bool BufferList::isEmpty()
|
||||
{
|
||||
return bstore.isEmpty();
|
||||
}
|
||||
|
||||
extern void MenuWrite(Buffer*);
|
||||
extern void MenuWrite(Buffer *);
|
||||
|
||||
bool BufferList::QwriteAll()
|
||||
{
|
||||
bool askMoreConfirmation = false;
|
||||
string unsaved;
|
||||
#ifdef NEW_STORE
|
||||
for(BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
if (!(*it)->isLyxClean()) {
|
||||
switch(AskConfirmation(_("Changes in document:"),
|
||||
MakeDisplayPath((*it)->filename,
|
||||
50),
|
||||
_("Save document?"))) {
|
||||
case 1: // Yes
|
||||
MenuWrite((*it));
|
||||
break;
|
||||
case 2: // No
|
||||
askMoreConfirmation = true;
|
||||
unsaved += MakeDisplayPath((*it)->filename,50);
|
||||
unsaved += "\n";
|
||||
break;
|
||||
case 3: // Cancel
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer *b=0;
|
||||
while ((b=biter())) {
|
||||
Buffer * b = 0;
|
||||
while ((b = biter())) {
|
||||
if (!b->isLyxClean()) {
|
||||
switch(AskConfirmation(_("Changes in document:"),
|
||||
MakeDisplayPath(b->filename,50),
|
||||
@ -164,6 +206,7 @@ bool BufferList::QwriteAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (askMoreConfirmation &&
|
||||
lyxrc->exit_confirmation &&
|
||||
!AskQuestion(_("Some documents were not saved:"),
|
||||
@ -176,7 +219,7 @@ bool BufferList::QwriteAll()
|
||||
|
||||
|
||||
// Should probably be moved to somewhere else: BufferView? LyXView?
|
||||
bool BufferList::write(Buffer *buf, bool makeBackup)
|
||||
bool BufferList::write(Buffer * buf, bool makeBackup)
|
||||
{
|
||||
minibuffer->Set(_("Saving document"),
|
||||
MakeDisplayPath(buf->filename),"...");
|
||||
@ -283,27 +326,39 @@ bool BufferList::write(Buffer *buf, bool makeBackup)
|
||||
void BufferList::closeAll()
|
||||
{
|
||||
_state = BufferList::CLOSING;
|
||||
|
||||
#ifdef NEW_STORE
|
||||
while (!bstore.empty()) {
|
||||
close(bstore.front());
|
||||
}
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer *b=0;
|
||||
while ((b=biter())) {
|
||||
Buffer * b = 0;
|
||||
while ((b = biter())) {
|
||||
close(b);
|
||||
}
|
||||
#endif
|
||||
_state = BufferList::OK;
|
||||
}
|
||||
|
||||
|
||||
void BufferList::resize()
|
||||
{
|
||||
#ifdef NEW_STORE
|
||||
for(BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
(*it)->resize();
|
||||
}
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer *b=0;
|
||||
while ((b=biter())) {
|
||||
Buffer * b = 0;
|
||||
while ((b = biter())) {
|
||||
b->resize();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool BufferList::close(Buffer *buf)
|
||||
bool BufferList::close(Buffer * buf)
|
||||
{
|
||||
buf->InsetUnlock();
|
||||
|
||||
@ -337,38 +392,67 @@ void BufferList::makePup(int pup)
|
||||
in the same way as for lastfiles.[hC]
|
||||
*/
|
||||
{
|
||||
int ant=0;
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer *b=0;
|
||||
while ((b=biter())) {
|
||||
string relbuf = MakeDisplayPath(b->filename,30);
|
||||
int ant = 0;
|
||||
#ifdef NEW_STORE
|
||||
for(BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
string relbuf = MakeDisplayPath((*it)->filename, 30);
|
||||
fl_addtopup(pup, relbuf.c_str());
|
||||
ant++;
|
||||
++ant;
|
||||
}
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer * b = 0;
|
||||
while ((b = biter())) {
|
||||
string relbuf = MakeDisplayPath(b->filename, 30);
|
||||
fl_addtopup(pup, relbuf.c_str());
|
||||
++ant;
|
||||
}
|
||||
#endif
|
||||
if (ant == 0) fl_addtopup(pup,_("No Documents Open!%t"));
|
||||
}
|
||||
|
||||
|
||||
Buffer* BufferList::first()
|
||||
Buffer * BufferList::first()
|
||||
{
|
||||
#ifdef NEW_STORE
|
||||
if (bstore.empty()) return 0;
|
||||
return bstore.front();
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
return biter();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Buffer* BufferList::getBuffer(int choice)
|
||||
Buffer * BufferList::getBuffer(int choice)
|
||||
{
|
||||
#ifdef NEW_STORE
|
||||
if (choice >= bstore.size()) return 0;
|
||||
return bstore[choice];
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer *b=0;
|
||||
Buffer * b = 0;
|
||||
b = biter[choice];
|
||||
|
||||
// Be careful, this could be 0.
|
||||
return b;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void BufferList::updateInset(Inset *inset, bool mark_dirty)
|
||||
void BufferList::updateInset(Inset * inset, bool mark_dirty)
|
||||
{
|
||||
#ifdef NEW_STORE
|
||||
for (BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
if ((*it)->text && (*it)->text->UpdateInset(inset)) {
|
||||
if (mark_dirty)
|
||||
(*it)->markDirty();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer *b=0;
|
||||
while ((b=biter())) {
|
||||
@ -378,11 +462,23 @@ void BufferList::updateInset(Inset *inset, bool mark_dirty)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int BufferList::unlockInset(UpdatableInset *inset)
|
||||
int BufferList::unlockInset(UpdatableInset * inset)
|
||||
{
|
||||
#ifdef NEW_STORE
|
||||
if (!inset) return 1;
|
||||
for(BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
if ((*it)->the_locking_inset == inset) {
|
||||
(*it)->InsetUnlock();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
#else
|
||||
if (!inset) return 1;
|
||||
|
||||
BufferStorage_Iter biter(bstore);
|
||||
@ -394,11 +490,27 @@ int BufferList::unlockInset(UpdatableInset *inset)
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
|
||||
{
|
||||
#ifdef NEW_STORE
|
||||
for(BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
if (!(*it)->isDepClean(mastertmpdir)) {
|
||||
string writefile = mastertmpdir;
|
||||
writefile += '/';
|
||||
writefile += ChangeExtension((*it)->getFileName(),
|
||||
".tex", true);
|
||||
(*it)->makeLaTeXFile(writefile, mastertmpdir,
|
||||
false, true);
|
||||
(*it)->markDepClean(mastertmpdir);
|
||||
|
||||
}
|
||||
}
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer *b=0;
|
||||
while ((b=biter())) {
|
||||
@ -410,17 +522,64 @@ void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
|
||||
b->markDepClean(mastertmpdir);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void BufferList::emergencyWriteAll()
|
||||
{
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer *b=0;
|
||||
while ((b=biter())) {
|
||||
if (!b->isLyxClean()) {
|
||||
#ifdef NEW_STORE
|
||||
for (BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
if (!(*it)->isLyxClean()) {
|
||||
bool madeit=false;
|
||||
|
||||
lyxerr <<_("lyx: Attempting to save"
|
||||
" document ")
|
||||
<< (*it)->filename
|
||||
<< _(" as...") << endl;
|
||||
|
||||
for (int i = 0; i < 3 && !madeit; ++i) {
|
||||
string s;
|
||||
|
||||
// We try to save three places:
|
||||
// 1) Same place as document.
|
||||
// 2) In HOME directory.
|
||||
// 3) In "/tmp" directory.
|
||||
if (i == 0) {
|
||||
s = (*it)->filename;
|
||||
} else if (i == 1) {
|
||||
s = AddName(GetEnvPath("HOME"),
|
||||
(*it)->filename);
|
||||
} else { // MakeAbsPath to prepend the current drive letter on OS/2
|
||||
s = AddName(MakeAbsPath("/tmp/"),
|
||||
(*it)->filename);
|
||||
}
|
||||
s += ".emergency";
|
||||
|
||||
lyxerr << " " << i + 1 << ") " << s << endl;
|
||||
|
||||
if ((*it)->writeFile(s,true)) {
|
||||
(*it)->markLyxClean();
|
||||
lyxerr << _(" Save seems successful. "
|
||||
"Phew.") << endl;
|
||||
madeit = true;
|
||||
} else if (i != 2) {
|
||||
lyxerr << _(" Save failed! Trying...")
|
||||
<< endl;
|
||||
} else {
|
||||
lyxerr << _(" Save failed! Bummer. Document is lost.") << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer * b = 0;
|
||||
while ((b = biter())) {
|
||||
if (!b->isLyxClean()) {
|
||||
bool madeit = false;
|
||||
|
||||
lyxerr <<_("lyx: Attempting to save"
|
||||
" document ")
|
||||
<< b->filename
|
||||
@ -433,9 +592,9 @@ void BufferList::emergencyWriteAll()
|
||||
// 1) Same place as document.
|
||||
// 2) In HOME directory.
|
||||
// 3) In "/tmp" directory.
|
||||
if (i==0) {
|
||||
if (i == 0) {
|
||||
s = b->filename;
|
||||
} else if (i==1) {
|
||||
} else if (i == 1) {
|
||||
s = AddName(GetEnvPath("HOME"),
|
||||
b->filename);
|
||||
} else { // MakeAbsPath to prepend the current drive letter on OS/2
|
||||
@ -444,7 +603,7 @@ void BufferList::emergencyWriteAll()
|
||||
}
|
||||
s += ".emergency";
|
||||
|
||||
lyxerr << " " << i+1 << ") " << s << endl;
|
||||
lyxerr << " " << i + 1 << ") " << s << endl;
|
||||
|
||||
if (b->writeFile(s,true)) {
|
||||
b->markLyxClean();
|
||||
@ -459,12 +618,13 @@ void BufferList::emergencyWriteAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Buffer* BufferList::readFile(string const & s, bool ronly)
|
||||
{
|
||||
Buffer *b = bstore.newBuffer(s, lyxrc, ronly);
|
||||
Buffer * b = bstore.newBuffer(s, lyxrc, ronly);
|
||||
|
||||
string ts = s;
|
||||
string e = OnlyPath(s);
|
||||
@ -533,32 +693,50 @@ Buffer* BufferList::readFile(string const & s, bool ronly)
|
||||
|
||||
bool BufferList::exists(string const & s)
|
||||
{
|
||||
#ifdef NEW_STORE
|
||||
for (BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
if ((*it)->filename == s)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer *b=0;
|
||||
while ((b=biter())) {
|
||||
Buffer * b = 0;
|
||||
while ((b = biter())) {
|
||||
if (b->filename == s)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Buffer* BufferList::getBuffer(string const &s)
|
||||
Buffer * BufferList::getBuffer(string const & s)
|
||||
{
|
||||
#ifdef NEW_STORE
|
||||
for(BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
if ((*it)->filename == s)
|
||||
return (*it);
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
BufferStorage_Iter biter(bstore);
|
||||
Buffer *b=0;
|
||||
while ((b=biter())) {
|
||||
if (b->filename ==s)
|
||||
Buffer * b = 0;
|
||||
while ((b = biter())) {
|
||||
if (b->filename == s)
|
||||
return b;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Buffer* BufferList::newFile(string const & name, string tname)
|
||||
Buffer * BufferList::newFile(string const & name, string tname)
|
||||
{
|
||||
/* get a free buffer */
|
||||
Buffer *b = bstore.newBuffer(name, lyxrc);
|
||||
Buffer * b = bstore.newBuffer(name, lyxrc);
|
||||
|
||||
// use defaults.lyx as a default template if it exists.
|
||||
if (tname.empty()) {
|
||||
@ -577,11 +755,17 @@ Buffer* BufferList::newFile(string const & name, string tname)
|
||||
WriteAlert(_("Error!"),_("Unable to open template"),
|
||||
MakeDisplayPath(tname));
|
||||
// no template, start with empty buffer
|
||||
b->paragraph = new LyXParagraph();
|
||||
b->paragraph = new LyXParagraph;
|
||||
#ifdef NEW_TEXT
|
||||
b->paragraph->text.reserve(500);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else { // start with empty buffer
|
||||
b->paragraph = new LyXParagraph();
|
||||
b->paragraph = new LyXParagraph;
|
||||
#ifdef NEW_TEXT
|
||||
b->paragraph->text.reserve(500);
|
||||
#endif
|
||||
}
|
||||
|
||||
b->markDirty();
|
||||
@ -591,7 +775,7 @@ Buffer* BufferList::newFile(string const & name, string tname)
|
||||
}
|
||||
|
||||
|
||||
Buffer* BufferList::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
{
|
||||
// make sure our path is absolute
|
||||
string s = MakeAbsPath(filename);
|
||||
@ -632,7 +816,7 @@ Buffer* BufferList::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
return getBuffer(s);
|
||||
}
|
||||
}
|
||||
Buffer *b=0;
|
||||
Buffer * b = 0;
|
||||
bool ro = false;
|
||||
switch (IsFileWriteable(s)) {
|
||||
case 0:
|
||||
@ -641,7 +825,7 @@ Buffer* BufferList::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
ro = true;
|
||||
// Fall through
|
||||
case 1:
|
||||
b=readFile(s, ro);
|
||||
b = readFile(s, ro);
|
||||
if (b) {
|
||||
b->lyxvc.file_found_hook(s);
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "buffer.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define NEW_STORE 1
|
||||
|
||||
/** A class to hold all the buffers in a structure
|
||||
The point of this class is to hide from bufferlist what kind
|
||||
of structure the buffers are stored in. Should be no concern for
|
||||
@ -30,15 +32,41 @@
|
||||
gave me an "internal gcc error".
|
||||
*/
|
||||
class BufferStorage {
|
||||
#ifdef NEW_STORE
|
||||
public:
|
||||
///
|
||||
typedef vector<Buffer *> Container;
|
||||
///
|
||||
typedef Container::iterator iterator;
|
||||
///
|
||||
bool empty() const { return container.empty(); }
|
||||
///
|
||||
void release(Buffer * buf);
|
||||
///
|
||||
Buffer * newBuffer(string const & s, LyXRC *, bool = false);
|
||||
///
|
||||
Container::iterator begin() { return container.begin(); }
|
||||
///
|
||||
Container::iterator end() { return container.end(); }
|
||||
///
|
||||
Buffer * front() { return container.front(); }
|
||||
///
|
||||
Buffer * operator[](int c) { return container[c]; }
|
||||
///
|
||||
int size() const { return container.size(); }
|
||||
private:
|
||||
///
|
||||
Container container;
|
||||
#else
|
||||
public:
|
||||
///
|
||||
BufferStorage();
|
||||
///
|
||||
bool isEmpty();
|
||||
bool empty();
|
||||
///
|
||||
void release(Buffer* buf);
|
||||
void release(Buffer * buf);
|
||||
///
|
||||
Buffer* newBuffer(string const &s, LyXRC *, bool =false);
|
||||
Buffer* newBuffer(string const & s, LyXRC *, bool =false);
|
||||
private:
|
||||
enum {
|
||||
/** The max number of buffers there are possible to have
|
||||
@ -54,8 +82,11 @@ private:
|
||||
Buffer *buffer[NUMBER_OF_BUFFERS];
|
||||
///
|
||||
friend class BufferStorage_Iter;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifndef NEW_STORE
|
||||
/// An Iterator class for BufferStorage
|
||||
class BufferStorage_Iter {
|
||||
public:
|
||||
@ -72,7 +103,7 @@ private:
|
||||
///
|
||||
unsigned char index;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/** The class governing all the open buffers
|
||||
@ -85,9 +116,6 @@ public:
|
||||
///
|
||||
BufferList();
|
||||
|
||||
///
|
||||
~BufferList();
|
||||
|
||||
/// state info
|
||||
enum list_state {
|
||||
///
|
||||
@ -104,11 +132,11 @@ public:
|
||||
true), the file name will not be added to the last opened
|
||||
files list
|
||||
*/
|
||||
Buffer* loadLyXFile(string const & filename,
|
||||
bool tolastfiles = true);
|
||||
Buffer * loadLyXFile(string const & filename,
|
||||
bool tolastfiles = true);
|
||||
|
||||
///
|
||||
bool isEmpty();
|
||||
bool empty();
|
||||
|
||||
/// Saves buffer. Returns false if unsuccesful.
|
||||
bool write(Buffer *, bool makeBackup = true);
|
||||
@ -123,24 +151,20 @@ public:
|
||||
void resize();
|
||||
|
||||
/// Read a file into a buffer readonly or not.
|
||||
Buffer* readFile(string const &, bool ro);
|
||||
Buffer * readFile(string const &, bool ro);
|
||||
|
||||
/// Make a new file (buffer) using a template
|
||||
Buffer* newFile(string const &, string);
|
||||
Buffer * newFile(string const &, string);
|
||||
|
||||
/** This one must be moved to some other place.
|
||||
*/
|
||||
void makePup(int);
|
||||
|
||||
///** Later with multiple frames this should not be here.
|
||||
// */
|
||||
//Buffer* switchBuffer(Buffer *from, int);
|
||||
///
|
||||
void updateInset(Inset *, bool = true);
|
||||
|
||||
///
|
||||
void updateInset(Inset*, bool = true);
|
||||
|
||||
///
|
||||
int unlockInset(UpdatableInset*);
|
||||
int unlockInset(UpdatableInset *);
|
||||
|
||||
///
|
||||
void updateIncludedTeXfiles(string const &);
|
||||
@ -154,15 +178,15 @@ public:
|
||||
bool close(Buffer *);
|
||||
|
||||
///
|
||||
Buffer* first();
|
||||
Buffer * first();
|
||||
|
||||
/// returns true if the buffer exists already
|
||||
bool exists(string const &);
|
||||
|
||||
/// returns a pointer to the buffer with the given name.
|
||||
Buffer* getBuffer(string const &);
|
||||
Buffer * getBuffer(string const &);
|
||||
/// returns a pointer to the buffer with the given number.
|
||||
Buffer* getBuffer(int);
|
||||
Buffer * getBuffer(int);
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -1108,7 +1108,10 @@ void InsertAsciiFile(string const & f, bool asParagraph)
|
||||
return;
|
||||
}
|
||||
|
||||
tmppar = new LyXParagraph();
|
||||
tmppar = new LyXParagraph;
|
||||
#ifdef NEW_TEXT
|
||||
tmppar->text.reserve(500);
|
||||
#endif
|
||||
tmppar->readSimpleWholeFile(myfile);
|
||||
|
||||
// set the end of the string
|
||||
@ -4067,10 +4070,10 @@ void UpdateInsetUpdateList()
|
||||
// way to do this (and the cleanest for now). This function just inserts
|
||||
// a newline in the string and the inserts 'depth'-spaces so that the
|
||||
// code is indented in the right way!!!
|
||||
void addNewlineAndDepth(string &file, int const depth)
|
||||
void addNewlineAndDepth(string & file, int const depth)
|
||||
{
|
||||
file += '\n';
|
||||
file.append(' ', depth);
|
||||
file.append(depth, ' ');
|
||||
}
|
||||
|
||||
|
||||
|
@ -148,7 +148,7 @@ extern "C" int LyX_XErrHandler(Display *display, XErrorEvent *xeev)
|
||||
{
|
||||
//#warning Please see if you can trigger this!
|
||||
// emergency save
|
||||
if (!bufferlist.isEmpty())
|
||||
if (!bufferlist.empty())
|
||||
bufferlist.emergencyWriteAll();
|
||||
|
||||
// Get the reason for the crash.
|
||||
|
@ -2826,7 +2826,7 @@ void LyXFunc::reloadBuffer()
|
||||
void LyXFunc::CloseBuffer()
|
||||
{
|
||||
if (bufferlist.close(owner->currentBuffer()) && !quitting) {
|
||||
if (bufferlist.isEmpty()) {
|
||||
if (bufferlist.empty()) {
|
||||
// need this otherwise SEGV may occur while trying to
|
||||
// set variables that don't exist
|
||||
// since there's no current buffer
|
||||
|
@ -17,15 +17,17 @@
|
||||
#endif
|
||||
|
||||
#define NEW_TEXT 1
|
||||
#define NEW_TABLE 1
|
||||
//#define NEW_TABLE 1
|
||||
|
||||
#ifdef NEW_TABLE
|
||||
#include <list>
|
||||
#endif
|
||||
|
||||
#ifdef NEW_TEXT
|
||||
//#include <vector>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
//#include <deque>
|
||||
//#define __STD_STUFF 1
|
||||
//#include <rope.h>
|
||||
#endif
|
||||
|
||||
#include "definitions.h"
|
||||
@ -142,7 +144,11 @@ public:
|
||||
|
||||
#ifdef NEW_TEXT
|
||||
///
|
||||
typedef deque<char> TextContainer;
|
||||
typedef char value_type;
|
||||
///
|
||||
typedef vector<value_type> TextContainer;
|
||||
//typedef deque<char> TextContainer;
|
||||
//typedef rope<char> TextContainer;
|
||||
typedef int size_type;
|
||||
///
|
||||
TextContainer text;
|
||||
|
@ -1573,7 +1573,11 @@ void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
|
||||
// set the pseudo menu-button back
|
||||
fl_set_object_boxtype(ob, FL_FLAT_BOX);
|
||||
fl_redraw_object(ob);
|
||||
#ifdef NEW_STORE
|
||||
if (choice > 0) men->handleBufferMenu(choice - 1);
|
||||
#else
|
||||
if (choice > 0) men->handleBufferMenu(choice);
|
||||
#endif
|
||||
|
||||
fl_freepup(BufferMenu);
|
||||
}
|
||||
|
@ -697,6 +697,7 @@ void LyXParagraph::Erase(int pos)
|
||||
#endif
|
||||
#ifdef NEW_TEXT
|
||||
text.erase(text.begin() + pos);
|
||||
//text.erase(pos, 1);
|
||||
#else
|
||||
// Shift rest of text
|
||||
for (int i = pos; i < last - 1; i++) {
|
||||
@ -847,6 +848,7 @@ void LyXParagraph::InsertChar(int pos, char c)
|
||||
return;
|
||||
}
|
||||
text.insert(text.begin() + pos, c);
|
||||
//text.insert(pos, c);
|
||||
#else
|
||||
/* > because last is the next unused position, and you can
|
||||
* use it if you want */
|
||||
@ -1872,6 +1874,7 @@ void LyXParagraph::BreakParagraph(int pos, int flag)
|
||||
|
||||
#ifdef NEW_TEXT
|
||||
pos_end = pos_first + par->text.size() - 1;
|
||||
tmp->text.reserve(pos_end - pos);
|
||||
#else
|
||||
pos_end = pos_first + par->last - 1;
|
||||
/* make sure there is enough memory for the now larger
|
||||
@ -1888,7 +1891,9 @@ void LyXParagraph::BreakParagraph(int pos, int flag)
|
||||
|
||||
for (i = pos_end; i >= pos; i--)
|
||||
par->Erase(i - pos_first);
|
||||
#ifndef NEW_TEXT
|
||||
#ifdef NEW_TEXT
|
||||
par->text.resize(par->text.size());
|
||||
#else
|
||||
/* free memory of the now shorter paragraph*/
|
||||
par->FitSize();
|
||||
#endif
|
||||
@ -1961,7 +1966,7 @@ LyXParagraph * LyXParagraph::FirstSelfrowPar()
|
||||
LyXParagraph * LyXParagraph::Clone()
|
||||
{
|
||||
/* create a new paragraph */
|
||||
LyXParagraph * result = new LyXParagraph();
|
||||
LyXParagraph * result = new LyXParagraph;
|
||||
|
||||
result->MakeSameLayout(this);
|
||||
|
||||
@ -1983,6 +1988,7 @@ LyXParagraph * LyXParagraph::Clone()
|
||||
/* copy everything behind the break-position to the new paragraph */
|
||||
|
||||
#ifdef NEW_TEXT
|
||||
result->text.reserve(size());
|
||||
for (size_type i = 0; i < size(); i++) {
|
||||
CopyIntoMinibuffer(i);
|
||||
result->InsertFromMinibuffer(i);
|
||||
@ -2070,7 +2076,9 @@ void LyXParagraph::BreakParagraphConservative(int pos)
|
||||
InsertFromMinibuffer will enlarge the memory (it uses
|
||||
InsertChar of course). But doing it by hand
|
||||
is MUCH faster! (only one time, not thousend times!!) */
|
||||
#ifndef NEW_TEXT
|
||||
#ifdef NEW_TEXT
|
||||
tmp->text.reserve(pos_end - pos);
|
||||
#else
|
||||
tmp->Enlarge(0, pos_end - pos);
|
||||
#endif
|
||||
for (i = pos; i <= pos_end; i++) {
|
||||
@ -2080,7 +2088,9 @@ void LyXParagraph::BreakParagraphConservative(int pos)
|
||||
}
|
||||
for (i = pos_end; i >= pos; i--)
|
||||
par->Erase(i - pos_first);
|
||||
#ifndef NEW_TEXT
|
||||
#ifdef NEW_TEXT
|
||||
par->text.resize(par->text.size());
|
||||
#else
|
||||
/* free memory of the now shorter paragraph*/
|
||||
par->FitSize();
|
||||
#endif
|
||||
|
@ -49,14 +49,13 @@ using std::min;
|
||||
|
||||
struct lyxstring::Srep {
|
||||
///
|
||||
static lyxstring::size_type const xtra =
|
||||
static_cast<lyxstring::size_type>(8);
|
||||
static size_t const xtra = static_cast<size_t>(8);
|
||||
/// size
|
||||
lyxstring::size_type sz;
|
||||
size_t sz;
|
||||
/// Reference count
|
||||
unsigned short ref;
|
||||
size_t ref;
|
||||
/// The total amount of data reserved for this representaion
|
||||
lyxstring::size_type res;
|
||||
size_t res;
|
||||
/// Data. At least 1 char for trailing null.
|
||||
lyxstring::value_type * s;
|
||||
|
||||
@ -344,16 +343,13 @@ void lyxstringInvariant::helper() const
|
||||
// test every last little thing we *know* should be true.
|
||||
// I may have missed a test or two, so feel free to fill
|
||||
// in the gaps. ARRae.
|
||||
// NOTE: Don't put TestlyxstringInvariant() in any of the
|
||||
// lyxstring methods used below otherwise you'll get an
|
||||
// infinite recursion and a crash.
|
||||
Assert(object);
|
||||
Assert(object->rep);
|
||||
Assert(object->rep->s); // s is never 0
|
||||
Assert(object->rep->res); // always some space allocated
|
||||
Assert(object->size() <= object->rep->res);
|
||||
Assert(object->rep->sz <= object->rep->res);
|
||||
Assert(object->rep->ref >= 1); // its in use so it must be referenced
|
||||
Assert(object->rep->ref < (1 << 8*sizeof(object->rep->ref)) - 1);
|
||||
Assert(object->rep->ref < static_cast<size_t>(1 << (8 * sizeof(object->rep->ref) - 1)));
|
||||
// if it does ever == then we should be generating a new copy
|
||||
// and starting again. (Is char always 8-bits?)
|
||||
}
|
||||
@ -367,7 +363,8 @@ void lyxstringInvariant::helper() const
|
||||
// Constructors and Deconstructors.
|
||||
///////////////////////////////////////
|
||||
|
||||
lyxstring::size_type const lyxstring::npos = static_cast<lyxstring::size_type>(-1);
|
||||
lyxstring::size_type const lyxstring::npos =
|
||||
static_cast<lyxstring::size_type>(-1);
|
||||
|
||||
lyxstring::lyxstring()
|
||||
{
|
||||
@ -983,7 +980,8 @@ lyxstring::size_type lyxstring::rfind(value_type const * ptr, size_type i,
|
||||
}
|
||||
|
||||
|
||||
lyxstring::size_type lyxstring::rfind(value_type const * ptr, size_type i) const
|
||||
lyxstring::size_type lyxstring::rfind(value_type const * ptr,
|
||||
size_type i) const
|
||||
{
|
||||
Assert(ptr);
|
||||
TestlyxstringInvariant(this);
|
||||
@ -1123,7 +1121,7 @@ lyxstring::size_type lyxstring::find_last_of(value_type c, size_type i) const
|
||||
|
||||
|
||||
lyxstring::size_type lyxstring::find_first_not_of(lyxstring const & a,
|
||||
size_type i) const
|
||||
size_type i) const
|
||||
{
|
||||
TestlyxstringInvariant(this);
|
||||
|
||||
@ -1412,49 +1410,11 @@ lyxstring::size_type lyxstring::copy(value_type * buf, size_type len,
|
||||
////////////////////
|
||||
|
||||
// Compare funcs should be verified.
|
||||
// Should we try to make them work with '\0' value_types?
|
||||
// An STL string can usually contain '\0' value_types.
|
||||
|
||||
int lyxstring::compare(lyxstring const & str) const
|
||||
int lyxstring::internal_compare(size_type pos, size_type n,
|
||||
value_type const * s,
|
||||
size_type slen, size_type n2) const
|
||||
{
|
||||
TestlyxstringInvariant(this);
|
||||
|
||||
return compare(0, rep->sz, str.c_str(), str.rep->sz);
|
||||
}
|
||||
|
||||
|
||||
int lyxstring::compare(value_type const * s) const
|
||||
{
|
||||
Assert(s);
|
||||
TestlyxstringInvariant(this);
|
||||
|
||||
return compare(0, rep->sz, s, (!s) ? 0 : strlen(s));
|
||||
}
|
||||
|
||||
|
||||
int lyxstring::compare(size_type pos, size_type n, lyxstring const & str) const
|
||||
{
|
||||
TestlyxstringInvariant(this);
|
||||
|
||||
return compare(pos, n, str.c_str(), str.rep->sz);
|
||||
}
|
||||
|
||||
|
||||
int lyxstring::compare(size_type pos, size_type n, lyxstring const & str,
|
||||
size_type pos2, size_type n2) const
|
||||
{
|
||||
TestlyxstringInvariant(this);
|
||||
|
||||
return compare(pos, n, str.c_str() + pos2, n2);
|
||||
}
|
||||
|
||||
|
||||
int lyxstring::compare(size_type pos, size_type n, value_type const * s,
|
||||
size_type n2) const
|
||||
{
|
||||
Assert(s && (pos < rep->sz || pos == 0));
|
||||
TestlyxstringInvariant(this);
|
||||
|
||||
if ((rep->sz == 0 || n == 0) && (!*s || n2 == 0)) return 0;
|
||||
if (!*s) return 1;
|
||||
// since n > n2, min(n,n2) == 0, c == 0 (stops segfault also)
|
||||
@ -1462,7 +1422,7 @@ int lyxstring::compare(size_type pos, size_type n, value_type const * s,
|
||||
// remember that n can very well be a lot larger than rep->sz
|
||||
// so we have to ensure that n is no larger than rep->sz
|
||||
n = min(n, rep->sz);
|
||||
n2 = min(n2, strlen(s));
|
||||
n2 = min(n2, slen);
|
||||
if (n == n2)
|
||||
return memcmp(&(rep->s[pos]), s, n);
|
||||
int c = memcmp(&(rep->s[pos]), s, min(n,n2));
|
||||
@ -1474,6 +1434,52 @@ int lyxstring::compare(size_type pos, size_type n, value_type const * s,
|
||||
}
|
||||
|
||||
|
||||
int lyxstring::compare(lyxstring const & str) const
|
||||
{
|
||||
TestlyxstringInvariant(this);
|
||||
return internal_compare(0, rep->sz, str.rep->s,
|
||||
str.rep->sz, str.rep->sz);
|
||||
}
|
||||
|
||||
|
||||
int lyxstring::compare(value_type const * s) const
|
||||
{
|
||||
Assert(s);
|
||||
TestlyxstringInvariant(this);
|
||||
int n = (!s) ? 0 : strlen(s);
|
||||
return internal_compare(0, rep->sz, s, n, n);
|
||||
}
|
||||
|
||||
|
||||
int lyxstring::compare(size_type pos, size_type n, lyxstring const & str) const
|
||||
{
|
||||
Assert(pos < rep->sz || pos == 0);
|
||||
TestlyxstringInvariant(this);
|
||||
return internal_compare(pos, n, str.rep->s, str.rep->sz, str.rep->sz);
|
||||
}
|
||||
|
||||
|
||||
int lyxstring::compare(size_type pos, size_type n, lyxstring const & str,
|
||||
size_type pos2, size_type n2) const
|
||||
{
|
||||
Assert(pos < rep->sz || pos == 0);
|
||||
Assert(pos2 < str.rep->sz || pos2 == 0);
|
||||
TestlyxstringInvariant(this);
|
||||
return internal_compare(pos, n,
|
||||
str.rep->s + pos2,
|
||||
str.rep->sz - pos2, n2);
|
||||
}
|
||||
|
||||
|
||||
int lyxstring::compare(size_type pos, size_type n, value_type const * s,
|
||||
size_type n2) const
|
||||
{
|
||||
Assert(s && (pos < rep->sz || pos == 0));
|
||||
TestlyxstringInvariant(this);
|
||||
return internal_compare(pos, n, s, (!s) ? 0 : strlen(s), n2);
|
||||
}
|
||||
|
||||
|
||||
/////////////////
|
||||
// Substrings
|
||||
/////////////////
|
||||
|
@ -533,7 +533,12 @@ private:
|
||||
//lyxstring & operator=(int);
|
||||
//
|
||||
//lyxstring & operator+=(int);
|
||||
|
||||
|
||||
/// Compare this with s. works with embedded '\0' chars also.
|
||||
int internal_compare(size_type pos, size_type n,
|
||||
value_type const * s,
|
||||
size_type slen, size_type n2) const;
|
||||
|
||||
/// Forward declaration of the string representation
|
||||
struct Srep;
|
||||
// DEC cxx requires this.
|
||||
|
@ -854,7 +854,7 @@ int LyXText::Fill(Row * row, int paperwidth)
|
||||
LyXParagraph::size_type main_body =
|
||||
BeginningOfMainBody(row->par);
|
||||
LyXParagraph::size_type i = row->pos;
|
||||
while (i < last) {
|
||||
while (i <= last) {
|
||||
#else
|
||||
int main_body = BeginningOfMainBody(row->par);
|
||||
int i = row->pos;
|
||||
|
21
src/text2.C
21
src/text2.C
@ -1898,8 +1898,9 @@ This is not implemented yet.
|
||||
if (sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)
|
||||
== sel_end_cursor.par->ParFromPos(sel_end_cursor.pos)) {
|
||||
/* only within one paragraph */
|
||||
simple_cut_buffer = new LyXParagraph();
|
||||
simple_cut_buffer = new LyXParagraph;
|
||||
#ifdef NEW_TEXT
|
||||
simple_cut_buffer->text.reserve(500);
|
||||
LyXParagraph::size_type i =
|
||||
sel_start_cursor.pos;
|
||||
#else
|
||||
@ -2072,6 +2073,9 @@ void LyXText::CopySelection()
|
||||
== sel_end_cursor.par->ParFromPos(sel_end_cursor.pos)) {
|
||||
/* only within one paragraph */
|
||||
simple_cut_buffer = new LyXParagraph;
|
||||
#if NEW_TEXT
|
||||
simple_cut_buffer->text.reserve(500);
|
||||
#endif
|
||||
for (i = sel_start_cursor.pos; i < sel_end_cursor.pos; ++i){
|
||||
sel_start_cursor.par->CopyIntoMinibuffer(i);
|
||||
simple_cut_buffer->InsertFromMinibuffer(i - sel_start_cursor.pos);
|
||||
@ -2390,8 +2394,8 @@ bool LyXText::IsStringInText(LyXParagraph * par, int pos, char const * str)
|
||||
if (par) {
|
||||
int i = 0;
|
||||
while (pos + i < par->Last() && str[i] &&
|
||||
str[i]==par->GetChar(pos+i)) {
|
||||
i++;
|
||||
str[i] == par->GetChar(pos + i)) {
|
||||
++i;
|
||||
}
|
||||
if (!str[i])
|
||||
return true;
|
||||
@ -3427,7 +3431,9 @@ bool LyXText::TextHandleUndo(Undo * undo){ // returns false if no undo possible
|
||||
if (undo->kind == Undo::EDIT){
|
||||
tmppar2->text = tmppar->text;
|
||||
#ifdef NEW_TEXT
|
||||
tmppar->text.clear();
|
||||
//tmppar->text.clear();
|
||||
tmppar->text.erase(tmppar->text.begin(),
|
||||
tmppar->text.end());
|
||||
#else
|
||||
tmppar->text = 0;
|
||||
#endif
|
||||
@ -3598,7 +3604,9 @@ Undo * LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph * before,
|
||||
// a memory optimization: Just store the layout information when only edit
|
||||
if (kind == Undo::EDIT){
|
||||
#ifdef NEW_TEXT
|
||||
tmppar2->text.clear();
|
||||
//tmppar2->text.clear();
|
||||
tmppar2->text.erase(tmppar2->text.begin(),
|
||||
tmppar2->text.end());
|
||||
#else
|
||||
if (tmppar2->text)
|
||||
delete[] tmppar2->text;
|
||||
@ -3615,7 +3623,8 @@ Undo * LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph * before,
|
||||
// a memory optimization: Just store the layout information when only edit
|
||||
if (kind == Undo::EDIT){
|
||||
#ifdef NEW_TEXT
|
||||
tmppar2->next->text.clear();
|
||||
//tmppar2->next->text.clear();
|
||||
tmppar2->next->text.erase(tmppar2->next->text.begin(), tmppar2->next->text.end());
|
||||
#else
|
||||
if (tmppar2->next->text)
|
||||
delete[] tmppar2->next->text;
|
||||
|
Loading…
Reference in New Issue
Block a user