mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
continue the crusade to get rid of current_view
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@564 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d5134a917d
commit
c52895023e
23
ChangeLog
23
ChangeLog
@ -3,6 +3,29 @@
|
||||
* src/insets/insettoc.[Ch] (LinuxDoc, DocBook): mark the methods
|
||||
as const.
|
||||
|
||||
2000-02-20 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/bufferlist.C: get rid of current_view from this file
|
||||
|
||||
* src/spellchecker.C: get rid of current_view from this file
|
||||
|
||||
* src/vspace.C: get rid of current_view from this file
|
||||
(inPixels): added BufferView parameter for this func
|
||||
(asLatexCommand): added a BufferParams for this func
|
||||
|
||||
* src/text.C src/text2.C: get rid of current_view from these
|
||||
files.
|
||||
|
||||
* src/lyxfont.C (getFontDirection): move this function here from
|
||||
text.C
|
||||
|
||||
* src/bufferparams.C (getDocumentDirection): move this function
|
||||
here from text.C
|
||||
|
||||
* src/paragraph.C (getParDirection): move this function here from
|
||||
text.C
|
||||
(getLetterDirection): ditto
|
||||
|
||||
2000-02-18 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* WorkArea, Painter, LyXScreen: Fixed the crash that occured on
|
||||
|
@ -185,7 +185,7 @@ dnl Check the version of g++
|
||||
case $gxx_version in
|
||||
2.7*) CXXFLAGS="$lyx_opt";;
|
||||
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti";;
|
||||
2.95.*) CXXFLAGS="-g $lyx_opt -Woverloaded-virtual -fno-rtti -fno-exceptions";;
|
||||
2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
|
||||
*2.91.*) CXXFLAGS="-g $lyx_opt -Wno-return-type -fno-exceptions -fno-rtti";;
|
||||
*) CXXFLAGS="-g $lyx_opt -fno-exceptions -fno-rtti";;
|
||||
esac
|
||||
|
@ -604,7 +604,8 @@ void BufferView::workAreaMotionNotify(int x, int y, unsigned int state)
|
||||
if (the_locking_inset) {
|
||||
LyXCursor cursor = text->cursor;
|
||||
the_locking_inset->
|
||||
InsetMotionNotify(x - cursor.x,
|
||||
InsetMotionNotify(this,
|
||||
x - cursor.x,
|
||||
y - cursor.y,
|
||||
state);
|
||||
return;
|
||||
@ -666,7 +667,8 @@ void BufferView::workAreaButtonPress(int xpos, int ypos, unsigned int button)
|
||||
otherwise give the event to the inset */
|
||||
if (inset_hit) {
|
||||
the_locking_inset->
|
||||
InsetButtonPress(xpos, ypos,
|
||||
InsetButtonPress(this,
|
||||
xpos, ypos,
|
||||
button);
|
||||
return;
|
||||
} else {
|
||||
@ -736,7 +738,7 @@ void BufferView::workAreaButtonPress(int xpos, int ypos, unsigned int button)
|
||||
selection_possible = false;
|
||||
owner_->updateLayoutChoice();
|
||||
owner_->getMiniBuffer()->Set(inset_hit->EditMessage());
|
||||
inset_hit->Edit(xpos, ypos);
|
||||
inset_hit->Edit(this, xpos, ypos);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -788,7 +790,7 @@ void BufferView::workAreaButtonRelease(int x, int y, unsigned int button)
|
||||
Only a ButtonPress Event outside the inset will
|
||||
force a InsetUnlock. */
|
||||
the_locking_inset->
|
||||
InsetButtonRelease(x, x, button);
|
||||
InsetButtonRelease(this, x, y, button);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -835,7 +837,7 @@ void BufferView::workAreaButtonRelease(int x, int y, unsigned int button)
|
||||
}
|
||||
|
||||
owner_->getMiniBuffer()->Set(inset_hit->EditMessage());
|
||||
inset_hit->Edit(x, y);
|
||||
inset_hit->Edit(this, x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -911,7 +913,7 @@ void BufferView::workAreaButtonRelease(int x, int y, unsigned int button)
|
||||
textclasslist
|
||||
.TextClass(buffer_->
|
||||
params.textclass).defaultfont())) {
|
||||
text->cursor.par->bibkey->Edit(0, 0);
|
||||
text->cursor.par->bibkey->Edit(this, 0, 0);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -1107,7 +1109,7 @@ void BufferView::cursorToggleCB(FL_OBJECT * ob, long)
|
||||
view->screen->CursorToggle();
|
||||
} else {
|
||||
view->the_locking_inset->
|
||||
ToggleInsetCursor();
|
||||
ToggleInsetCursor(view);
|
||||
}
|
||||
goto set_timer_and_return;
|
||||
} else {
|
||||
@ -1117,7 +1119,7 @@ void BufferView::cursorToggleCB(FL_OBJECT * ob, long)
|
||||
} else {
|
||||
if (!view->the_locking_inset->isCursorVisible())
|
||||
view->the_locking_inset->
|
||||
ToggleInsetCursor();
|
||||
ToggleInsetCursor(view);
|
||||
}
|
||||
// This is only run when work_area_focus or lyx_focus is false.
|
||||
Window tmpwin;
|
||||
@ -1383,7 +1385,7 @@ void BufferView::insetSleep()
|
||||
{
|
||||
if (the_locking_inset && !inset_slept) {
|
||||
the_locking_inset->GetCursorPos(slx, sly);
|
||||
the_locking_inset->InsetUnlock();
|
||||
the_locking_inset->InsetUnlock(this);
|
||||
inset_slept = true;
|
||||
}
|
||||
}
|
||||
@ -1392,7 +1394,7 @@ void BufferView::insetSleep()
|
||||
void BufferView::insetWakeup()
|
||||
{
|
||||
if (the_locking_inset && inset_slept) {
|
||||
the_locking_inset->Edit(slx, sly);
|
||||
the_locking_inset->Edit(this, slx, sly);
|
||||
inset_slept = false;
|
||||
}
|
||||
}
|
||||
@ -1401,7 +1403,7 @@ void BufferView::insetWakeup()
|
||||
void BufferView::insetUnlock()
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
if (!inset_slept) the_locking_inset->InsetUnlock();
|
||||
if (!inset_slept) the_locking_inset->InsetUnlock(this);
|
||||
the_locking_inset = 0;
|
||||
text->FinishUndo();
|
||||
inset_slept = false;
|
||||
|
@ -237,7 +237,7 @@ void BufferView::open_new_inset(UpdatableInset * new_inset)
|
||||
insertInset(new_inset);
|
||||
text->CursorLeft();
|
||||
update(1);
|
||||
new_inset->Edit(0, 0);
|
||||
new_inset->Edit(this, 0, 0);
|
||||
}
|
||||
|
||||
/* This is also a buffer property (ale) */
|
||||
@ -360,7 +360,7 @@ void BufferView::insertNote()
|
||||
{
|
||||
InsetInfo * new_inset = new InsetInfo();
|
||||
insertInset(new_inset);
|
||||
new_inset->Edit(0, 0);
|
||||
new_inset->Edit(this, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -727,7 +727,7 @@ void BufferView::fitLockedInsetCursor(long x, long y, int asc, int desc)
|
||||
int BufferView::unlockInset(UpdatableInset * inset)
|
||||
{
|
||||
if (inset && the_locking_inset == inset) {
|
||||
inset->InsetUnlock();
|
||||
inset->InsetUnlock(this);
|
||||
the_locking_inset = 0;
|
||||
text->FinishUndo();
|
||||
return 0;
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
///
|
||||
string getText();
|
||||
///
|
||||
char const * c_str();
|
||||
char const * c_str() const;
|
||||
///
|
||||
Bullet & operator = (Bullet const &);
|
||||
///
|
||||
@ -244,7 +244,7 @@ inline Bullet & Bullet::operator=(Bullet const & b)
|
||||
}
|
||||
|
||||
|
||||
inline char const * Bullet::c_str()
|
||||
inline char const * Bullet::c_str() const
|
||||
{
|
||||
return this->getText().c_str();
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ static
|
||||
char const * spacing_string[] = {"single", "onehalf", "double", "other"};
|
||||
|
||||
|
||||
void Spacing::writeFile(ostream & os)
|
||||
void Spacing::writeFile(ostream & os) const
|
||||
{
|
||||
if (getSpace() == Spacing::Other) {
|
||||
os.setf(ios::showpoint|ios::fixed);
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
set(sp, fval);
|
||||
}
|
||||
///
|
||||
void writeFile(ostream &);
|
||||
void writeFile(ostream &) const;
|
||||
///
|
||||
friend bool operator!=(Spacing const & a, Spacing const & b) {
|
||||
if (a.space == b.space && a.getValue() == b.getValue())
|
||||
|
98
src/buffer.C
98
src/buffer.C
@ -34,6 +34,8 @@ using std::setw;
|
||||
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <utime.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "buffer.h"
|
||||
@ -174,7 +176,7 @@ bool Buffer::saveParamsAsDefaults()
|
||||
|
||||
/// Update window titles of all users
|
||||
// Should work on a list
|
||||
void Buffer::updateTitles()
|
||||
void Buffer::updateTitles() const
|
||||
{
|
||||
if (users) users->owner()->updateWindowTitle();
|
||||
}
|
||||
@ -182,7 +184,7 @@ void Buffer::updateTitles()
|
||||
|
||||
/// Reset autosave timer of all users
|
||||
// Should work on a list
|
||||
void Buffer::resetAutosaveTimers()
|
||||
void Buffer::resetAutosaveTimers() const
|
||||
{
|
||||
if (users) users->owner()->resetAutosaveTimer();
|
||||
}
|
||||
@ -966,8 +968,95 @@ bool Buffer::readFile(LyXLex & lex, LyXParagraph * par)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Should probably be moved to somewhere else: BufferView? LyXView?
|
||||
bool Buffer::save(bool makeBackup) const
|
||||
{
|
||||
// We don't need autosaves in the immediate future. (Asger)
|
||||
resetAutosaveTimers();
|
||||
|
||||
// make a backup
|
||||
if (makeBackup) {
|
||||
string s = fileName() + '~';
|
||||
// Rename is the wrong way of making a backup,
|
||||
// this is the correct way.
|
||||
/* truss cp fil fil2:
|
||||
lstat("LyXVC3.lyx", 0xEFFFF898) Err#2 ENOENT
|
||||
stat("LyXVC.lyx", 0xEFFFF688) = 0
|
||||
open("LyXVC.lyx", O_RDONLY) = 3
|
||||
open("LyXVC3.lyx", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 4
|
||||
fstat(4, 0xEFFFF508) = 0
|
||||
fstat(3, 0xEFFFF508) = 0
|
||||
read(3, " # T h i s f i l e w".., 8192) = 5579
|
||||
write(4, " # T h i s f i l e w".., 5579) = 5579
|
||||
read(3, 0xEFFFD4A0, 8192) = 0
|
||||
close(4) = 0
|
||||
close(3) = 0
|
||||
chmod("LyXVC3.lyx", 0100644) = 0
|
||||
lseek(0, 0, SEEK_CUR) = 46440
|
||||
_exit(0)
|
||||
*/
|
||||
|
||||
// Should proabaly have some more error checking here.
|
||||
// Should be cleaned up in 0.13, at least a bit.
|
||||
// Doing it this way, also makes the inodes stay the same.
|
||||
// This is still not a very good solution, in particular we
|
||||
// might loose the owner of the backup.
|
||||
FileInfo finfo(fileName());
|
||||
if (finfo.exist()) {
|
||||
mode_t fmode = finfo.getMode();
|
||||
struct utimbuf * times = new struct utimbuf;
|
||||
|
||||
times->actime = finfo.getAccessTime();
|
||||
times->modtime = finfo.getModificationTime();
|
||||
ifstream ifs(fileName().c_str());
|
||||
ofstream ofs(s.c_str(), ios::out|ios::trunc);
|
||||
if (ifs && ofs) {
|
||||
ofs << ifs.rdbuf();
|
||||
ifs.close();
|
||||
ofs.close();
|
||||
::chmod(s.c_str(), fmode);
|
||||
|
||||
if (::utime(s.c_str(), times)) {
|
||||
lyxerr << "utime error." << endl;
|
||||
}
|
||||
} else {
|
||||
lyxerr << "LyX was not able to make "
|
||||
"backupcopy. Beware." << endl;
|
||||
}
|
||||
delete times;
|
||||
}
|
||||
}
|
||||
|
||||
if (writeFile(fileName(), false)) {
|
||||
markLyxClean();
|
||||
|
||||
// now delete the autosavefile
|
||||
string a = OnlyPath(fileName());
|
||||
a += '#';
|
||||
a += OnlyFilename(fileName());
|
||||
a += '#';
|
||||
FileInfo fileinfo(a);
|
||||
if (fileinfo.exist()) {
|
||||
if (::remove(a.c_str()) != 0) {
|
||||
WriteFSAlert(_("Could not delete "
|
||||
"auto-save file!"), a);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Saving failed, so backup is not backup
|
||||
if (makeBackup) {
|
||||
string s = fileName() + '~';
|
||||
::rename(s.c_str(), fileName().c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Returns false if unsuccesful
|
||||
bool Buffer::writeFile(string const & fname, bool flag)
|
||||
bool Buffer::writeFile(string const & fname, bool flag) const
|
||||
{
|
||||
// if flag is false writeFile will not create any GUI
|
||||
// warnings, only cerr.
|
||||
@ -1366,9 +1455,6 @@ void Buffer::makeLaTeXFile(string const & fname,
|
||||
{
|
||||
lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
|
||||
|
||||
// How the **** can this be needed?
|
||||
//params.textclass = current_view->buffer()->params.textclass;
|
||||
|
||||
niceFile = nice; // this will be used by Insetincludes.
|
||||
|
||||
tex_code_break_column = lyxrc->ascii_linelen;
|
||||
|
18
src/buffer.h
18
src/buffer.h
@ -95,10 +95,10 @@ public:
|
||||
}
|
||||
|
||||
/// Update window titles of all users
|
||||
void updateTitles();
|
||||
void updateTitles() const;
|
||||
|
||||
/// Reset autosave timers for all users
|
||||
void resetAutosaveTimers();
|
||||
void resetAutosaveTimers() const;
|
||||
|
||||
/** Adds the BufferView to the users list.
|
||||
Later this func will insert the BufferView into a real list,
|
||||
@ -131,8 +131,14 @@ public:
|
||||
If par is given, the file is inserted. */
|
||||
bool readLyXformat2(LyXLex &, LyXParagraph * par = 0);
|
||||
|
||||
/** Save file
|
||||
Takes care of auto-save files and backup file if requested.
|
||||
Returns true if the save is successful, false otherwise.
|
||||
*/
|
||||
bool save(bool makeBackup) const;
|
||||
|
||||
/// Write file. Returns false if unsuccesful.
|
||||
bool writeFile(string const &, bool);
|
||||
bool writeFile(string const &, bool) const;
|
||||
|
||||
///
|
||||
void writeFileAscii(string const & , int);
|
||||
@ -180,7 +186,7 @@ public:
|
||||
bool isDepClean(string const & name) const;
|
||||
|
||||
///
|
||||
void markLyxClean() {
|
||||
void markLyxClean() const {
|
||||
if (!lyx_clean) {
|
||||
lyx_clean = true;
|
||||
updateTitles();
|
||||
@ -360,10 +366,10 @@ private:
|
||||
void RoffAsciiTable(ostream &, LyXParagraph * par);
|
||||
|
||||
/// is save needed
|
||||
bool lyx_clean;
|
||||
mutable bool lyx_clean;
|
||||
|
||||
/// is autosave needed
|
||||
bool bak_clean;
|
||||
mutable bool bak_clean;
|
||||
|
||||
/** do we need to run LaTeX, changed 23/03/98, Heinrich Bauer
|
||||
We have to distinguish between TeX-runs executed in the original
|
||||
|
118
src/bufferlist.C
118
src/bufferlist.C
@ -18,12 +18,8 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <utime.h>
|
||||
|
||||
#include "bufferlist.h"
|
||||
#include "lyx_main.h"
|
||||
#include "minibuffer.h"
|
||||
@ -40,12 +36,8 @@
|
||||
#include "vc-backend.h"
|
||||
#include "TextCache.h"
|
||||
|
||||
extern BufferView * current_view;
|
||||
extern int RunLinuxDoc(int, string const &);
|
||||
|
||||
using std::ifstream;
|
||||
using std::ofstream;
|
||||
using std::ios;
|
||||
using std::find;
|
||||
|
||||
//
|
||||
@ -133,105 +125,6 @@ bool BufferList::QwriteAll()
|
||||
}
|
||||
|
||||
|
||||
// Should probably be moved to somewhere else: BufferView? LyXView?
|
||||
bool BufferList::write(Buffer * buf, bool makeBackup)
|
||||
{
|
||||
if (buf->getUser())
|
||||
buf->getUser()
|
||||
->owner()
|
||||
->getMiniBuffer()
|
||||
->Set(_("Saving document"),
|
||||
MakeDisplayPath(buf->fileName()), "...");
|
||||
|
||||
// We don't need autosaves in the immediate future. (Asger)
|
||||
buf->resetAutosaveTimers();
|
||||
|
||||
// make a backup
|
||||
if (makeBackup) {
|
||||
string s = buf->fileName() + '~';
|
||||
// Rename is the wrong way of making a backup,
|
||||
// this is the correct way.
|
||||
/* truss cp fil fil2:
|
||||
lstat("LyXVC3.lyx", 0xEFFFF898) Err#2 ENOENT
|
||||
stat("LyXVC.lyx", 0xEFFFF688) = 0
|
||||
open("LyXVC.lyx", O_RDONLY) = 3
|
||||
open("LyXVC3.lyx", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 4
|
||||
fstat(4, 0xEFFFF508) = 0
|
||||
fstat(3, 0xEFFFF508) = 0
|
||||
read(3, " # T h i s f i l e w".., 8192) = 5579
|
||||
write(4, " # T h i s f i l e w".., 5579) = 5579
|
||||
read(3, 0xEFFFD4A0, 8192) = 0
|
||||
close(4) = 0
|
||||
close(3) = 0
|
||||
chmod("LyXVC3.lyx", 0100644) = 0
|
||||
lseek(0, 0, SEEK_CUR) = 46440
|
||||
_exit(0)
|
||||
*/
|
||||
|
||||
// Should proabaly have some more error checking here.
|
||||
// Should be cleaned up in 0.13, at least a bit.
|
||||
// Doing it this way, also makes the inodes stay the same.
|
||||
// This is still not a very good solution, in particular we
|
||||
// might loose the owner of the backup.
|
||||
FileInfo finfo(buf->fileName());
|
||||
if (finfo.exist()) {
|
||||
mode_t fmode = finfo.getMode();
|
||||
struct utimbuf * times = new struct utimbuf;
|
||||
|
||||
times->actime = finfo.getAccessTime();
|
||||
times->modtime = finfo.getModificationTime();
|
||||
ifstream ifs(buf->fileName().c_str());
|
||||
ofstream ofs(s.c_str(), ios::out|ios::trunc);
|
||||
if (ifs && ofs) {
|
||||
ofs << ifs.rdbuf();
|
||||
ifs.close();
|
||||
ofs.close();
|
||||
::chmod(s.c_str(), fmode);
|
||||
|
||||
if (::utime(s.c_str(), times)) {
|
||||
lyxerr << "utime error." << endl;
|
||||
}
|
||||
} else {
|
||||
lyxerr << "LyX was not able to make "
|
||||
"backupcopy. Beware." << endl;
|
||||
}
|
||||
delete times;
|
||||
}
|
||||
}
|
||||
|
||||
if (buf->writeFile(buf->fileName(), false)) {
|
||||
buf->markLyxClean();
|
||||
|
||||
current_view->owner()->getMiniBuffer()->
|
||||
Set(_("Document saved as"),
|
||||
MakeDisplayPath(buf->fileName()));
|
||||
|
||||
// now delete the autosavefile
|
||||
string a = OnlyPath(buf->fileName());
|
||||
a += '#';
|
||||
a += OnlyFilename(buf->fileName());
|
||||
a += '#';
|
||||
FileInfo fileinfo(a);
|
||||
if (fileinfo.exist()) {
|
||||
if (::remove(a.c_str()) != 0) {
|
||||
WriteFSAlert(_("Could not delete "
|
||||
"auto-save file!"), a);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Saving failed, so backup is not backup
|
||||
if (makeBackup) {
|
||||
string s = buf->fileName() + '~';
|
||||
::rename(s.c_str(), buf->fileName().c_str());
|
||||
}
|
||||
current_view->owner()->getMiniBuffer()->Set(_("Save failed!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void BufferList::closeAll()
|
||||
{
|
||||
state_ = BufferList::CLOSING;
|
||||
@ -265,12 +158,21 @@ bool BufferList::close(Buffer * buf)
|
||||
MakeDisplayPath(buf->fileName(), 50),
|
||||
_("Save document?"))){
|
||||
case 1: // Yes
|
||||
#if 0
|
||||
if (write(buf, lyxrc->make_backup)) {
|
||||
lastfiles->newFile(buf->fileName());
|
||||
} else {
|
||||
AllowInput();
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (buf->save(lyxrc->make_backup)) {
|
||||
lastfiles->newFile(buf->fileName());
|
||||
} else {
|
||||
AllowInput();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 3: // Cancel
|
||||
AllowInput();
|
||||
@ -588,9 +490,11 @@ Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
bool ro = false;
|
||||
switch (IsFileWriteable(s)) {
|
||||
case 0:
|
||||
#if 0
|
||||
current_view->owner()->getMiniBuffer()->
|
||||
Set(_("File `") + MakeDisplayPath(s, 50) +
|
||||
_("' is read-only."));
|
||||
#endif
|
||||
ro = true;
|
||||
// Fall through
|
||||
case 1:
|
||||
|
@ -96,7 +96,9 @@ public:
|
||||
bool empty() const;
|
||||
|
||||
/// Saves buffer. Returns false if unsuccesful.
|
||||
#if 0
|
||||
bool write(Buffer *, bool makeBackup);
|
||||
#endif
|
||||
|
||||
///
|
||||
bool QwriteAll();
|
||||
|
@ -22,6 +22,9 @@
|
||||
#include "debug.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "lyxrc.h"
|
||||
|
||||
extern LyXRC * lyxrc;
|
||||
|
||||
BufferParams::BufferParams()
|
||||
{
|
||||
@ -60,7 +63,7 @@ BufferParams::BufferParams()
|
||||
}
|
||||
|
||||
|
||||
void BufferParams::writeFile(ostream & os)
|
||||
void BufferParams::writeFile(ostream & os) const
|
||||
{
|
||||
// The top of the file is written by the buffer.
|
||||
// Prints out the buffer info into the .lyx file given by file
|
||||
@ -71,9 +74,9 @@ void BufferParams::writeFile(ostream & os)
|
||||
// then the the preamble
|
||||
if (!preamble.empty()) {
|
||||
// remove '\n' from the end of preamble
|
||||
preamble = strip(preamble, '\n');
|
||||
string tmppreamble = strip(preamble, '\n');
|
||||
os << "\\begin_preamble\n"
|
||||
<< preamble
|
||||
<< tmppreamble
|
||||
<< "\n\\end_preamble\n";
|
||||
}
|
||||
|
||||
@ -244,3 +247,10 @@ void BufferParams::readGraphicsDriver(LyXLex & lex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LyXDirection BufferParams::getDocumentDirection() const
|
||||
{
|
||||
return (lyxrc->rtl_support && language == "hebrew")
|
||||
? LYX_DIR_RIGHT_TO_LEFT : LYX_DIR_LEFT_TO_RIGHT;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public:
|
||||
//@}
|
||||
|
||||
///
|
||||
void writeFile(ostream &);
|
||||
void writeFile(ostream &) const;
|
||||
|
||||
///
|
||||
void useClassDefaults();
|
||||
|
@ -1253,7 +1253,7 @@ bool InsetFig::Deletable() const
|
||||
}
|
||||
|
||||
|
||||
void InsetFig::Edit(int, int)
|
||||
void InsetFig::Edit(BufferView * bv, int, int)
|
||||
{
|
||||
lyxerr.debug() << "Editing InsetFig." << endl;
|
||||
Regenerate();
|
||||
@ -1261,8 +1261,8 @@ void InsetFig::Edit(int, int)
|
||||
// We should have RO-versions of the form instead.
|
||||
// The actual prevention of altering a readonly doc
|
||||
// is done in CallbackFig()
|
||||
if(current_view->buffer()->isReadonly())
|
||||
WarnReadonly(current_view->buffer()->fileName());
|
||||
if(bv->buffer()->isReadonly())
|
||||
WarnReadonly(bv->buffer()->fileName());
|
||||
|
||||
if (!form) {
|
||||
form = create_form_Figure();
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
/// what appears in the minibuffer when opening
|
||||
char const * EditMessage() const { return _("Opened figure"); }
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const;
|
||||
///
|
||||
|
@ -49,7 +49,7 @@ bool Inset::AutoDelete() const
|
||||
}
|
||||
|
||||
|
||||
void Inset::Edit(int, int)
|
||||
void Inset::Edit(BufferView *, int, int)
|
||||
{
|
||||
}
|
||||
|
||||
@ -62,14 +62,14 @@ LyXFont Inset::ConvertFont(LyXFont font)
|
||||
|
||||
/* some stuff for inset locking */
|
||||
|
||||
void UpdatableInset::InsetButtonPress(int x, int y, int button)
|
||||
void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
|
||||
{
|
||||
lyxerr.debug() << "Inset Button Press x=" << x
|
||||
<< ", y=" << y << ", button=" << button << endl;
|
||||
}
|
||||
|
||||
|
||||
void UpdatableInset::InsetButtonRelease(int x, int y, int button)
|
||||
void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
|
||||
{
|
||||
lyxerr.debug() << "Inset Button Release x=" << x
|
||||
<< ", y=" << y << ", button=" << button << endl;
|
||||
@ -82,14 +82,14 @@ void UpdatableInset::InsetKeyPress(XKeyEvent *)
|
||||
}
|
||||
|
||||
|
||||
void UpdatableInset::InsetMotionNotify(int x, int y, int state)
|
||||
void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
|
||||
{
|
||||
lyxerr.debug() << "Inset Motion Notify x=" << x
|
||||
<< ", y=" << y << ", state=" << state << endl;
|
||||
}
|
||||
|
||||
|
||||
void UpdatableInset::InsetUnlock()
|
||||
void UpdatableInset::InsetUnlock(BufferView *)
|
||||
{
|
||||
lyxerr.debug() << "Inset Unlock" << endl;
|
||||
}
|
||||
@ -102,6 +102,6 @@ unsigned char UpdatableInset::Editable() const
|
||||
}
|
||||
|
||||
|
||||
void UpdatableInset::ToggleInsetCursor()
|
||||
void UpdatableInset::ToggleInsetCursor(BufferView *)
|
||||
{
|
||||
}
|
||||
|
@ -38,14 +38,18 @@ extern "C" void bibitem_cb(FL_OBJECT *, long data)
|
||||
switch (data) {
|
||||
case 1: // OK, citation
|
||||
{
|
||||
if(!current_view->buffer()->isReadonly()) {
|
||||
InsetCommand * inset = static_cast<InsetCommand*>(citation_form->citation_form->u_vdata);
|
||||
InsetCitation::Holder * holder =
|
||||
static_cast<InsetCitation::Holder*>
|
||||
(citation_form->citation_form->u_vdata);
|
||||
if(!holder->view->buffer()->isReadonly()) {
|
||||
|
||||
InsetCitation * inset = holder->inset;
|
||||
inset->setContents(bibcombox->getline());
|
||||
inset->setOptions(fl_get_input(citation_form->label));
|
||||
fl_hide_form(citation_form->citation_form);
|
||||
// shouldn't mark the buffer dirty unless something
|
||||
// was actually altered
|
||||
UpdateInset(current_view, inset);
|
||||
UpdateInset(holder->view, inset);
|
||||
break;
|
||||
}
|
||||
// fall through to Cancel on RO-mode
|
||||
@ -54,14 +58,18 @@ extern "C" void bibitem_cb(FL_OBJECT *, long data)
|
||||
break;
|
||||
case 3: // OK, bibitem
|
||||
{
|
||||
if(!current_view->buffer()->isReadonly()) {
|
||||
InsetCommand * inset = static_cast<InsetCommand*>(bibitem_form->bibitem_form->u_vdata);
|
||||
InsetBibKey::Holder * holder =
|
||||
static_cast<InsetBibKey::Holder*>
|
||||
(bibitem_form->bibitem_form->u_vdata);
|
||||
|
||||
if(!holder->view->buffer()->isReadonly()) {
|
||||
InsetBibKey * inset = holder->inset;
|
||||
inset->setContents(fl_get_input(bibitem_form->key));
|
||||
inset->setOptions(fl_get_input(bibitem_form->label));
|
||||
fl_hide_form(bibitem_form->bibitem_form);
|
||||
// Does look like a hack? It is! (but will change at 0.13)
|
||||
current_view->text->RedoParagraph();
|
||||
current_view->update(1);
|
||||
holder->view->text->RedoParagraph();
|
||||
holder->view->update(1);
|
||||
break;
|
||||
} // fall through to Cancel on RO-mode
|
||||
}
|
||||
@ -144,22 +152,26 @@ InsetCitation::~InsetCitation()
|
||||
{
|
||||
if(citation_form && citation_form->citation_form
|
||||
&& citation_form->citation_form->visible
|
||||
&& citation_form->citation_form->u_vdata == this)
|
||||
&& citation_form->citation_form->u_vdata == &holder)
|
||||
fl_hide_form(citation_form->citation_form);
|
||||
}
|
||||
|
||||
|
||||
void InsetCitation::Edit(int, int)
|
||||
void InsetCitation::Edit(BufferView * bv, int, int)
|
||||
{
|
||||
if(current_view->buffer()->isReadonly())
|
||||
WarnReadonly(current_view->buffer()->fileName());
|
||||
if(bv->buffer()->isReadonly())
|
||||
WarnReadonly(bv->buffer()->fileName());
|
||||
|
||||
if (!citation_form) {
|
||||
citation_form = create_form_citation_form();
|
||||
fl_set_form_atclose(citation_form->citation_form,
|
||||
CancelCloseBoxCB, 0);
|
||||
}
|
||||
citation_form->citation_form->u_vdata = this;
|
||||
|
||||
holder.inset = this;
|
||||
holder.view = bv;
|
||||
|
||||
citation_form->citation_form->u_vdata = &holder;
|
||||
|
||||
BibitemUpdate(bibcombox);
|
||||
if (!bibcombox->select_text(getContents().c_str()))
|
||||
@ -254,17 +266,21 @@ string InsetBibKey::getScreenLabel() const
|
||||
upwards?
|
||||
(Joacim 1998-03-04)
|
||||
*/
|
||||
void InsetBibKey::Edit(int, int)
|
||||
void InsetBibKey::Edit(BufferView * bv, int, int)
|
||||
{
|
||||
if(current_view->buffer()->isReadonly())
|
||||
WarnReadonly(current_view->buffer()->fileName());
|
||||
if(bv->buffer()->isReadonly())
|
||||
WarnReadonly(bv->buffer()->fileName());
|
||||
|
||||
if (!bibitem_form) {
|
||||
bibitem_form = create_form_bibitem_form();
|
||||
fl_set_form_atclose(bibitem_form->bibitem_form,
|
||||
CancelCloseBoxCB, 0);
|
||||
}
|
||||
bibitem_form->bibitem_form->u_vdata = this;
|
||||
|
||||
holder.inset = this;
|
||||
holder.view = bv;
|
||||
|
||||
bibitem_form->bibitem_form->u_vdata = &holder;
|
||||
// InsetBibtex uses the same form, with different labels
|
||||
fl_set_object_label(bibitem_form->key, idex(_("Key:|#K")));
|
||||
fl_set_button_shortcut(bibitem_form->key, scex(_("Key:|#K")), 1);
|
||||
@ -354,9 +370,13 @@ string InsetBibtex::getKeys(char delim)
|
||||
{
|
||||
// This hack is copied from InsetBibtex::Latex.
|
||||
// Is it still needed? Probably yes.
|
||||
if (!owner) {
|
||||
owner = current_view->buffer();
|
||||
}
|
||||
// Why is this needed here when it already is in Latex?
|
||||
// Anyway we need a different way to get to the
|
||||
// buffer the inset is in. (Lgb)
|
||||
|
||||
//if (!owner) {
|
||||
// owner = current_view->buffer();
|
||||
//}
|
||||
|
||||
string tmp, keys;
|
||||
string bibfiles = getContents();
|
||||
@ -400,7 +420,7 @@ string InsetBibtex::getKeys(char delim)
|
||||
|
||||
|
||||
// BibTeX should have its own dialog. This is provisional.
|
||||
void InsetBibtex::Edit(int, int)
|
||||
void InsetBibtex::Edit(BufferView *, int, int)
|
||||
{
|
||||
if (!bibitem_form) {
|
||||
bibitem_form = create_form_bibitem_form();
|
||||
|
@ -38,11 +38,20 @@ public:
|
||||
///
|
||||
string getScreenLabel()const;
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const {
|
||||
return 1;
|
||||
}
|
||||
private:
|
||||
///
|
||||
struct Holder {
|
||||
InsetCitation * inset;
|
||||
BufferView * view;
|
||||
};
|
||||
|
||||
///
|
||||
Holder holder;
|
||||
};
|
||||
|
||||
|
||||
@ -68,7 +77,7 @@ public:
|
||||
///
|
||||
virtual string getScreenLabel() const;
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const {
|
||||
return 1;
|
||||
@ -85,6 +94,14 @@ public:
|
||||
private:
|
||||
///
|
||||
int counter;
|
||||
///
|
||||
struct Holder {
|
||||
InsetBibKey * inset;
|
||||
BufferView * view;
|
||||
};
|
||||
|
||||
///
|
||||
Holder holder;
|
||||
};
|
||||
|
||||
|
||||
@ -109,7 +126,7 @@ public:
|
||||
///
|
||||
string getScreenLabel() const;
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
int Latex(ostream &, signed char) const;
|
||||
///
|
||||
|
@ -155,7 +155,7 @@ extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT * ob, long data)
|
||||
}
|
||||
|
||||
|
||||
void InsetError::Edit(int, int)
|
||||
void InsetError::Edit(BufferView *, int, int)
|
||||
{
|
||||
static int ow = 400, oh = 240;
|
||||
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
/// what appears in the minibuffer when opening
|
||||
char const * EditMessage() const {return _("Opened error");}
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const;
|
||||
///
|
||||
|
@ -227,10 +227,10 @@ Inset * InsetInclude::Clone() const
|
||||
}
|
||||
|
||||
|
||||
void InsetInclude::Edit(int, int)
|
||||
void InsetInclude::Edit(BufferView * bv, int, int)
|
||||
{
|
||||
if(current_view->buffer()->isReadonly())
|
||||
WarnReadonly(current_view->buffer()->fileName());
|
||||
if(bv->buffer()->isReadonly())
|
||||
WarnReadonly(bv->buffer()->fileName());
|
||||
|
||||
if (!form) {
|
||||
form = create_form_include();
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
/// This returns the list of bibkeys on the child buffer
|
||||
string getKeys(char delim) const;
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const
|
||||
{
|
||||
|
@ -86,10 +86,10 @@ InsetIndex::~InsetIndex()
|
||||
}
|
||||
|
||||
|
||||
void InsetIndex::Edit(int, int)
|
||||
void InsetIndex::Edit(BufferView * bv, int, int)
|
||||
{
|
||||
if(current_view->buffer()->isReadonly())
|
||||
WarnReadonly(current_view->buffer()->fileName());
|
||||
if(bv->buffer()->isReadonly())
|
||||
WarnReadonly(bv->buffer()->fileName());
|
||||
|
||||
if (!index_form)
|
||||
index_form = create_form_index_form();
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
///
|
||||
Inset * Clone() const { return new InsetIndex(contents);}
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const
|
||||
{
|
||||
@ -59,7 +59,7 @@ public:
|
||||
/// Updates needed features for this inset.
|
||||
void Validate(LaTeXFeatures & features) const;
|
||||
///
|
||||
void Edit(int, int) {}
|
||||
void Edit(BufferView *, int, int) {}
|
||||
///
|
||||
unsigned char Editable() const{
|
||||
return 1;
|
||||
|
@ -180,12 +180,12 @@ extern "C" void C_InsetInfo_CloseInfoCB(FL_OBJECT * ob, long data)
|
||||
}
|
||||
|
||||
|
||||
void InsetInfo::Edit(int, int)
|
||||
void InsetInfo::Edit(BufferView * bv, int, int)
|
||||
{
|
||||
static int ow = -1, oh;
|
||||
|
||||
if(current_view->buffer()->isReadonly())
|
||||
WarnReadonly(current_view->buffer()->fileName());
|
||||
if(bv->buffer()->isReadonly())
|
||||
WarnReadonly(bv->buffer()->fileName());
|
||||
|
||||
if (!form) {
|
||||
FL_OBJECT *obj;
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
/// what appears in the minibuffer when opening
|
||||
char const * EditMessage() const {return _("Opened note");}
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const;
|
||||
///
|
||||
|
@ -25,9 +25,6 @@
|
||||
#include "commandtags.h"
|
||||
|
||||
|
||||
extern BufferView * current_view;
|
||||
|
||||
|
||||
InsetParent::InsetParent(string const & fn, Buffer * owner)
|
||||
: InsetCommand("lyxparent")
|
||||
{
|
||||
@ -38,10 +35,10 @@ InsetParent::InsetParent(string const & fn, Buffer * owner)
|
||||
}
|
||||
|
||||
|
||||
void InsetParent::Edit(int, int)
|
||||
void InsetParent::Edit(BufferView * bv, int, int)
|
||||
{
|
||||
current_view->owner()->getLyXFunc()->Dispatch(LFUN_CHILDOPEN,
|
||||
getContents().c_str());
|
||||
bv->owner()->getLyXFunc()->Dispatch(LFUN_CHILDOPEN,
|
||||
getContents().c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
return string(_("Parent:")) + getContents();
|
||||
}
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const {
|
||||
return 1;
|
||||
|
@ -43,9 +43,9 @@ InsetRef::InsetRef(InsetCommand const & inscmd, Buffer * bf)
|
||||
}
|
||||
|
||||
|
||||
void InsetRef::Edit(int, int)
|
||||
void InsetRef::Edit(BufferView * bv, int, int)
|
||||
{
|
||||
current_view->owner()->getLyXFunc()
|
||||
bv->owner()->getLyXFunc()
|
||||
->Dispatch(LFUN_REFGOTO, getContents().c_str());
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
///
|
||||
Inset::Code LyxCode() const { return Inset::REF_CODE; }
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const {
|
||||
return 1;
|
||||
|
@ -11,11 +11,9 @@
|
||||
#include "lyxfunc.h"
|
||||
#include "LyXView.h"
|
||||
|
||||
extern BufferView * current_view;
|
||||
|
||||
void InsetTOC::Edit(int, int)
|
||||
void InsetTOC::Edit(BufferView * bv, int, int)
|
||||
{
|
||||
current_view->owner()->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
|
||||
bv->owner()->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
|
||||
}
|
||||
|
||||
int InsetTOC::Linuxdoc(string & file) const
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
///
|
||||
string getScreenLabel() const { return _("Table of Contents"); }
|
||||
/// On edit, we open the TOC pop-up
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const {
|
||||
return 1;
|
||||
|
@ -14,9 +14,9 @@
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "lyx_gui_misc.h" // CancelCloseBoxCB
|
||||
|
||||
extern BufferView * current_view;
|
||||
extern void UpdateInset(BufferView *, Inset * inset, bool mark_dirty = true);
|
||||
|
||||
|
||||
InsetUrl::InsetUrl(string const & cmd)
|
||||
: fd_form_url(0)
|
||||
{
|
||||
@ -67,7 +67,11 @@ InsetUrl::~InsetUrl()
|
||||
|
||||
void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
|
||||
{
|
||||
InsetUrl * inset = static_cast<InsetUrl*>(ob->u_vdata);
|
||||
Holder * holder = static_cast<Holder*>(ob->u_vdata);
|
||||
|
||||
InsetUrl * inset = holder->inset;
|
||||
BufferView * bv = holder->view;
|
||||
|
||||
string url = fl_get_input(inset->fd_form_url->url_name);
|
||||
string name = fl_get_input(inset->fd_form_url->name_name);
|
||||
string cmdname;
|
||||
@ -76,7 +80,7 @@ void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
|
||||
else
|
||||
cmdname = "url";
|
||||
|
||||
Buffer * buffer = current_view->buffer();
|
||||
Buffer * buffer = bv->buffer();
|
||||
|
||||
if ((url != inset->getContents() ||
|
||||
name != inset->getOptions() ||
|
||||
@ -90,7 +94,7 @@ void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
|
||||
inset->flag = InsetUrl::URL;
|
||||
else
|
||||
inset->flag = InsetUrl::HTML_URL;
|
||||
UpdateInset(current_view, inset);
|
||||
UpdateInset(bv, inset);
|
||||
}
|
||||
|
||||
if (inset->fd_form_url) {
|
||||
@ -107,19 +111,21 @@ extern "C" void C_InsetUrl_CloseUrlCB(FL_OBJECT * ob, long data)
|
||||
}
|
||||
|
||||
|
||||
void InsetUrl::Edit(int, int)
|
||||
void InsetUrl::Edit(BufferView * bv, int, int)
|
||||
{
|
||||
static int ow = -1, oh;
|
||||
|
||||
if(current_view->buffer()->isReadonly())
|
||||
WarnReadonly(current_view->buffer()->fileName());
|
||||
if(bv->buffer()->isReadonly())
|
||||
WarnReadonly(bv->buffer()->fileName());
|
||||
|
||||
if (!fd_form_url) {
|
||||
fd_form_url = create_form_form_url();
|
||||
fd_form_url->button_close->u_vdata = this;
|
||||
holder.inset = this;
|
||||
fd_form_url->button_close->u_vdata = &holder;
|
||||
fl_set_form_atclose(fd_form_url->form_url,
|
||||
CancelCloseBoxCB, 0);
|
||||
}
|
||||
holder.view = bv;
|
||||
fl_set_input(fd_form_url->url_name, getContents().c_str());
|
||||
fl_set_input(fd_form_url->name_name, getOptions().c_str());
|
||||
switch(flag) {
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
///
|
||||
void Validate(LaTeXFeatures &) const;
|
||||
///
|
||||
void Edit(int, int);
|
||||
void Edit(BufferView *, int, int);
|
||||
///
|
||||
unsigned char Editable() const {
|
||||
return 1;
|
||||
@ -80,6 +80,14 @@ public:
|
||||
///
|
||||
static void CloseUrlCB(FL_OBJECT *, long data);
|
||||
private:
|
||||
///
|
||||
struct Holder {
|
||||
InsetUrl * inset;
|
||||
BufferView * view;
|
||||
};
|
||||
///
|
||||
Holder holder;
|
||||
|
||||
///
|
||||
Url_Flags flag;
|
||||
///
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
class Painter;
|
||||
class Buffer;
|
||||
class BufferView;
|
||||
|
||||
struct LaTeXFeatures;
|
||||
|
||||
/// Insets
|
||||
@ -93,7 +95,7 @@ public:
|
||||
/// what appears in the minibuffer when opening
|
||||
virtual char const * EditMessage() const {return _("Opened inset");}
|
||||
///
|
||||
virtual void Edit(int, int);
|
||||
virtual void Edit(BufferView *, int, int);
|
||||
///
|
||||
virtual unsigned char Editable() const;
|
||||
///
|
||||
@ -178,23 +180,24 @@ public:
|
||||
virtual unsigned char Editable() const;
|
||||
|
||||
/// may call ToggleLockedInsetCursor
|
||||
virtual void ToggleInsetCursor();
|
||||
virtual void ToggleInsetCursor(BufferView *);
|
||||
///
|
||||
virtual void GetCursorPos(int &, int &) const {}
|
||||
///
|
||||
virtual void InsetButtonPress(int x, int y, int button);
|
||||
virtual void InsetButtonPress(BufferView *, int x, int y, int button);
|
||||
///
|
||||
virtual void InsetButtonRelease(int x, int y, int button);
|
||||
virtual void InsetButtonRelease(BufferView *,
|
||||
int x, int y, int button);
|
||||
|
||||
///
|
||||
virtual void InsetKeyPress(XKeyEvent * ev);
|
||||
///
|
||||
virtual void InsetMotionNotify(int x, int y, int state);
|
||||
virtual void InsetMotionNotify(BufferView *, int x, int y, int state);
|
||||
///
|
||||
virtual void InsetUnlock();
|
||||
virtual void InsetUnlock(BufferView *);
|
||||
|
||||
/// An updatable inset could handle lyx editing commands
|
||||
virtual bool LocalDispatch(int, char const *) { return false; };
|
||||
virtual bool LocalDispatch(BufferView *, int, char const *) { return false; };
|
||||
//
|
||||
bool isCursorVisible() const { return cursor_visible; }
|
||||
protected:
|
||||
|
@ -279,7 +279,7 @@ void SetUpdateTimer(float time)
|
||||
void MenuWrite(Buffer * buffer)
|
||||
{
|
||||
XFlush(fl_display);
|
||||
if (!bufferlist.write(buffer, lyxrc->make_backup)) {
|
||||
if (!buffer->save(lyxrc->make_backup)) {
|
||||
string fname = buffer->fileName();
|
||||
string s = MakeAbsPath(fname);
|
||||
if (AskQuestion(_("Save failed. Rename and try again?"),
|
||||
@ -3142,7 +3142,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
|
||||
InsetFig * new_inset = new InsetFig(100, 20, buffer);
|
||||
current_view->insertInset(new_inset);
|
||||
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
|
||||
new_inset->Edit(0, 0);
|
||||
new_inset->Edit(current_view, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3191,7 +3191,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
|
||||
|
||||
Inset * new_inset = new InsetFig(100, 100, buffer);
|
||||
current_view->insertInset(new_inset);
|
||||
new_inset->Edit(0, 0);
|
||||
new_inset->Edit(current_view, 0, 0);
|
||||
current_view->update(0);
|
||||
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
|
||||
current_view->text->UnFreezeUndo();
|
||||
|
@ -1095,6 +1095,17 @@ bool LyXFont::equalExceptLatex(LyXFont const & f) const
|
||||
}
|
||||
|
||||
|
||||
LyXDirection LyXFont::getFontDirection() const
|
||||
{
|
||||
if (lyxrc->rtl_support
|
||||
&& direction() == LyXFont::RTL_DIR
|
||||
&& latex() != LyXFont::ON)
|
||||
return LYX_DIR_RIGHT_TO_LEFT;
|
||||
else
|
||||
return LYX_DIR_LEFT_TO_RIGHT;
|
||||
}
|
||||
|
||||
|
||||
ostream & operator<<(ostream & o, LyXFont::FONT_MISC_STATE fms)
|
||||
{
|
||||
return o << int(fms);
|
||||
|
@ -528,7 +528,7 @@ string LyXFunc::Dispatch(int ac,
|
||||
owner->view()->menuUndo();
|
||||
inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
|
||||
if (inset)
|
||||
inset->Edit(slx, sly);
|
||||
inset->Edit(owner->view(), slx, sly);
|
||||
return string();
|
||||
} else
|
||||
if (action == LFUN_REDO) {
|
||||
@ -539,10 +539,11 @@ string LyXFunc::Dispatch(int ac,
|
||||
owner->view()->menuRedo();
|
||||
inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
|
||||
if (inset)
|
||||
inset->Edit(slx, sly);
|
||||
inset->Edit(owner->view(),
|
||||
slx, sly);
|
||||
return string();
|
||||
} else
|
||||
if (owner->view()->the_locking_inset->LocalDispatch(action, argument.c_str()))
|
||||
if (owner->view()->the_locking_inset->LocalDispatch(owner->view(), action, argument.c_str()))
|
||||
return string();
|
||||
else {
|
||||
setMessage(N_("Text mode"));
|
||||
@ -702,7 +703,16 @@ string LyXFunc::Dispatch(int ac,
|
||||
break;
|
||||
|
||||
case LFUN_MENUWRITE:
|
||||
owner->getMiniBuffer()->Set(_("Saving document"),
|
||||
MakeDisplayPath(owner->buffer()->fileName()),
|
||||
"...");
|
||||
MenuWrite(owner->buffer());
|
||||
//owner->getMiniBuffer()->
|
||||
// Set(_("Document saved as"),
|
||||
// MakeDisplayPath(owner->buffer()->fileName()));
|
||||
//} else {
|
||||
//owner->getMiniBuffer()->Set(_("Save failed!"));
|
||||
//}
|
||||
break;
|
||||
|
||||
case LFUN_MENUWRITEAS:
|
||||
@ -1275,7 +1285,7 @@ string LyXFunc::Dispatch(int ac,
|
||||
|
||||
case LFUN_SPELLCHECK:
|
||||
if (lyxrc->isp_command != "none")
|
||||
ShowSpellChecker();
|
||||
ShowSpellChecker(owner->view());
|
||||
break; // RVDK_PATCH_5
|
||||
|
||||
// --- Cursor Movements -----------------------------
|
||||
@ -1296,7 +1306,7 @@ string LyXFunc::Dispatch(int ac,
|
||||
&& tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == 2){
|
||||
Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
|
||||
setMessage(tmpinset->EditMessage());
|
||||
tmpinset->Edit(0, 0);
|
||||
tmpinset->Edit(owner->view(), 0, 0);
|
||||
break;
|
||||
}
|
||||
if (direction == LYX_DIR_LEFT_TO_RIGHT)
|
||||
@ -1324,7 +1334,8 @@ string LyXFunc::Dispatch(int ac,
|
||||
&& txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == 2) {
|
||||
Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
|
||||
setMessage(tmpinset->EditMessage());
|
||||
tmpinset->Edit(tmpinset->width(owner->view()->painter(),
|
||||
tmpinset->Edit(owner->view(),
|
||||
tmpinset->width(owner->view()->painter(),
|
||||
txt->GetFont(txt->cursor.par,
|
||||
txt->cursor.pos)), 0);
|
||||
break;
|
||||
@ -1883,7 +1894,7 @@ string LyXFunc::Dispatch(int ac,
|
||||
else
|
||||
new_inset = new InsetUrl("url", "", "");
|
||||
owner->view()->insertInset(new_inset);
|
||||
new_inset->Edit(0, 0);
|
||||
new_inset->Edit(owner->view(), 0, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1980,22 +1991,6 @@ string LyXFunc::Dispatch(int ac,
|
||||
|
||||
// Recenter screen
|
||||
owner->view()->center();
|
||||
#if 0
|
||||
owner->view()->beforeChange();
|
||||
if (owner->view()->text->cursor.y >
|
||||
owner->view()->getWorkArea()->height() / 2
|
||||
) {
|
||||
owner->view()->getScreen()->
|
||||
Draw(owner->view()->text->cursor.y -
|
||||
owner->view()->getWorkArea()->height() / 2
|
||||
);
|
||||
} else { // <=
|
||||
owner->view()->getScreen()->
|
||||
Draw(0);
|
||||
}
|
||||
owner->view()->update(0);
|
||||
owner->view()->redraw();
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2124,7 +2119,9 @@ string LyXFunc::Dispatch(int ac,
|
||||
owner->view()->
|
||||
open_new_inset(new InsetFormula(false));
|
||||
owner->view()->
|
||||
the_locking_inset->LocalDispatch(action, argument.c_str());
|
||||
the_locking_inset->LocalDispatch(owner->view(),
|
||||
action,
|
||||
argument.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2190,7 +2187,7 @@ string LyXFunc::Dispatch(int ac,
|
||||
owner->view()->insertInset(new_inset);
|
||||
} else {
|
||||
owner->view()->insertInset(new_inset);
|
||||
new_inset->Edit(0, 0);
|
||||
new_inset->Edit(owner->view(), 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2211,7 +2208,7 @@ string LyXFunc::Dispatch(int ac,
|
||||
|
||||
owner->view()->insertInset(new_inset);
|
||||
if (lsarg.empty()) {
|
||||
new_inset->Edit(0, 0);
|
||||
new_inset->Edit(owner->view(), 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2277,7 +2274,7 @@ string LyXFunc::Dispatch(int ac,
|
||||
|
||||
//don't edit it if the call was to INSERT_LAST
|
||||
if(action != LFUN_INDEX_INSERT_LAST) {
|
||||
new_inset->Edit(0, 0);
|
||||
new_inset->Edit(owner->view(), 0, 0);
|
||||
} else {
|
||||
//it looks blank on the screen unless
|
||||
//we do something. put it here.
|
||||
@ -2315,7 +2312,7 @@ string LyXFunc::Dispatch(int ac,
|
||||
Inset * new_inset = new InsetInclude(argument,
|
||||
owner->buffer());
|
||||
owner->view()->insertInset(new_inset, "Standard", true);
|
||||
new_inset->Edit(0, 0);
|
||||
new_inset->Edit(owner->view(), 0, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -179,5 +179,11 @@ struct pushpophelper {
|
||||
}
|
||||
LyXLex & lex;
|
||||
};
|
||||
// To avoid wrong usage:
|
||||
// pushpophelper(...); // wrong
|
||||
// pushpophelper pph(...); // right
|
||||
// we add this macro:
|
||||
#define pushpophelper(x, y, z) unnamed_pushpophelper;
|
||||
// Tip gotten from Bobby Schmidt's column in C/C++ Users Journal
|
||||
|
||||
#endif
|
||||
|
@ -131,7 +131,7 @@ public:
|
||||
LyXDirection getLetterDirection(size_type pos) const;
|
||||
|
||||
///
|
||||
void writeFile(ostream &, BufferParams &, char, char);
|
||||
void writeFile(ostream &, BufferParams const &, char, char) const;
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
class Buffer;
|
||||
class BufferParams;
|
||||
//class LyXScreen;
|
||||
class Row;
|
||||
class BufferView;
|
||||
|
||||
|
@ -43,7 +43,6 @@ extern void UpdateInset(BufferView *, Inset * inset, bool mark_dirty = true);
|
||||
|
||||
extern char * mathed_label;
|
||||
|
||||
extern BufferView * current_view;
|
||||
extern char const * latex_special_chars;
|
||||
|
||||
short greek_kb_flag = 0;
|
||||
@ -456,12 +455,12 @@ void InsetFormula::draw(Painter & pain, LyXFont const &,
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::Edit(int x, int y)
|
||||
void InsetFormula::Edit(BufferView * bv, int x, int y)
|
||||
{
|
||||
mathcursor = new MathedCursor(par);
|
||||
current_view->lockInset(this);
|
||||
bv->lockInset(this);
|
||||
par->Metrics();
|
||||
UpdateInset(current_view, this, false);
|
||||
UpdateInset(bv, this, false);
|
||||
x += par->xo;
|
||||
y += par->yo;
|
||||
mathcursor->SetPos(x, y);
|
||||
@ -470,26 +469,26 @@ void InsetFormula::Edit(int x, int y)
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::InsetUnlock()
|
||||
void InsetFormula::InsetUnlock(BufferView * bv)
|
||||
{
|
||||
if (mathcursor) {
|
||||
if (mathcursor->InMacroMode()) {
|
||||
mathcursor->MacroModeClose();
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
}
|
||||
delete mathcursor;
|
||||
}
|
||||
mathcursor = 0;
|
||||
UpdateInset(current_view, this, false);
|
||||
UpdateInset(bv, this, false);
|
||||
}
|
||||
|
||||
|
||||
// Now a symbol can be inserted only if the inset is locked
|
||||
void InsetFormula::InsertSymbol(char const * s)
|
||||
void InsetFormula::InsertSymbol(BufferView * bv, char const * s)
|
||||
{
|
||||
if (!s || !mathcursor) return;
|
||||
mathcursor->Interpret(s);
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
}
|
||||
|
||||
|
||||
@ -500,7 +499,7 @@ void InsetFormula::GetCursorPos(int& x, int& y) const
|
||||
y -= par->yo;
|
||||
}
|
||||
|
||||
void InsetFormula::ToggleInsetCursor()
|
||||
void InsetFormula::ToggleInsetCursor(BufferView * bv)
|
||||
{
|
||||
if (!mathcursor)
|
||||
return;
|
||||
@ -514,39 +513,39 @@ void InsetFormula::ToggleInsetCursor()
|
||||
int desc = font.maxDescent();
|
||||
|
||||
if (cursor_visible)
|
||||
current_view->hideLockedInsetCursor();
|
||||
bv->hideLockedInsetCursor();
|
||||
else
|
||||
current_view->showLockedInsetCursor(x, y, asc, desc);
|
||||
bv->showLockedInsetCursor(x, y, asc, desc);
|
||||
cursor_visible = !cursor_visible;
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::ShowInsetCursor()
|
||||
void InsetFormula::ShowInsetCursor(BufferView * bv)
|
||||
{
|
||||
if (!cursor_visible) {
|
||||
int x, y, asc, desc;
|
||||
if (mathcursor) {
|
||||
int x, y;
|
||||
mathcursor->GetPos(x, y);
|
||||
// x -= par->xo;
|
||||
y -= par->yo;
|
||||
LyXFont font = WhichFont(LM_TC_TEXTRM, LM_ST_TEXT);
|
||||
asc = font.maxAscent();
|
||||
desc = font.maxDescent();
|
||||
current_view->fitLockedInsetCursor(x, y, asc, desc);
|
||||
int asc = font.maxAscent();
|
||||
int desc = font.maxDescent();
|
||||
bv->fitLockedInsetCursor(x, y, asc, desc);
|
||||
}
|
||||
ToggleInsetCursor();
|
||||
ToggleInsetCursor(bv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::HideInsetCursor()
|
||||
void InsetFormula::HideInsetCursor(BufferView * bv)
|
||||
{
|
||||
if (cursor_visible)
|
||||
ToggleInsetCursor();
|
||||
ToggleInsetCursor(bv);
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::ToggleInsetSelection()
|
||||
void InsetFormula::ToggleInsetSelection(BufferView * bv)
|
||||
{
|
||||
if (!mathcursor)
|
||||
return;
|
||||
@ -559,7 +558,7 @@ void InsetFormula::ToggleInsetSelection()
|
||||
// x -= par->xo;
|
||||
// y -= par->yo;
|
||||
|
||||
UpdateInset(current_view, this, false);
|
||||
UpdateInset(bv, this, false);
|
||||
|
||||
}
|
||||
|
||||
@ -634,59 +633,62 @@ string InsetFormula::getLabel(int il) const
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::UpdateLocal()
|
||||
void InsetFormula::UpdateLocal(BufferView * bv)
|
||||
{
|
||||
par->Metrics(); // To inform lyx kernel the exact size
|
||||
// (there were problems with arrays).
|
||||
UpdateInset(current_view, this);
|
||||
UpdateInset(bv, this);
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::InsetButtonRelease(int x, int y, int /*button*/)
|
||||
void InsetFormula::InsetButtonRelease(BufferView * bv,
|
||||
int x, int y, int /*button*/)
|
||||
{
|
||||
HideInsetCursor();
|
||||
HideInsetCursor(bv);
|
||||
x += par->xo;
|
||||
y += par->yo;
|
||||
mathcursor->SetPos(x, y);
|
||||
ShowInsetCursor();
|
||||
ShowInsetCursor(bv);
|
||||
if (sel_flag) {
|
||||
sel_flag = false;
|
||||
sel_x = sel_y = 0;
|
||||
UpdateInset(current_view, this, false);
|
||||
UpdateInset(bv, this, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::InsetButtonPress(int x, int y, int /*button*/)
|
||||
void InsetFormula::InsetButtonPress(BufferView * bv,
|
||||
int x, int y, int /*button*/)
|
||||
{
|
||||
sel_flag = false;
|
||||
sel_x = x; sel_y = y;
|
||||
if (mathcursor->Selection()) {
|
||||
mathcursor->SelClear();
|
||||
UpdateInset(current_view, this, false);
|
||||
UpdateInset(bv, this, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::InsetMotionNotify(int x, int y, int /*button*/)
|
||||
void InsetFormula::InsetMotionNotify(BufferView * bv,
|
||||
int x, int y, int /*button*/)
|
||||
{
|
||||
if (sel_x && sel_y && abs(x-sel_x) > 4 && !sel_flag) {
|
||||
sel_flag = true;
|
||||
HideInsetCursor();
|
||||
HideInsetCursor(bv);
|
||||
mathcursor->SetPos(sel_x + par->xo, sel_y + par->yo);
|
||||
mathcursor->SelStart();
|
||||
ShowInsetCursor();
|
||||
ShowInsetCursor(bv);
|
||||
mathcursor->GetPos(sel_x, sel_y);
|
||||
} else
|
||||
if (sel_flag) {
|
||||
HideInsetCursor();
|
||||
HideInsetCursor(bv);
|
||||
x += par->xo;
|
||||
y += par->yo;
|
||||
mathcursor->SetPos(x, y);
|
||||
ShowInsetCursor();
|
||||
ShowInsetCursor(bv);
|
||||
mathcursor->GetPos(x, y);
|
||||
if (sel_x!= x || sel_y!= y)
|
||||
UpdateInset(current_view, this, false);
|
||||
UpdateInset(bv, this, false);
|
||||
sel_x = x; sel_y = y;
|
||||
}
|
||||
}
|
||||
@ -713,7 +715,7 @@ bool InsetFormula::SetNumber(bool numbf)
|
||||
}
|
||||
|
||||
|
||||
bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
|
||||
{
|
||||
// extern char *dispatch_result;
|
||||
MathedTextCodes varcode = LM_TC_MIN;
|
||||
@ -724,7 +726,7 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
bool result = true;
|
||||
static MathSpaceInset * sp= 0;
|
||||
|
||||
HideInsetCursor();
|
||||
HideInsetCursor(bv);
|
||||
|
||||
if (mathcursor->getLastCode() == LM_TC_TEX) {
|
||||
varcode = LM_TC_TEX;
|
||||
@ -761,40 +763,40 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
break;
|
||||
case LFUN_DELETE_LINE_FORWARD:
|
||||
//current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
current_view->lockedInsetStoreUndo(Undo::DELETE);
|
||||
bv->lockedInsetStoreUndo(Undo::DELETE);
|
||||
mathcursor->DelLine();
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
break;
|
||||
case LFUN_BREAKLINE:
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
mathcursor->Insert(' ', LM_TC_CR);
|
||||
par = mathcursor->GetPar();
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
break;
|
||||
case LFUN_TAB:
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
mathcursor->Insert(0, LM_TC_TAB);
|
||||
//UpdateInset(this);
|
||||
break;
|
||||
case LFUN_TABINSERT:
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
mathcursor->Insert('T', LM_TC_TAB);
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
break;
|
||||
case LFUN_BACKSPACE:
|
||||
if (!mathcursor->Left())
|
||||
break;
|
||||
|
||||
if (!mathcursor->InMacroMode() && mathcursor->pullArg()) {
|
||||
UpdateInset(current_view, this);
|
||||
UpdateInset(bv, this);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_DELETE:
|
||||
//current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
current_view->lockedInsetStoreUndo(Undo::DELETE);
|
||||
bv->lockedInsetStoreUndo(Undo::DELETE);
|
||||
mathcursor->Delete();
|
||||
UpdateInset(current_view, this);
|
||||
UpdateInset(bv, this);
|
||||
break;
|
||||
// case LFUN_GETXY:
|
||||
// sprintf(dispatch_buffer, "%d %d",);
|
||||
@ -814,11 +816,11 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
case LFUN_PASTE:
|
||||
if (was_macro)
|
||||
mathcursor->MacroModeClose();
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
mathcursor->SelPaste(); UpdateLocal(); break;
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
mathcursor->SelPaste(); UpdateLocal(bv); break;
|
||||
case LFUN_CUT:
|
||||
current_view->lockedInsetStoreUndo(Undo::DELETE);
|
||||
mathcursor->SelCut(); UpdateLocal(); break;
|
||||
bv->lockedInsetStoreUndo(Undo::DELETE);
|
||||
mathcursor->SelCut(); UpdateLocal(bv); break;
|
||||
case LFUN_COPY: mathcursor->SelCopy(); break;
|
||||
case LFUN_HOMESEL:
|
||||
case LFUN_ENDSEL:
|
||||
@ -844,7 +846,7 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
{
|
||||
if (!greek_kb_flag) {
|
||||
greek_kb_flag = 1;
|
||||
current_view->owner()->getMiniBuffer()->Set(_("Math greek mode on"));
|
||||
bv->owner()->getMiniBuffer()->Set(_("Math greek mode on"));
|
||||
} else
|
||||
greek_kb_flag = 0;
|
||||
break;
|
||||
@ -855,9 +857,9 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
{
|
||||
greek_kb_flag = (greek_kb_flag) ? 0 : 2;
|
||||
if (greek_kb_flag)
|
||||
current_view->owner()->getMiniBuffer()->Set(_("Math greek keyboard on"));
|
||||
bv->owner()->getMiniBuffer()->Set(_("Math greek keyboard on"));
|
||||
else
|
||||
current_view->owner()->getMiniBuffer()->Set(_("Math greek keyboard off"));
|
||||
bv->owner()->getMiniBuffer()->Set(_("Math greek keyboard off"));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -872,13 +874,13 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
{
|
||||
// varcode = LM_TC_TEX;
|
||||
mathcursor->setLastCode(LM_TC_TEX);
|
||||
current_view->owner()->getMiniBuffer()->Set(_("TeX mode"));
|
||||
bv->owner()->getMiniBuffer()->Set(_("TeX mode"));
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MATH_NUMBER:
|
||||
{
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
if (disp_flag) {
|
||||
short type = par->GetType();
|
||||
bool oldf = (type == LM_OT_PARN || type == LM_OT_MPARN);
|
||||
@ -887,13 +889,13 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
if (!label.empty()) {
|
||||
label.clear();
|
||||
}
|
||||
current_view->owner()->getMiniBuffer()->Set(_("No number"));
|
||||
bv->owner()->getMiniBuffer()->Set(_("No number"));
|
||||
} else {
|
||||
++type;
|
||||
current_view->owner()->getMiniBuffer()->Set(_("Number"));
|
||||
bv->owner()->getMiniBuffer()->Set(_("Number"));
|
||||
}
|
||||
par->SetType(type);
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -906,16 +908,16 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
// mt->SetNumbered(!mt->IsNumbered());
|
||||
|
||||
mathcursor->setNumbered();
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MATH_LIMITS:
|
||||
{
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
if (mathcursor->Limits())
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
}
|
||||
|
||||
case LFUN_MATH_SIZE:
|
||||
@ -923,20 +925,20 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
latexkeys * l = in_word_set (arg, strlen(arg));
|
||||
int sz = (l) ? l->id: -1;
|
||||
mathcursor->SetSize(sz);
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSERT_MATH:
|
||||
{
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
InsertSymbol(arg);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
InsertSymbol(bv, arg);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSERT_MATRIX:
|
||||
{
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
int k, m, n;
|
||||
char s[80], arg2[80];
|
||||
// This is just so that too long args won't ooze out of s.
|
||||
@ -955,14 +957,14 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
if (k > 2 && int(strlen(s)) > m)
|
||||
p->SetAlign(s[0], &s[1]);
|
||||
mathcursor->Insert(p, LM_TC_ACTIVE_INSET);
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MATH_DELIM:
|
||||
{
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
char lf[40], rg[40], arg2[40];
|
||||
int ilf = '(', irg = '.';
|
||||
latexkeys * l;
|
||||
@ -1000,23 +1002,23 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
|
||||
MathDelimInset * p = new MathDelimInset(ilf, irg);
|
||||
mathcursor->Insert(p, LM_TC_ACTIVE_INSET);
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_PROTECTEDSPACE:
|
||||
{
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
sp = new MathSpaceInset(1);
|
||||
mathcursor->Insert(sp);
|
||||
space_on = true;
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSERT_LABEL:
|
||||
{
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
if (par->GetType() < LM_OT_PAR) break;
|
||||
string lb = arg;
|
||||
if (lb.empty()) {
|
||||
@ -1036,7 +1038,7 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
//if (label.notEmpty()) delete label;
|
||||
label = lb;
|
||||
}
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
} else
|
||||
label.clear();
|
||||
break;
|
||||
@ -1044,16 +1046,16 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
|
||||
case LFUN_MATH_DISPLAY:
|
||||
//current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
current_view->lockedInsetStoreUndo(Undo::EDIT);
|
||||
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||
display(!disp_flag);
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
break;
|
||||
|
||||
// Invalid actions under math mode
|
||||
case LFUN_MATH_MODE:
|
||||
{
|
||||
if (mathcursor->getLastCode()!= LM_TC_TEXTRM) {
|
||||
current_view->owner()->getMiniBuffer()->Set(_("math text mode"));
|
||||
bv->owner()->getMiniBuffer()->Set(_("math text mode"));
|
||||
varcode = LM_TC_TEXTRM;
|
||||
} else {
|
||||
varcode = LM_TC_VAR;
|
||||
@ -1062,18 +1064,18 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
break;
|
||||
}
|
||||
case LFUN_UNDO:
|
||||
current_view->owner()->getMiniBuffer()->Set(_("Invalid action in math mode!"));
|
||||
bv->owner()->getMiniBuffer()->Set(_("Invalid action in math mode!"));
|
||||
break;
|
||||
|
||||
//------- dummy actions
|
||||
case LFUN_EXEC_COMMAND:
|
||||
current_view->owner()->getMiniBuffer()->ExecCommand();
|
||||
bv->owner()->getMiniBuffer()->ExecCommand();
|
||||
break;
|
||||
|
||||
default:
|
||||
if ((action == -1 || action == LFUN_SELFINSERT) && arg) {
|
||||
unsigned char c = arg[0];
|
||||
current_view->lockedInsetStoreUndo(Undo::INSERT);
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
|
||||
if (c == ' ' && mathcursor->getAccent() == LM_hat) {
|
||||
c = '^';
|
||||
@ -1168,10 +1170,10 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
if (c == '\\') {
|
||||
if (was_macro)
|
||||
mathcursor->MacroModeClose();
|
||||
current_view->owner()->getMiniBuffer()->Set(_("TeX mode"));
|
||||
bv->owner()->getMiniBuffer()->Set(_("TeX mode"));
|
||||
mathcursor->setLastCode(LM_TC_TEX);
|
||||
}
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
} else {
|
||||
// lyxerr << "Closed by action " << action << endl;
|
||||
result = false;
|
||||
@ -1180,15 +1182,15 @@ bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
if (was_macro != mathcursor->InMacroMode()
|
||||
&& action >= 0
|
||||
&& action != LFUN_BACKSPACE)
|
||||
UpdateLocal();
|
||||
UpdateLocal(bv);
|
||||
if (sp && !space_on) sp = 0;
|
||||
if (mathcursor->Selection() || was_selection)
|
||||
ToggleInsetSelection();
|
||||
ToggleInsetSelection(bv);
|
||||
|
||||
if (result)
|
||||
ShowInsetCursor();
|
||||
ShowInsetCursor(bv);
|
||||
else
|
||||
current_view->unlockInset(this);
|
||||
bv->unlockInset(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -72,37 +72,37 @@ public:
|
||||
/// what appears in the minibuffer when opening
|
||||
char const * EditMessage() const {return _("Math editor mode");}
|
||||
///
|
||||
void Edit(int x, int y);
|
||||
void Edit(BufferView *, int x, int y);
|
||||
///
|
||||
bool display() const { return (disp_flag) ? true: false; }
|
||||
///
|
||||
void display(bool);
|
||||
///
|
||||
void ToggleInsetCursor();
|
||||
void ToggleInsetCursor(BufferView *);
|
||||
///
|
||||
void ShowInsetCursor();
|
||||
void ShowInsetCursor(BufferView *);
|
||||
///
|
||||
void HideInsetCursor();
|
||||
void HideInsetCursor(BufferView *);
|
||||
///
|
||||
void GetCursorPos(int &, int &) const;
|
||||
///
|
||||
void ToggleInsetSelection();
|
||||
void ToggleInsetSelection(BufferView * bv);
|
||||
///
|
||||
void InsetButtonPress(int x, int y, int button);
|
||||
void InsetButtonPress(BufferView *, int x, int y, int button);
|
||||
///
|
||||
void InsetButtonRelease(int x, int y, int button);
|
||||
void InsetButtonRelease(BufferView *, int x, int y, int button);
|
||||
///
|
||||
void InsetKeyPress(XKeyEvent * ev);
|
||||
///
|
||||
void InsetMotionNotify(int x, int y, int state);
|
||||
void InsetMotionNotify(BufferView *, int x, int y, int state);
|
||||
///
|
||||
void InsetUnlock();
|
||||
void InsetUnlock(BufferView *);
|
||||
|
||||
/// To allow transparent use of math editing functions
|
||||
virtual bool LocalDispatch(int, char const *);
|
||||
virtual bool LocalDispatch(BufferView *, int, char const *);
|
||||
|
||||
///
|
||||
void InsertSymbol(char const *);
|
||||
void InsertSymbol(BufferView *, char const *);
|
||||
///
|
||||
bool SetNumber(bool);
|
||||
///
|
||||
@ -111,9 +111,9 @@ public:
|
||||
string getLabel(int) const;
|
||||
|
||||
protected:
|
||||
void UpdateLocal();
|
||||
void UpdateLocal(BufferView * bv);
|
||||
MathParInset * par;
|
||||
static MathedCursor* mathcursor;
|
||||
static MathedCursor * mathcursor;
|
||||
|
||||
private:
|
||||
bool disp_flag;
|
||||
|
@ -174,15 +174,15 @@ void InsetFormulaMacro::draw(Painter & pain, LyXFont const & f,
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaMacro::Edit(int x, int y)
|
||||
void InsetFormulaMacro::Edit(BufferView * bv, int x, int y)
|
||||
{
|
||||
opened = true;
|
||||
par = static_cast<MathParInset*>(tmacro->Clone());
|
||||
InsetFormula::Edit(x, y);
|
||||
InsetFormula::Edit(bv, x, y);
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaMacro::InsetUnlock()
|
||||
void InsetFormulaMacro::InsetUnlock(BufferView * bv)
|
||||
{
|
||||
opened = false;
|
||||
LyxArrayBase * tarray = tmacro->GetData();
|
||||
@ -190,24 +190,25 @@ void InsetFormulaMacro::InsetUnlock()
|
||||
it.Clear();
|
||||
tmacro->SetData(par->GetData());
|
||||
tmacro->setEditMode(false);
|
||||
InsetFormula::InsetUnlock();
|
||||
InsetFormula::InsetUnlock(bv);
|
||||
}
|
||||
|
||||
|
||||
bool InsetFormulaMacro::LocalDispatch(int action, char const * arg)
|
||||
bool InsetFormulaMacro::LocalDispatch(BufferView * bv,
|
||||
int action, char const * arg)
|
||||
{
|
||||
if (action == LFUN_MATH_MACROARG) {
|
||||
int i = atoi(arg) - 1;
|
||||
if (i >= 0 && i < tmacro->getNoArgs()) {
|
||||
mathcursor->Insert(tmacro->getMacroPar(i), LM_TC_INSET);
|
||||
InsetFormula::UpdateLocal();
|
||||
InsetFormula::UpdateLocal(bv);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
tmacro->setEditMode(true);
|
||||
tmacro->Metrics();
|
||||
bool result = InsetFormula::LocalDispatch(action, arg);
|
||||
bool result = InsetFormula::LocalDispatch(bv, action, arg);
|
||||
tmacro->setEditMode(false);
|
||||
|
||||
return result;
|
||||
|
@ -61,14 +61,14 @@ public:
|
||||
/// what appears in the minibuffer when opening
|
||||
char const * EditMessage() const {return _("Math macro editor mode");}
|
||||
///
|
||||
void Edit(int x, int y);
|
||||
void Edit(BufferView *, int x, int y);
|
||||
///
|
||||
void InsetUnlock();
|
||||
void InsetUnlock(BufferView *);
|
||||
///
|
||||
bool LocalDispatch(int, char const *);
|
||||
bool LocalDispatch(BufferView *, int, char const *);
|
||||
protected:
|
||||
///
|
||||
void UpdateLocal();
|
||||
//void UpdateLocal();
|
||||
private:
|
||||
///
|
||||
bool opened;
|
||||
|
@ -371,11 +371,11 @@ void math_insert_symbol(char const * s)
|
||||
current_view->beforeChange();
|
||||
current_view->insertInset(new_inset);
|
||||
// Update(1);//BUG
|
||||
new_inset->Edit(0, 0);
|
||||
new_inset->InsertSymbol(s);
|
||||
new_inset->Edit(current_view, 0, 0);
|
||||
new_inset->InsertSymbol(current_view, s);
|
||||
} else
|
||||
if (current_view->the_locking_inset->LyxCode() == Inset::MATH_CODE)
|
||||
static_cast<InsetFormula*>(current_view->the_locking_inset)->InsertSymbol(s);
|
||||
static_cast<InsetFormula*>(current_view->the_locking_inset)->InsertSymbol(current_view, s);
|
||||
else
|
||||
lyxerr << "Math error: attempt to write on a wrong "
|
||||
"class of inset." << endl;
|
||||
|
@ -112,11 +112,10 @@ LyXParagraph::LyXParagraph(LyXParagraph * par)
|
||||
}
|
||||
|
||||
|
||||
void LyXParagraph::writeFile(ostream & os, BufferParams & params,
|
||||
char footflag, char dth)
|
||||
void LyXParagraph::writeFile(ostream & os, BufferParams const & params,
|
||||
char footflag, char dth) const
|
||||
{
|
||||
LyXFont font1, font2;
|
||||
Inset * inset;
|
||||
int column = 0;
|
||||
int h = 0;
|
||||
char c = 0;
|
||||
@ -257,7 +256,8 @@ void LyXParagraph::writeFile(ostream & os, BufferParams & params,
|
||||
c = GetChar(i);
|
||||
switch (c) {
|
||||
case META_INSET:
|
||||
inset = GetInset(i);
|
||||
{
|
||||
Inset const * inset = GetInset(i);
|
||||
if (inset)
|
||||
if (inset->DirectWrite()) {
|
||||
// international char, let it write
|
||||
@ -270,7 +270,8 @@ void LyXParagraph::writeFile(ostream & os, BufferParams & params,
|
||||
os << "\n\\end_inset \n\n";
|
||||
column = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case META_NEWLINE:
|
||||
os << "\n\\newline \n";
|
||||
column = 0;
|
||||
@ -1892,7 +1893,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(string & file, TexRow & texrow,
|
||||
further_blank_line = true;
|
||||
}
|
||||
if (added_space_top.kind() != VSpace::NONE) {
|
||||
file += added_space_top.asLatexCommand();
|
||||
file += added_space_top.asLatexCommand(current_view->buffer()->params);
|
||||
further_blank_line = true;
|
||||
}
|
||||
|
||||
@ -2020,7 +2021,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(string & file, TexRow & texrow,
|
||||
}
|
||||
|
||||
if (added_space_bottom.kind() != VSpace::NONE) {
|
||||
file += added_space_bottom.asLatexCommand();
|
||||
file += added_space_bottom.asLatexCommand(current_view->buffer()->params);
|
||||
further_blank_line = true;
|
||||
}
|
||||
|
||||
@ -3971,3 +3972,34 @@ bool LyXParagraph::IsWord(size_type pos ) const
|
||||
{
|
||||
return IsWordChar(GetChar(pos)) ;
|
||||
}
|
||||
|
||||
|
||||
LyXDirection LyXParagraph::getParDirection() const
|
||||
{
|
||||
if (!lyxrc->rtl_support || table)
|
||||
return LYX_DIR_LEFT_TO_RIGHT;
|
||||
|
||||
if (size() > 0)
|
||||
return (getFont(0).direction() == LyXFont::RTL_DIR)
|
||||
? LYX_DIR_RIGHT_TO_LEFT : LYX_DIR_LEFT_TO_RIGHT;
|
||||
else
|
||||
return current_view->buffer()->params.getDocumentDirection();
|
||||
}
|
||||
|
||||
|
||||
LyXDirection
|
||||
LyXParagraph::getLetterDirection(LyXParagraph::size_type pos) const
|
||||
{
|
||||
if (!lyxrc->rtl_support)
|
||||
return LYX_DIR_LEFT_TO_RIGHT;
|
||||
|
||||
LyXDirection direction = getFont(pos).getFontDirection();
|
||||
if (IsLineSeparator(pos) && 0 < pos && pos < Last() - 1
|
||||
&& !IsLineSeparator(pos + 1)
|
||||
&& !(table && IsNewline(pos + 1))
|
||||
&& (getFont(pos - 1).getFontDirection() != direction
|
||||
|| getFont(pos + 1).getFontDirection() != direction))
|
||||
return getParDirection();
|
||||
else
|
||||
return direction;
|
||||
}
|
||||
|
@ -49,8 +49,7 @@
|
||||
#include "debug.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
extern LyXRC *lyxrc;
|
||||
extern BufferView *current_view;
|
||||
extern LyXRC * lyxrc;
|
||||
|
||||
// Spellchecker status
|
||||
enum {
|
||||
@ -62,7 +61,7 @@ enum {
|
||||
ISP_IGNORE
|
||||
};
|
||||
|
||||
static bool RunSpellChecker(string const &);
|
||||
static bool RunSpellChecker(BufferView * bv);
|
||||
|
||||
static FILE *in, *out; /* streams to communicate with ispell */
|
||||
pid_t isp_pid = -1; // pid for the `ispell' process. Also used (RO) in
|
||||
@ -224,7 +223,7 @@ void SpellCheckerOptions()
|
||||
// Could also use a clean up. (Asger Alstrup)
|
||||
|
||||
static
|
||||
void create_ispell_pipe(string const & lang)
|
||||
void create_ispell_pipe(BufferParams const & params, string const & lang)
|
||||
{
|
||||
static char o_buf[BUFSIZ]; // jc: it could be smaller
|
||||
int pipein[2], pipeout[2];
|
||||
@ -325,13 +324,13 @@ void create_ispell_pipe(string const & lang)
|
||||
argv[argc++] = tmp;
|
||||
}
|
||||
if (lyxrc->isp_use_input_encoding &&
|
||||
current_view->buffer()->params.inputenc != "default") {
|
||||
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->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';
|
||||
tmp = new char[params.inputenc.length() + 1];
|
||||
params.inputenc.copy(tmp, params.inputenc.length());
|
||||
tmp[params.inputenc.length()] = '\0';
|
||||
argv[argc++] = tmp;
|
||||
}
|
||||
|
||||
@ -520,13 +519,13 @@ inline void ispell_store_replacement(char const *mis, string const & cor) {
|
||||
}
|
||||
|
||||
|
||||
void ShowSpellChecker()
|
||||
void ShowSpellChecker(BufferView * bv)
|
||||
{
|
||||
FL_OBJECT *obj;
|
||||
FL_OBJECT * obj;
|
||||
int ret;
|
||||
|
||||
// Exit if we don't have a document open
|
||||
if (!current_view->available())
|
||||
if (!bv->available())
|
||||
return;
|
||||
|
||||
if (fd_form_spell_check == 0) {
|
||||
@ -588,7 +587,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->buffer()->isReadonly()) {
|
||||
if (!bv->buffer()->isReadonly()) {
|
||||
fl_activate_object(fd_form_spell_check->replace);
|
||||
fl_set_object_lcol(fd_form_spell_check->replace, FL_BLACK);
|
||||
}
|
||||
@ -599,7 +598,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->buffer()->GetLanguage());
|
||||
ret = RunSpellChecker(bv);
|
||||
|
||||
// deactivate insert, accept, replace, and stop
|
||||
fl_deactivate_object(fd_form_spell_check->insert);
|
||||
@ -629,29 +628,26 @@ void ShowSpellChecker()
|
||||
if (obj == fd_form_spell_check->done) break;
|
||||
}
|
||||
fl_hide_form(fd_form_spell_check->form_spell_check);
|
||||
current_view->endOfSpellCheck();
|
||||
bv->endOfSpellCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Perform an ispell session
|
||||
static
|
||||
bool RunSpellChecker(string const & lang)
|
||||
bool RunSpellChecker(BufferView * bv)
|
||||
{
|
||||
isp_result *result;
|
||||
char *word;
|
||||
int i, oldval, clickline, newvalue;
|
||||
float newval;
|
||||
FL_OBJECT *obj;
|
||||
unsigned int word_count = 0;
|
||||
isp_result * result;
|
||||
int i, newvalue;
|
||||
FL_OBJECT * obj;
|
||||
|
||||
string tmp = (lyxrc->isp_use_alt_lang) ? lyxrc->isp_alt_lang:lang;
|
||||
string tmp = (lyxrc->isp_use_alt_lang) ? lyxrc->isp_alt_lang : bv->buffer()->GetLanguage();
|
||||
|
||||
oldval = 0; /* used for updating slider only when needed */
|
||||
newval = 0.0;
|
||||
int oldval = 0; /* used for updating slider only when needed */
|
||||
float newval = 0.0;
|
||||
|
||||
/* create ispell process */
|
||||
create_ispell_pipe(tmp);
|
||||
create_ispell_pipe(bv->buffer()->params, tmp);
|
||||
|
||||
if (isp_pid == -1) {
|
||||
fl_show_message(
|
||||
@ -668,8 +664,9 @@ bool RunSpellChecker(string const & lang)
|
||||
// Put ispell in terse mode to improve speed
|
||||
ispell_terse_mode();
|
||||
|
||||
unsigned int word_count = 0;
|
||||
while (true) {
|
||||
word = current_view->nextWord(newval);
|
||||
char * word = bv->nextWord(newval);
|
||||
if (word == 0) break;
|
||||
++word_count;
|
||||
|
||||
@ -703,7 +700,8 @@ bool RunSpellChecker(string const & lang)
|
||||
switch (result->flag) {
|
||||
case ISP_UNKNOWN:
|
||||
case ISP_MISSED:
|
||||
current_view->selectLastWord();
|
||||
{
|
||||
bv->selectLastWord();
|
||||
fl_set_object_label(fd_form_spell_check->text, word);
|
||||
fl_set_input(fd_form_spell_check->input, word);
|
||||
fl_clear_browser(fd_form_spell_check->browser);
|
||||
@ -711,7 +709,7 @@ bool RunSpellChecker(string const & lang)
|
||||
fl_add_browser_line(fd_form_spell_check->browser, result->misses[i]);
|
||||
}
|
||||
|
||||
clickline = -1;
|
||||
int clickline = -1;
|
||||
while (true) {
|
||||
obj = fl_do_forms();
|
||||
if (obj == fd_form_spell_check->insert) {
|
||||
@ -728,7 +726,7 @@ bool RunSpellChecker(string const & lang)
|
||||
if (obj == fd_form_spell_check->replace ||
|
||||
obj == fd_form_spell_check->input) {
|
||||
ispell_store_replacement(word, fl_get_input(fd_form_spell_check->input));
|
||||
current_view->replaceWord(fl_get_input(fd_form_spell_check->input));
|
||||
bv->replaceWord(fl_get_input(fd_form_spell_check->input));
|
||||
break;
|
||||
}
|
||||
if (obj == fd_form_spell_check->browser) {
|
||||
@ -737,7 +735,7 @@ bool RunSpellChecker(string const & lang)
|
||||
if (clickline ==
|
||||
fl_get_browser(fd_form_spell_check->browser)) {
|
||||
ispell_store_replacement(word, fl_get_input(fd_form_spell_check->input));
|
||||
current_view->replaceWord(fl_get_input(fd_form_spell_check->input));
|
||||
bv->replaceWord(fl_get_input(fd_form_spell_check->input));
|
||||
break;
|
||||
}
|
||||
clickline = fl_get_browser(fd_form_spell_check->browser);
|
||||
@ -760,6 +758,7 @@ bool RunSpellChecker(string const & lang)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
delete result;
|
||||
delete[] word;
|
||||
@ -787,19 +786,14 @@ bool RunSpellChecker(string const & lang)
|
||||
}
|
||||
|
||||
|
||||
//void sigchldhandler(int sig)
|
||||
void sigchldhandler(pid_t pid, int *status)
|
||||
void sigchldhandler(pid_t pid, int * status)
|
||||
{
|
||||
//int status ;
|
||||
|
||||
if (isp_pid>0)
|
||||
//if (waitpid(isp_pid, &status, WNOHANG) == isp_pid) {
|
||||
if (isp_pid > 0)
|
||||
if (pid == isp_pid) {
|
||||
isp_pid= -1;
|
||||
fcntl(isp_fd, F_SETFL, O_NONBLOCK); /* set the file descriptor
|
||||
to nonblocking so we can
|
||||
continue */
|
||||
}
|
||||
//sigchldchecker(sig);
|
||||
sigchldchecker(pid, status);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
/* These functions are defined in lyx_cb.C */
|
||||
|
||||
class BufferView;
|
||||
|
||||
/** MarkLastWord should only be used immidiately after NextWord().
|
||||
If you give control back to the user, you _have_ to call EndOfSpellCheck()
|
||||
@ -15,7 +16,7 @@
|
||||
|
||||
/** This function has to be implemented by the spell checker.
|
||||
It will show the spellcheker form*/
|
||||
void ShowSpellChecker();
|
||||
void ShowSpellChecker(BufferView *);
|
||||
///
|
||||
void SpellCheckerOptions();
|
||||
|
||||
|
76
src/text.C
76
src/text.C
@ -37,7 +37,6 @@ using std::min;
|
||||
|
||||
static const int LYX_PAPER_MARGIN = 20;
|
||||
|
||||
extern BufferView * current_view;
|
||||
extern LyXRC * lyxrc;
|
||||
|
||||
// ale070405
|
||||
@ -127,50 +126,7 @@ LyXParagraph::size_type LyXText::RowLast(Row const * row) const
|
||||
}
|
||||
|
||||
|
||||
LyXDirection BufferParams::getDocumentDirection() const
|
||||
{
|
||||
return (lyxrc->rtl_support && language == "hebrew")
|
||||
? LYX_DIR_RIGHT_TO_LEFT : LYX_DIR_LEFT_TO_RIGHT;
|
||||
}
|
||||
|
||||
LyXDirection LyXParagraph::getParDirection() const
|
||||
{
|
||||
if (!lyxrc->rtl_support || table)
|
||||
return LYX_DIR_LEFT_TO_RIGHT;
|
||||
|
||||
if (size() > 0)
|
||||
return (getFont(0).direction() == LyXFont::RTL_DIR)
|
||||
? LYX_DIR_RIGHT_TO_LEFT : LYX_DIR_LEFT_TO_RIGHT;
|
||||
else
|
||||
return current_view->buffer()->params.getDocumentDirection();
|
||||
}
|
||||
|
||||
LyXDirection LyXFont::getFontDirection() const
|
||||
{
|
||||
if (lyxrc->rtl_support
|
||||
&& direction() == LyXFont::RTL_DIR
|
||||
&& latex() != LyXFont::ON)
|
||||
return LYX_DIR_RIGHT_TO_LEFT;
|
||||
else
|
||||
return LYX_DIR_LEFT_TO_RIGHT;
|
||||
}
|
||||
|
||||
LyXDirection
|
||||
LyXParagraph::getLetterDirection(LyXParagraph::size_type pos) const
|
||||
{
|
||||
if (!lyxrc->rtl_support)
|
||||
return LYX_DIR_LEFT_TO_RIGHT;
|
||||
|
||||
LyXDirection direction = getFont(pos).getFontDirection();
|
||||
if (IsLineSeparator(pos) && 0 < pos && pos < Last() - 1
|
||||
&& !IsLineSeparator(pos + 1)
|
||||
&& !(table && IsNewline(pos + 1))
|
||||
&& (getFont(pos - 1).getFontDirection() != direction
|
||||
|| getFont(pos + 1).getFontDirection() != direction))
|
||||
return getParDirection();
|
||||
else
|
||||
return direction;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::ComputeBidiTables(Row * row) const
|
||||
@ -633,7 +589,7 @@ int LyXText::LeftMargin(Row const * row) const
|
||||
x += paperwidth *
|
||||
atoi(row->par->pextra_widthp.c_str()) / 100;
|
||||
} else if (!row->par->pextra_width.empty()) {
|
||||
int xx = VSpace(row->par->pextra_width).inPixels();
|
||||
int xx = VSpace(row->par->pextra_width).inPixels(owner_);
|
||||
|
||||
if (xx > paperwidth)
|
||||
xx = paperwidth * 80 / 100;
|
||||
@ -1259,13 +1215,13 @@ void LyXText::SetHeightOfRow(Row * row_ptr) const
|
||||
if (layout.isParagraph()
|
||||
&& firstpar->GetDepth() == 0
|
||||
&& firstpar->Previous())
|
||||
maxasc += parameters->getDefSkip().inPixels();
|
||||
maxasc += parameters->getDefSkip().inPixels(owner_);
|
||||
else if (firstpar->Previous()
|
||||
&& textclasslist.Style(parameters->textclass,
|
||||
firstpar->Previous()->GetLayout()).isParagraph()
|
||||
&& firstpar->Previous()->GetDepth() == 0)
|
||||
// is it right to use defskip here too? (AS)
|
||||
maxasc += parameters->getDefSkip().inPixels();
|
||||
maxasc += parameters->getDefSkip().inPixels(owner_);
|
||||
}
|
||||
|
||||
/* the paper margins */
|
||||
@ -1274,7 +1230,7 @@ void LyXText::SetHeightOfRow(Row * row_ptr) const
|
||||
|
||||
/* add the vertical spaces, that the user added */
|
||||
if (firstpar->added_space_top.kind() != VSpace::NONE)
|
||||
maxasc += int(firstpar->added_space_top.inPixels());
|
||||
maxasc += int(firstpar->added_space_top.inPixels(owner_));
|
||||
|
||||
/* do not forget the DTP-lines!
|
||||
* there height depends on the font of the nearest character */
|
||||
@ -1371,7 +1327,7 @@ void LyXText::SetHeightOfRow(Row * row_ptr) const
|
||||
|
||||
/* add the vertical spaces, that the user added */
|
||||
if (firstpar->added_space_bottom.kind() != VSpace::NONE)
|
||||
maxdesc += int(firstpar->added_space_bottom.inPixels());
|
||||
maxdesc += int(firstpar->added_space_bottom.inPixels(owner_));
|
||||
|
||||
/* do not forget the DTP-lines!
|
||||
* there height depends on the font of the nearest character */
|
||||
@ -1891,8 +1847,8 @@ void LyXText::TableFeatures(int feature) const
|
||||
return;
|
||||
}
|
||||
case LyXTable::DELETE_ROW:
|
||||
if (current_view->the_locking_inset)
|
||||
current_view->unlockInset(current_view->the_locking_inset);
|
||||
if (owner_->the_locking_inset)
|
||||
owner_->unlockInset(owner_->the_locking_inset);
|
||||
RemoveTableRow(&cursor);
|
||||
RedoParagraph();
|
||||
return;
|
||||
@ -1901,8 +1857,8 @@ void LyXText::TableFeatures(int feature) const
|
||||
LyXParagraph::size_type pos = 0;
|
||||
int cell_org = actCell;
|
||||
int cell = 0;
|
||||
if (current_view->the_locking_inset)
|
||||
current_view->unlockInset(current_view->the_locking_inset);
|
||||
if (owner_->the_locking_inset)
|
||||
owner_->unlockInset(owner_->the_locking_inset);
|
||||
do {
|
||||
if (!pos || (cursor.par->IsNewline(pos-1))){
|
||||
if (cursor.par->table->DeleteCellIfColumnIsDeleted(cell, cell_org)){
|
||||
@ -2487,7 +2443,7 @@ void LyXText::InsertChar(char c)
|
||||
* blank at the end of a row we have to force
|
||||
* a rebreak.*/
|
||||
|
||||
current_view->owner()->getMiniBuffer()
|
||||
owner_->owner()->getMiniBuffer()
|
||||
->Set(_("You cannot type two spaces this way. "
|
||||
" Please read the Tutorial."));
|
||||
#if 1
|
||||
@ -2514,9 +2470,9 @@ void LyXText::InsertChar(char c)
|
||||
&& cursor.par->Previous()->footnoteflag
|
||||
== LyXParagraph::OPEN_FOOTNOTE))) {
|
||||
if (cursor.pos == 0 )
|
||||
current_view->owner()->getMiniBuffer()->Set(_("You cannot insert a space at the beginning of a paragraph. Please read the Tutorial."));
|
||||
owner_->owner()->getMiniBuffer()->Set(_("You cannot insert a space at the beginning of a paragraph. Please read the Tutorial."));
|
||||
else
|
||||
current_view->owner()->getMiniBuffer()->Set(_("You cannot type two spaces this way. Please read the Tutorial."));
|
||||
owner_->owner()->getMiniBuffer()->Set(_("You cannot type two spaces this way. Please read the Tutorial."));
|
||||
charInserted();
|
||||
return;
|
||||
}
|
||||
@ -3742,7 +3698,7 @@ void LyXText::GetVisibleRow(int offset,
|
||||
}
|
||||
|
||||
/* think about user added space */
|
||||
y_top += int(row_ptr->par->added_space_top.inPixels());
|
||||
y_top += int(row_ptr->par->added_space_top.inPixels(owner_));
|
||||
|
||||
/* think about the parskip */
|
||||
/* some parskips VERY EASY IMPLEMENTATION */
|
||||
@ -3750,13 +3706,13 @@ void LyXText::GetVisibleRow(int offset,
|
||||
if (layout.latextype == LATEX_PARAGRAPH
|
||||
&& firstpar->GetDepth() == 0
|
||||
&& firstpar->Previous())
|
||||
y_top += parameters->getDefSkip().inPixels();
|
||||
y_top += parameters->getDefSkip().inPixels(owner_);
|
||||
else if (firstpar->Previous()
|
||||
&& textclasslist.Style(parameters->textclass,
|
||||
firstpar->Previous()->GetLayout()).latextype == LATEX_PARAGRAPH
|
||||
&& firstpar->Previous()->GetDepth() == 0)
|
||||
// is it right to use defskip here, too? (AS)
|
||||
y_top += parameters->getDefSkip().inPixels();
|
||||
y_top += parameters->getDefSkip().inPixels(owner_);
|
||||
}
|
||||
|
||||
if (row_ptr->par->line_top) { /* draw a top line */
|
||||
@ -3894,7 +3850,7 @@ void LyXText::GetVisibleRow(int offset,
|
||||
}
|
||||
|
||||
/* think about user added space */
|
||||
y_bottom -= int(firstpar->added_space_bottom.inPixels());
|
||||
y_bottom -= int(firstpar->added_space_bottom.inPixels(owner_));
|
||||
|
||||
if (firstpar->line_bottom) {
|
||||
/* draw a bottom line */
|
||||
|
18
src/text2.C
18
src/text2.C
@ -39,8 +39,6 @@
|
||||
|
||||
#define FIX_DOUBLE_SPACE 1
|
||||
|
||||
extern BufferView * current_view;
|
||||
|
||||
using std::copy;
|
||||
|
||||
LyXText::LyXText(BufferView * bv, int pw, Buffer * p)
|
||||
@ -342,9 +340,9 @@ void LyXText::ToggleFootnote()
|
||||
if (par->next
|
||||
&& par->next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
|
||||
OpenFootnote();
|
||||
current_view->owner()->getMiniBuffer()->Set(_("Opened float"));
|
||||
owner_->owner()->getMiniBuffer()->Set(_("Opened float"));
|
||||
} else {
|
||||
current_view->owner()->getMiniBuffer()->Set(_("Closed float"));
|
||||
owner_->owner()->getMiniBuffer()->Set(_("Closed float"));
|
||||
CloseFootnote();
|
||||
}
|
||||
}
|
||||
@ -353,16 +351,16 @@ void LyXText::ToggleFootnote()
|
||||
void LyXText::OpenStuff()
|
||||
{
|
||||
if (cursor.pos == 0 && cursor.par->bibkey){
|
||||
cursor.par->bibkey->Edit(0, 0);
|
||||
cursor.par->bibkey->Edit(owner_, 0, 0);
|
||||
}
|
||||
else if (cursor.pos < cursor.par->Last()
|
||||
&& cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
|
||||
&& cursor.par->GetInset(cursor.pos)->Editable()) {
|
||||
current_view->owner()->getMiniBuffer()
|
||||
owner_->owner()->getMiniBuffer()
|
||||
->Set(cursor.par->GetInset(cursor.pos)->EditMessage());
|
||||
if (cursor.par->GetInset(cursor.pos)->Editable() != 2)
|
||||
SetCursorParUndo();
|
||||
cursor.par->GetInset(cursor.pos)->Edit(0, 0);
|
||||
cursor.par->GetInset(cursor.pos)->Edit(owner_, 0, 0);
|
||||
} else {
|
||||
ToggleFootnote();
|
||||
}
|
||||
@ -380,7 +378,7 @@ void LyXText::CloseFootnote()
|
||||
|
||||
if (!par->next ||
|
||||
par->next->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) {
|
||||
current_view->owner()->getMiniBuffer()
|
||||
owner_->owner()->getMiniBuffer()
|
||||
->Set(_("Nothing to do"));
|
||||
return;
|
||||
}
|
||||
@ -1071,7 +1069,7 @@ void LyXText::ToggleFree(LyXFont const & font, bool toggleall)
|
||||
// If the mask is completely neutral, tell user
|
||||
if (font == LyXFont(LyXFont::ALL_IGNORE)) {
|
||||
// Could only happen with user style
|
||||
current_view->owner()->getMiniBuffer()
|
||||
owner_->owner()->getMiniBuffer()
|
||||
->Set(_("No font change defined. Use Character under"
|
||||
" the Layout menu to define font change."));
|
||||
return;
|
||||
@ -2963,7 +2961,7 @@ void LyXText::SetCursorIntern(LyXParagraph * par,
|
||||
current_font = cursor.par->GetFontSettings(cursor.pos);
|
||||
real_current_font = GetFont(cursor.par, cursor.pos);
|
||||
if (pos == 0 && par->size() == 0
|
||||
&& current_view->buffer()->params.getDocumentDirection() == LYX_DIR_RIGHT_TO_LEFT) {
|
||||
&& owner_->buffer()->params.getDocumentDirection() == LYX_DIR_RIGHT_TO_LEFT) {
|
||||
current_font.setDirection(LyXFont::RTL_DIR);
|
||||
real_current_font.setDirection(LyXFont::RTL_DIR);
|
||||
}
|
||||
|
11
src/vspace.C
11
src/vspace.C
@ -25,7 +25,6 @@
|
||||
#include "support/lstrings.h"
|
||||
|
||||
extern LyXRC * lyxrc;
|
||||
extern BufferView * current_view;
|
||||
|
||||
/* length units
|
||||
*/
|
||||
@ -467,12 +466,12 @@ string VSpace::asLyXCommand() const
|
||||
}
|
||||
|
||||
|
||||
string VSpace::asLatexCommand() const
|
||||
string VSpace::asLatexCommand(BufferParams const & params) const
|
||||
{
|
||||
switch (kin) {
|
||||
case NONE: return string();
|
||||
case DEFSKIP:
|
||||
return current_view->buffer()->params.getDefSkip().asLatexCommand();
|
||||
return params.getDefSkip().asLatexCommand(params);
|
||||
case SMALLSKIP: return kp ? "\\vspace*{\\smallskipamount}"
|
||||
: "\\smallskip{}";
|
||||
case MEDSKIP: return kp ? "\\vspace*{\\medskipamount}"
|
||||
@ -488,10 +487,10 @@ string VSpace::asLatexCommand() const
|
||||
}
|
||||
|
||||
|
||||
int VSpace::inPixels() const
|
||||
int VSpace::inPixels(BufferView * bv) const
|
||||
{
|
||||
// Height of a normal line in pixels (zoom factor considered)
|
||||
int height = current_view->text->DefaultHeight(); // [pixels]
|
||||
int height = bv->text->DefaultHeight(); // [pixels]
|
||||
|
||||
// Zoom factor specified by user in percent
|
||||
float const zoom = lyxrc->zoom / 100.0; // [percent]
|
||||
@ -506,7 +505,7 @@ int VSpace::inPixels() const
|
||||
case NONE: return 0;
|
||||
|
||||
case DEFSKIP:
|
||||
return current_view->buffer()->params.getDefSkip().inPixels();
|
||||
return bv->buffer()->params.getDefSkip().inPixels(bv);
|
||||
|
||||
// This is how the skips are normally defined by
|
||||
// LateX. But there should be some way to change
|
||||
|
11
src/vspace.h
11
src/vspace.h
@ -4,8 +4,8 @@
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright (C) 1995 1996 Matthias Ettrich
|
||||
* and the LyX Team.
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
@ -18,6 +18,9 @@
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
class BufferParams;
|
||||
class BufferView;
|
||||
|
||||
/// LyXLength Class
|
||||
class LyXLength {
|
||||
public:
|
||||
@ -197,9 +200,9 @@ public:
|
||||
///
|
||||
string asLyXCommand() const; // how it goes into the LyX file
|
||||
///
|
||||
string asLatexCommand() const;
|
||||
string asLatexCommand(BufferParams const & params) const;
|
||||
///
|
||||
int inPixels() const;
|
||||
int inPixels(BufferView * bv) const;
|
||||
private:
|
||||
///
|
||||
vspace_kind kin;
|
||||
|
Loading…
Reference in New Issue
Block a user