paragraph-spacing, redoparagraph in deleteemptyparagraphmechanism, got rid of some current_views

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@649 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-04-11 22:55:29 +00:00
parent 3df345c938
commit fe4e2a84c6
26 changed files with 529 additions and 317 deletions

View File

@ -1,3 +1,41 @@
2000-04-11 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/lyx_cb.[Ch]: made several functions take a BufferView* arg
instead of using current_view directly.
* src/lyxfunc.C (Dispatch): the paragraph-spacing implementation
* src/LyXAction.C (init): add the paragraph-spacing command.
* src/commandtags.h: add enum for LFUN_PARAGRAPH_SPACING
* src/buffer.C (parseSingleLyXformat2Token): read the paragraph spacing
* src/lyx_cb.C (CurrentState): output a string when the spacing is
different from the documents.
* src/text.C (SetHeightOfRow): take paragraph spacing into
account, paragraph spacing takes precedence over buffer spacing
(GetVisibleRow): ditto
* src/paragraph.C (writeFile): output the spacing parameter too.
(validate): set the correct features if spacing is used in the
paragraph.
(Clear): set spacing to default
(MakeSameLayout): spacing too
(HasSameLayout): spacing too
(SetLayout): spacing too
(TeXOnePar): output the spacing commands
* src/lyxparagraph.h: added a spacing variable for use with
per-paragraph spacing.
* src/Spacing.h: add a Default spacing and a method to check if
the current spacing is default. also added an operator==
* src/text2.C (DeleteEmptyParagraphMechanism): added a
RedoParagraphs.
2000-04-11 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/lyxserver.C (callback): fix dispatch of functions

View File

@ -192,7 +192,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
int selection = 0;
int mark_set = 0;
ProhibitInput();
ProhibitInput(bv_);
owner_->getMiniBuffer()->Set(_("Formatting document..."));
@ -251,7 +251,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
redraw();
owner_->getMiniBuffer()->Init();
bv_->setState();
AllowInput();
AllowInput(bv_);
// Now if the title form still exist kill it
TimerCB(0, 0);
@ -780,7 +780,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, unsigned int button)
if (button >= 2) return;
bv_->setState();
owner_->getMiniBuffer()->Set(CurrentState());
owner_->getMiniBuffer()->Set(CurrentState(bv_));
// Did we hit an editable inset?
if (inset_hit != 0) {

View File

@ -22,33 +22,24 @@ using std::pair;
static LyXParagraph * buf = 0;
CutAndPaste::CutAndPaste()
{
}
CutAndPaste::~CutAndPaste()
{
}
// for now here this should be in another Cut&Paste Class!
//
void CutAndPaste::DeleteBuffer()
{
if (!buf)
return;
LyXParagraph * tmppar;
while (buf) {
tmppar = buf;
buf = buf->next;
delete tmppar;
}
buf = 0;
if (!buf) return;
LyXParagraph * tmppar;
while (buf) {
tmppar = buf;
buf = buf->next;
delete tmppar;
}
buf = 0;
}
bool CutAndPaste::cutSelection(LyXParagraph *startpar, LyXParagraph **endpar,
bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar,
int start, int & end, char tc, bool doclear)
{
if (!startpar || (start > startpar->Last()))
@ -116,7 +107,8 @@ bool CutAndPaste::cutSelection(LyXParagraph *startpar, LyXParagraph **endpar,
return true;
}
bool CutAndPaste::copySelection(LyXParagraph *startpar, LyXParagraph *endpar,
bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar,
int start, int end, char tc)
{
if (!startpar || (start > startpar->Last()))
@ -156,7 +148,7 @@ bool CutAndPaste::copySelection(LyXParagraph *startpar, LyXParagraph *endpar,
// care about footnotes
if (buf->footnoteflag) {
tmppar = buf;
while (tmppar){
while (tmppar) {
tmppar->footnoteflag = LyXParagraph::NO_FOOTNOTE;
tmppar = tmppar->next;
}
@ -177,8 +169,9 @@ bool CutAndPaste::copySelection(LyXParagraph *startpar, LyXParagraph *endpar,
return true;
}
bool CutAndPaste::pasteSelection(LyXParagraph **par, LyXParagraph **endpar,
int &pos, char tc)
bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
int & pos, char tc)
{
if (!checkPastePossible(*par, pos))
return false;
@ -201,10 +194,10 @@ bool CutAndPaste::pasteSelection(LyXParagraph **par, LyXParagraph **endpar,
if (buf->IsNewline(0)){
while((tmppos < tmppar->Last()) &&
!tmppar->IsNewline(tmppos))
tmppos++;
++tmppos;
buf->Erase(0);
if (tmppos < tmppar->Last())
tmppos++;
++tmppos;
else
table_too_small = true;
} else {
@ -332,20 +325,21 @@ bool CutAndPaste::pasteSelection(LyXParagraph **par, LyXParagraph **endpar,
return true;
}
int CutAndPaste::nrOfParagraphs() const
{
if (!buf)
return 0;
if (!buf) return 0;
int n = 1;
LyXParagraph *tmppar = buf;
while(tmppar->next) {
++n;
tmppar = tmppar->next;
}
return n;
int n = 1;
LyXParagraph *tmppar = buf;
while(tmppar->next) {
++n;
tmppar = tmppar->next;
}
return n;
}
int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1,
LyXTextClassList::size_type c2,
LyXParagraph * par)
@ -385,17 +379,18 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1,
return ret;
}
char CutAndPaste::getBufferTextClass()
LyXTextClassList::size_type CutAndPaste::getBufferTextClass() const
{
return textclass;
}
bool CutAndPaste::checkPastePossible(LyXParagraph *par, int)
{
if (!buf)
return false;
LyXParagraph *tmppar;
bool CutAndPaste::checkPastePossible(LyXParagraph * par, int) const
{
if (!buf) return false;
LyXParagraph * tmppar;
// be carefull with footnotes in footnotes
if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {

View File

@ -22,32 +22,33 @@ class LyXParagraph;
///
class CutAndPaste {
public:
///
CutAndPaste();
~CutAndPaste();
bool cutSelection(LyXParagraph *startpar, LyXParagraph **endpar,
int start, int & end, char tc, bool doclear=false);
bool copySelection(LyXParagraph *startpar, LyXParagraph *endpar,
int start, int end, char tc);
bool pasteSelection(LyXParagraph **par, LyXParagraph **endpar,
int & pos, char tc);
int nrOfParagraphs() const;
/** needed to switch between different classes this works
for a list of paragraphs beginning with the specified par
return value is the number of wrong conversions
*/
int SwitchLayoutsBetweenClasses(LyXTextClassList::size_type class1,
LyXTextClassList::size_type class2,
LyXParagraph * par);
char getBufferTextClass();
bool checkPastePossible(LyXParagraph *, int pos);
///
bool cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar,
int start, int & end, char tc, bool doclear = false);
///
bool copySelection(LyXParagraph * startpar, LyXParagraph * endpar,
int start, int end, char tc);
///
bool pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
int & pos, char tc);
///
int nrOfParagraphs() const;
/** needed to switch between different classes this works
for a list of paragraphs beginning with the specified par
return value is the number of wrong conversions
*/
int SwitchLayoutsBetweenClasses(LyXTextClassList::size_type class1,
LyXTextClassList::size_type class2,
LyXParagraph * par);
///
LyXTextClassList::size_type getBufferTextClass() const;
///
bool checkPastePossible(LyXParagraph *, int pos) const;
private:
///
void DeleteBuffer();
///
char textclass;
///
void DeleteBuffer();
///
LyXTextClassList::size_type textclass;
};
#endif

View File

@ -112,11 +112,13 @@ string LaTeXFeatures::getPackages()
}
// setspace.sty
if ((params.spacing.getSpace() != Spacing::Single)
if ((params.spacing.getSpace() != Spacing::Single
&& !params.spacing.isDefault())
|| setspace) {
packages += "\\usepackage{setspace}\n";
}
switch (params.spacing.getSpace()) {
case Spacing::Default:
case Spacing::Single:
// we dont use setspace.sty so dont print anything
//packages += "\\singlespacing\n";

View File

@ -376,6 +376,7 @@ void LyXAction::init()
{ LFUN_LOWCASE_WORD, "word-lowcase", "", Noop },
{ LFUN_UPCASE_WORD, "word-upcase", "", Noop },
{ LFUN_DATE_INSERT, "date-insert", "", Noop },
{ LFUN_PARAGRAPH_SPACING, "paragraph-spacing", "", Noop },
{ LFUN_NOACTION, "", "", Noop }
};

View File

@ -56,13 +56,13 @@ void SendtoApplyCB(FL_OBJECT *, long)
Buffer * buffer = current_view->buffer();
if (fl_get_button(fd_form_sendto->radio_ftype_dvi) ||
fl_get_button(fd_form_sendto->radio_ftype_ps)) {
ProhibitInput();
ProhibitInput(current_view);
// Generate dvi file and check if there are errors in the .lyx file
if (MakeLaTeXOutput(buffer) > 0) {
AllowInput();
AllowInput(current_view);
return;
}
AllowInput();
AllowInput(current_view);
}
string ftypeext;
if (fl_get_button(fd_form_sendto->radio_ftype_lyx))

View File

@ -39,7 +39,7 @@ using std::endl;
extern FD_form_document * fd_form_document;
extern void AutoSave();
extern void AutoSave(BufferView *);
extern char updatetimer;
extern void QuitLyX();
LyXTextClass::size_type current_layout = 0;
@ -159,17 +159,19 @@ extern "C" void C_LyXView_UpdateTimerCB(FL_OBJECT * ob, long data)
// Callback for autosave timer
void LyXView::AutosaveTimerCB(FL_OBJECT *, long)
void LyXView::AutoSave()
{
lyxerr[Debug::INFO] << "Running AutoSave()" << endl;
AutoSave();
if (view()->available())
::AutoSave(view());
}
// Wrapper for the above
extern "C" void C_LyXView_AutosaveTimerCB(FL_OBJECT * ob, long data)
extern "C" void C_LyXView_AutosaveTimerCB(FL_OBJECT * ob, long)
{
LyXView::AutosaveTimerCB(ob, data);
LyXView * view = static_cast<LyXView*>(ob->u_vdata);
view->AutoSave();
}
@ -274,6 +276,7 @@ void LyXView::create_form_form_main(int width, int height)
// timer_autosave
fdui->timer_autosave = obj = fl_add_timer(FL_HIDDEN_TIMER,
0, 0, 0, 0, "Timer");
obj->u_vdata = this;
fl_set_object_callback(obj, C_LyXView_AutosaveTimerCB, 0);
// timer_update

View File

@ -128,7 +128,7 @@ public:
window manager. */
static int atCloseMainFormCB(FL_FORM *, void *);
/// A callback
static void AutosaveTimerCB(FL_OBJECT *, long);
void AutoSave();
/// A callback
static void UpdateTimerCB(FL_OBJECT *, long);
private:

View File

@ -9,6 +9,7 @@ using std::istringstream;
#endif
#include "Spacing.h"
#include "LString.h"
using std::ios;
using std::ostream;
@ -21,6 +22,7 @@ char const * spacing_string[] = {"single", "onehalf", "double", "other"};
float Spacing::getValue() const
{
switch(space) {
case Default: // nothing special should happen with this...
case Single: return 1.0;
case Onehalf: return 1.25;
case Double: return 1.667;
@ -57,14 +59,18 @@ void Spacing::set(Spacing::Space sp, char const * val)
}
void Spacing::writeFile(ostream & os) const
void Spacing::writeFile(ostream & os, bool para) const
{
if (space == Default) return;
string cmd = para ? "\\paragraph_spacing " : "\\spacing ";
if (getSpace() == Spacing::Other) {
os.setf(ios::showpoint|ios::fixed);
os.precision(2);
os << "\\spacing " << spacing_string[getSpace()]
os << cmd << spacing_string[getSpace()]
<< " " << getValue() << " \n";
} else {
os << "\\spacing " << spacing_string[getSpace()] << " \n";
os << cmd << spacing_string[getSpace()] << " \n";
}
}

View File

@ -26,12 +26,15 @@ public:
///
Double,
///
Other
Other,
///
Default
};
///
Spacing() {
space = Single;
value = getValue();
Spacing() : space(Single), value(1.0) {}
///
bool isDefault() const {
return space == Default;
}
///
float getValue() const;
@ -42,7 +45,13 @@ public:
///
void set(Spacing::Space sp, char const * val) ;
///
void writeFile(std::ostream &) const;
void writeFile(std::ostream &, bool para = false) const;
///
friend bool operator==(Spacing const & a, Spacing const & b) {
if (a.space == b.space && a.getValue() == b.getValue())
return true;
return false;
}
///
friend bool operator!=(Spacing const & a, Spacing const & b) {
if (a.space == b.space && a.getValue() == b.getValue())

View File

@ -304,7 +304,7 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par)
bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
LyXParagraph *& return_par,
const string & token, int & pos,
string const & token, int & pos,
char & depth, LyXFont & font,
LyXParagraph::footnote_flag & footnoteflag,
LyXParagraph::footnote_kind & footnotekind)
@ -373,7 +373,7 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
pos = 0;
lex.EatLine();
par->layout = LYX_DUMMY_LAYOUT;
font = LyXFont(LyXFont::ALL_INHERIT,params.language_info);
font = LyXFont(LyXFont::ALL_INHERIT, params.language_info);
if (format < 2.16 && params.language == "hebrew")
font.setLanguage(default_language);
} else if (token == "\\begin_float") {
@ -648,6 +648,22 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
} else {
lex.printError("Unknown spacing token: '$$Token'");
}
} else if (token == "\\paragraph_spacing") {
lex.next();
string tmp = strip(lex.GetString());
if (tmp == "single") {
par->spacing.set(Spacing::Single);
} else if (tmp == "onehalf") {
par->spacing.set(Spacing::Onehalf);
} else if (tmp == "double") {
par->spacing.set(Spacing::Double);
} else if (tmp == "other") {
lex.next();
par->spacing.set(Spacing::Other,
lex.GetFloat());
} else {
lex.printError("Unknown spacing token: '$$Token'");
}
} else if (token == "\\float_placement") {
lex.nextToken();
params.float_placement = lex.GetString();
@ -3233,7 +3249,7 @@ int Buffer::runLaTeX()
{
if (!users->text) return 0;
ProhibitInput();
ProhibitInput(users);
// get LaTeX-Filename
string name = getLatexName();
@ -3288,7 +3304,7 @@ int Buffer::runLaTeX()
users->fitCursor();
users->updateScrollbar();
}
AllowInput();
AllowInput(users);
return latex.getNumErrors();
}
@ -3298,7 +3314,7 @@ int Buffer::runLiterate()
{
if (!users->text) return 0;
ProhibitInput();
ProhibitInput(users);
// get LaTeX-Filename
string name = getLatexName();
@ -3359,7 +3375,7 @@ int Buffer::runLiterate()
users->fitCursor();
users->updateScrollbar();
}
AllowInput();
AllowInput(users);
return literate.getNumErrors();
}
@ -3369,7 +3385,7 @@ int Buffer::buildProgram()
{
if (!users->text) return 0;
ProhibitInput();
ProhibitInput(users);
// get LaTeX-Filename
string name = getLatexName();
@ -3429,7 +3445,7 @@ int Buffer::buildProgram()
users->fitCursor();
users->updateScrollbar();
}
AllowInput();
AllowInput(users);
return literate.getNumErrors();
}
@ -3442,7 +3458,7 @@ int Buffer::runChktex()
{
if (!users->text) return 0;
ProhibitInput();
ProhibitInput(users);
// get LaTeX-Filename
string name = getLatexName();
@ -3484,7 +3500,7 @@ int Buffer::runChktex()
users->fitCursor();
users->updateScrollbar();
}
AllowInput();
AllowInput(users);
return res;
}

View File

@ -262,7 +262,8 @@ public:
bool isLinuxDoc() const;
/// returns true if the buffer contains a DocBook document
bool isDocBook() const;
/// returns true if the buffer contains either a LinuxDoc or DocBook document
/** returns true if the buffer contains either a LinuxDoc
or DocBook document */
bool isSGML() const;
/// returns true if the buffer contains a Wed document
bool isLiterate() const;
@ -272,11 +273,12 @@ public:
/** Validate a buffer for LaTeX.
This validates the buffer, and returns a struct for use by
makeLaTeX and others. Its main use is to figure out what commands
and packages need to be included in the LaTeX file. It (should)
also check that the needed constructs are there (i.e. that the \refs
points to coresponding \labels). It should perhaps inset "error"
insets to help the user correct obvious mistakes.
makeLaTeX and others. Its main use is to figure out what
commands and packages need to be included in the LaTeX file.
It (should) also check that the needed constructs are there
(i.e. that the \refs points to coresponding \labels). It
should perhaps inset "error" insets to help the user correct
obvious mistakes.
*/
void validate(LaTeXFeatures &) const;

View File

@ -153,7 +153,7 @@ bool BufferList::close(Buffer * buf)
if (buf->getUser()) buf->getUser()->insetUnlock();
if (buf->paragraph && !buf->isLyxClean() && !quitting) {
ProhibitInput();
ProhibitInput(buf->getUser());
switch(AskConfirmation(_("Changes in document:"),
MakeDisplayPath(buf->fileName(), 50),
_("Save document?"))){
@ -161,15 +161,15 @@ bool BufferList::close(Buffer * buf)
if (buf->save()) {
lastfiles->newFile(buf->fileName());
} else {
AllowInput();
AllowInput(buf->getUser());
return false;
}
break;
case 3: // Cancel
AllowInput();
AllowInput(buf->getUser());
return false;
}
AllowInput();
AllowInput(buf->getUser());
}
bstore.release(buf);

View File

@ -133,7 +133,7 @@ public:
///
string fontsize;
///
LyXTextClassList::ClassList::size_type textclass;
LyXTextClassList::size_type textclass;
/* this are for the PaperLayout */
///

View File

@ -244,7 +244,8 @@ enum kb_action {
LFUN_INSET_ERT, // Jug 20000218
LFUN_INSERT_GRAPHICS, // Lgb 20000226
LFUN_INSET_FOOTNOTE, // Jug 20000307
LFUN_INSET_NUMBER, // Dekel 20000402
LFUN_INSET_NUMBER, // Dekel 20000402
LFUN_PARAGRAPH_SPACING, // Lgb 20000411
LFUN_LASTACTION /* this marks the end of the table */
};

View File

@ -58,6 +58,7 @@
#include "support/lyxlib.h"
#include "Painter.h"
#include "font.h"
#include "lyx_cb.h"
using std::ostream;
using std::istream;
@ -75,9 +76,6 @@ extern FL_OBJECT * figinset_canvas;
extern char ** environ; // is this only redundtant on linux systems? Lgb.
extern void ProhibitInput();
extern void AllowInput();
static float const DEG2PI = 57.295779513;
struct queue_element {
@ -2066,7 +2064,7 @@ void InsetFig::BrowseFile()
bool error = false;
do {
ProhibitInput();
ProhibitInput(current_view);
if (once) {
p = fileDlg.Select(_("EPS Figure"),
current_figure_path,
@ -2075,7 +2073,7 @@ void InsetFig::BrowseFile()
p = fileDlg.Select(_("EPS Figure"), buf,
"*ps", string());
}
AllowInput();
AllowInput(current_view);
if (p.empty()) return;

View File

@ -203,10 +203,10 @@ void ShowMessage(Buffer * buf,
// BufferViews. Or is it perhaps just the (input in) BufferViews in the
// current LyxView that should be prohibited (Lgb) (This applies to
// "AllowInput" as well.)
void ProhibitInput()
void ProhibitInput(BufferView * bv)
{
input_prohibited = true;
current_view->hideCursor();
bv->hideCursor();
static Cursor cursor;
static bool cursor_undefined = true;
@ -218,7 +218,7 @@ void ProhibitInput()
}
/* set the cursor to the watch for all forms and the canvas */
XDefineCursor(fl_display, current_view->owner()->getForm()->window,
XDefineCursor(fl_display, bv->owner()->getForm()->window,
cursor);
if (fd_form_paragraph->form_paragraph->visible)
XDefineCursor(fl_display,
@ -249,13 +249,13 @@ void SetXtermCursor(Window win)
}
void AllowInput()
void AllowInput(BufferView * bv)
{
input_prohibited = false;
/* reset the cursor from the watch for all forms and the canvas */
XUndefineCursor(fl_display, current_view->owner()->getForm()->window);
XUndefineCursor(fl_display, bv->owner()->getForm()->window);
if (fd_form_paragraph->form_paragraph->visible)
XUndefineCursor(fl_display,
fd_form_paragraph->form_paragraph->window);
@ -264,8 +264,8 @@ void AllowInput()
fd_form_character->form_character->window);
// What to do about this? (Lgb)
if (current_view->belowMouse())
SetXtermCursor(current_view->owner()->getForm()->window);
if (bv->belowMouse())
SetXtermCursor(bv->owner()->getForm()->window);
XFlush(fl_display);
fl_activate_all_forms();
@ -325,7 +325,7 @@ void MenuWriteAs(Buffer * buffer)
string oldname = fname;
LyXFileDlg fileDlg;
ProhibitInput();
ProhibitInput(current_view);
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
@ -336,7 +336,7 @@ void MenuWriteAs(Buffer * buffer)
OnlyPath(fname),
"*.lyx",
OnlyFilename(fname));
AllowInput();
AllowInput(current_view);
if (fname.empty()) {
return;
@ -587,11 +587,11 @@ bool CreatePostscript(Buffer * buffer, bool wait = false)
//if (!bv->text)
// return false;
ProhibitInput();
ProhibitInput(current_view);
// Generate dvi file
if (MakeLaTeXOutput(buffer) > 0) {
AllowInput();
AllowInput(current_view);
return false;
}
// Generate postscript file
@ -663,7 +663,7 @@ bool CreatePostscript(Buffer * buffer, bool wait = false)
}
Path p(path);
bool ret = RunScript(buffer, wait, command);
AllowInput();
AllowInput(current_view);
return ret;
}
@ -682,7 +682,7 @@ bool PreviewPostscript(Buffer * buffer)
}
// Start postscript viewer
ProhibitInput();
ProhibitInput(current_view);
string ps = ChangeExtension (buffer->fileName(),
".ps_tmp", true);
// push directorypath, if necessary
@ -692,7 +692,7 @@ bool PreviewPostscript(Buffer * buffer)
}
Path p(path);
bool ret = RunScript(buffer, false, lyxrc.view_ps_command, ps);
AllowInput();
AllowInput(current_view);
return ret;
}
@ -1096,26 +1096,26 @@ void QuitLyX()
void AutoSave()
void AutoSave(BufferView * bv)
// should probably be moved into BufferList (Lgb)
// Perfect target for a thread...
{
if (!current_view->available())
if (!bv->available())
return;
if (current_view->buffer()->isBakClean()
|| current_view->buffer()->isReadonly()) {
if (bv->buffer()->isBakClean()
|| bv->buffer()->isReadonly()) {
// We don't save now, but we'll try again later
current_view->owner()->resetAutosaveTimer();
bv->owner()->resetAutosaveTimer();
return;
}
current_view->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
bv->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
// create autosave filename
string fname = OnlyPath(current_view->buffer()->fileName());
string fname = OnlyPath(bv->buffer()->fileName());
fname += "#";
fname += OnlyFilename(current_view->buffer()->fileName());
fname += OnlyFilename(bv->buffer()->fileName());
fname += "#";
// tmp_ret will be located (usually) in /tmp
@ -1131,7 +1131,7 @@ void AutoSave()
// anyway.
bool failed = false;
if (!tmp_ret.empty()) {
current_view->buffer()->writeFile(tmp_ret, 1);
bv->buffer()->writeFile(tmp_ret, 1);
// assume successful write of tmp_ret
if (rename(tmp_ret.c_str(), fname.c_str()) == -1) {
failed = true;
@ -1146,11 +1146,11 @@ void AutoSave()
if (failed) {
// failed to write/rename tmp_ret so try writing direct
if (!current_view->buffer()->writeFile(fname, 1)) {
if (!bv->buffer()->writeFile(fname, 1)) {
// It is dangerous to do this in the child,
// but safe in the parent, so...
if (pid == -1)
current_view->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
bv->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
}
}
if (pid == 0) { // we are the child so...
@ -1158,8 +1158,8 @@ void AutoSave()
}
}
current_view->buffer()->markBakClean();
current_view->owner()->resetAutosaveTimer();
bv->buffer()->markBakClean();
bv->owner()->resetAutosaveTimer();
}
@ -1205,11 +1205,11 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
if (!bv->available()) return;
if (fname.empty()) {
ProhibitInput();
ProhibitInput(bv);
fname = fileDlg.Select(_("File to Insert"),
bv->owner()->buffer()->filepath,
"*");
AllowInput();
AllowInput(bv);
if (fname.empty()) return;
}
@ -1271,7 +1271,7 @@ void MenuShowTableOfContents()
void MenuInsertLabel(char const * arg)
{
string label = arg;
ProhibitInput();
ProhibitInput(current_view);
if (label.empty()) {
pair<bool, string>
result = askForText(_("Enter new label to insert:"));
@ -1284,7 +1284,7 @@ void MenuInsertLabel(char const * arg)
new_inset->setContents(label);
current_view->insertInset(new_inset);
}
AllowInput();
AllowInput(current_view);
}
@ -1390,7 +1390,7 @@ int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
default: /* nothing to be done yet ;-) */ break;
}
ProhibitInput();
ProhibitInput(bv);
Systemcalls one;
switch (flag) {
@ -1412,7 +1412,7 @@ int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
break;
}
AllowInput();
AllowInput(bv);
bv->buffer()->redraw();
return errorcode;
@ -1447,7 +1447,7 @@ int RunDocBook(int flag, string const & filename)
// case BufferParams::PAPER_USLETTER: add_flags = "-p letter"; break;
// default: /* nothing to be done yet ;-) */ break;
// }
ProhibitInput();
ProhibitInput(current_view);
int errorcode = 0;
Systemcalls one;
@ -1466,7 +1466,7 @@ int RunDocBook(int flag, string const & filename)
break;
}
AllowInput();
AllowInput(current_view);
current_view->buffer()->redraw();
return errorcode;
@ -1877,6 +1877,7 @@ bool UpdateLayoutDocument(BufferParams * params)
fl_set_input(fd_form_document->input_spacing, "");
switch (params->spacing.getSpace()) {
case Spacing::Default: // nothing bad should happen with this
case Spacing::Single:
{
// \singlespacing
@ -2078,93 +2079,93 @@ static
void ToggleAndShow(BufferView *, LyXFont const &);
void FontSize(string const & size)
void FontSize(BufferView * bv, string const & size)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setGUISize(size);
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
}
void Emph()
void Emph(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setEmph(LyXFont::TOGGLE);
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
}
void Noun()
void Noun(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setNoun(LyXFont::TOGGLE);
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
}
void Bold()
void Bold(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setSeries(LyXFont::BOLD_SERIES);
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
}
void Underline()
void Underline(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setUnderbar(LyXFont::TOGGLE);
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
}
void Code()
void Code(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
}
void Sans()
void Sans(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setFamily(LyXFont::SANS_FAMILY);
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
}
void Roman()
void Roman(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setFamily(LyXFont::ROMAN_FAMILY);
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
}
void Tex()
void Tex(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setLatex (LyXFont::TOGGLE);
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
}
void LangCB(string const & l)
void Lang(BufferView * bv, string const & l)
{
LyXFont font(LyXFont::ALL_IGNORE);
Languages::iterator lit = languages.find(l);
if (lit != languages.end()) {
font.setLanguage(&(*lit).second);
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
} else
WriteAlert(_("Error! unknown language"),l);
}
void StyleReset()
void StyleReset(BufferView * bv)
{
LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
ToggleAndShow(current_view, font);
ToggleAndShow(bv, font);
}
@ -2172,27 +2173,54 @@ void StyleReset()
* future perhaps we could try to implement a callback to the button-bar.
* That is, `light' the bold button when the font is currently bold, etc.
*/
string CurrentState()
string CurrentState(BufferView * bv)
{
string state;
if (current_view->available()) {
if (bv->available()) {
// I think we should only show changes from the default
// font. (Asger)
Buffer * buffer = current_view->buffer();
LyXFont font = current_view->text->real_current_font;
Buffer * buffer = bv->buffer();
LyXFont font = bv->text->real_current_font;
LyXFont defaultfont = textclasslist.TextClass(buffer->
params.textclass).defaultfont();
font.reduce(defaultfont);
state = _("Font: ") + font.stateText();
int depth = current_view->text->GetDepth();
// The paragraph depth
int depth = bv->text->GetDepth();
if (depth > 0)
state += string(_(", Depth: ")) + tostr(depth);
// The paragraph spacing, but only if different from
// buffer spacing.
if (!bv->text->cursor.par->spacing.isDefault()) {
Spacing::Space cur_space =
bv->text->cursor.par->spacing.getSpace();
state += _(", Spacing: ");
switch (cur_space) {
case Spacing::Single:
state += _("Single");
break;
case Spacing::Onehalf:
state += _("Onehalf");
break;
case Spacing::Double:
state += _("Double");
break;
case Spacing::Other:
state += _("Other (");
state += tostr(bv->text->cursor.par->spacing.getValue());
state += ")";
break;
case Spacing::Default:
// should never happen, do nothing
break;
}
}
}
return state;
}
// candidate for move to BufferView
/* -------> Does the actual toggle job of the XxxCB() calls above.
* Also shows the current font state.
@ -2372,9 +2400,9 @@ LyXFont UserFreeFont()
}
void Free()
void Free(BufferView * bv)
{
ToggleAndShow(current_view, UserFreeFont());
ToggleAndShow(bv, UserFreeFont());
}
@ -2587,7 +2615,7 @@ void UpdateDocumentButtons(BufferParams const & params)
extern "C" void ChoiceClassCB(FL_OBJECT * ob, long)
{
ProhibitInput();
ProhibitInput(current_view);
if (textclasslist.Load(fl_get_choice(ob)-1)) {
if (AskQuestion(_("Should I set some parameters to"),
fl_get_choice_text(ob),
@ -2606,7 +2634,7 @@ extern "C" void ChoiceClassCB(FL_OBJECT * ob, long)
fl_set_choice(fd_form_document->choice_class,
current_view->buffer()->params.textclass + 1);
}
AllowInput();
AllowInput(current_view);
}

View File

@ -19,49 +19,45 @@ extern bool BindFileSet;
///
extern void Foot(BufferView *);
///
extern void Emph();
extern void Emph(BufferView *);
///
extern void Bold();
extern void Bold(BufferView *);
///
extern void Noun();
extern void Noun(BufferView *);
///
extern void Margin(BufferView *);
///
extern void Figure();
///
extern void LangCB(string const &);
extern void Lang(BufferView *, string const &);
///
extern void Table();
///
extern void Melt(BufferView *);
///
extern void Tex();
extern void Tex(BufferView *);
///
extern void changeDepth(BufferView *, int);
///
extern void Free();
extern void Free(BufferView *);
///
extern void HtmlUrl();
extern void ProhibitInput(BufferView *);
///
extern void Url();
extern void AllowInput(BufferView *);
///
extern void ProhibitInput();
extern void Code(BufferView *);
///
extern void Code();
extern void Sans(BufferView *);
///
extern void Sans();
extern void Roman(BufferView *);
///
extern void Roman();
extern void StyleReset(BufferView *);
///
extern void StyleReset();
extern void Underline(BufferView *);
///
extern void Underline();
extern void FontSize(BufferView *, string const &);
///
extern void FontSize(string const &);
///
extern string CurrentState();
///
extern void AllowInput();
extern string CurrentState(BufferView *);
#endif

View File

@ -346,14 +346,14 @@ void WriteAlert(string const & s1, string const & s2, string const & s3)
if (current_view && current_view->owner())
minibuffer = current_view->owner()->getMiniBuffer();
if (minibuffer) {
ProhibitInput();
ProhibitInput(current_view);
minibuffer->Set(s1, s2, s3);
}
fl_set_resource("flAlert.dismiss.label", _("Dismiss"));
fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0);
if (minibuffer) {
AllowInput();
AllowInput(current_view);
}
}

View File

@ -9,6 +9,14 @@
* ====================================================== */
#include <config.h>
#ifdef HAVE_SSTREAM
#include <sstream>
using std::istringstream;
#else
#include <strstream>
#endif
#include <time.h>
#include <locale.h>
@ -103,7 +111,7 @@ extern LyXAction lyxaction;
// (alkis)
extern tex_accent_struct get_accent(kb_action action);
extern void AutoSave();
extern void AutoSave(BufferView *);
extern void SetUpdateTimer(float timer = 0.3);
extern void FreeUpdateTimer();
extern bool PreviewDVI(Buffer *);
@ -206,7 +214,7 @@ int LyXFunc::processKeyEvent(XEvent * ev)
owner->view()->unlockInset(tli);
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
} else {
tli->UnlockInsetInInset(owner->view(),
tli->GetLockingInset());
@ -578,14 +586,14 @@ string LyXFunc::Dispatch(int ac,
case LFUN_BREAKLINE:
owner->view()->text->CursorRight();
owner->view()->setState();
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_RIGHT:
if (!owner->view()->text->cursor.par->isRightToLeftPar()) {
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->
Set(CurrentState());
Set(CurrentState(owner->view()));
}
return string();
case LFUN_LEFT:
@ -593,7 +601,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->
Set(CurrentState());
Set(CurrentState(owner->view()));
}
return string();
default:
@ -871,7 +879,7 @@ string LyXFunc::Dispatch(int ac,
}
case LFUN_AUTOSAVE:
AutoSave();
AutoSave(owner->view());
break;
case LFUN_UNDO:
@ -976,13 +984,13 @@ string LyXFunc::Dispatch(int ac,
break;
case LFUN_FREE:
Free();
Free(owner->view());
break;
case LFUN_TEX:
Tex();
Tex(owner->view());
owner->view()->setState();
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_MELT:
@ -1201,59 +1209,59 @@ string LyXFunc::Dispatch(int ac,
case LFUN_LANGUAGE:
{
LangCB(argument);
Lang(owner->view(), argument);
owner->view()->setState();
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
}
break;
case LFUN_EMPH:
Emph();
owner->getMiniBuffer()->Set(CurrentState());
Emph(owner->view());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_BOLD:
Bold();
owner->getMiniBuffer()->Set(CurrentState());
Bold(owner->view());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_NOUN:
Noun();
owner->getMiniBuffer()->Set(CurrentState());
Noun(owner->view());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_CODE:
Code();
owner->getMiniBuffer()->Set(CurrentState());
Code(owner->view());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_SANS:
Sans();
owner->getMiniBuffer()->Set(CurrentState());
Sans(owner->view());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_ROMAN:
Roman();
owner->getMiniBuffer()->Set(CurrentState());
Roman(owner->view());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_DEFAULT:
StyleReset();
owner->getMiniBuffer()->Set(CurrentState());
StyleReset(owner->view());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_UNDERLINE:
Underline();
owner->getMiniBuffer()->Set(CurrentState());
Underline(owner->view());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_FONT_SIZE:
FontSize(argument);
owner->getMiniBuffer()->Set(CurrentState());
FontSize(owner->view(), argument);
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_FONT_STATE:
setMessage(CurrentState());
setMessage(CurrentState(owner->view()));
break;
case LFUN_UPCASE_WORD:
@ -1360,7 +1368,7 @@ string LyXFunc::Dispatch(int ac,
tmptext->CursorRight();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
}
break;
@ -1393,7 +1401,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
}
break;
@ -1403,7 +1411,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorUp();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_DOWN:
@ -1413,7 +1421,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorDown();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_UP_PARAGRAPH:
@ -1423,7 +1431,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorUpParagraph();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_DOWN_PARAGRAPH:
@ -1433,7 +1441,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorDownParagraph();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_PRIOR:
@ -1443,7 +1451,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->cursorPrevious();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_NEXT:
@ -1453,7 +1461,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->cursorNext();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_HOME:
@ -1463,7 +1471,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorHome();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_END:
@ -1473,7 +1481,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorEnd();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_TAB:
@ -1483,7 +1491,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorTab();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_WORDRIGHT:
@ -1496,7 +1504,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorRightOneWord();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_WORDLEFT:
@ -1509,7 +1517,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorLeftOneWord();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_BEGINNINGBUF:
@ -1519,7 +1527,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorTop();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_ENDBUF:
@ -1529,7 +1537,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorBottom();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
@ -1542,7 +1550,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorRight();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_LEFTSEL:
@ -1553,7 +1561,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorLeft();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_UPSEL:
@ -1561,7 +1569,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorUp();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_DOWNSEL:
@ -1569,7 +1577,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorDown();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_UP_PARAGRAPHSEL:
@ -1577,7 +1585,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorUpParagraph();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_DOWN_PARAGRAPHSEL:
@ -1585,7 +1593,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorDownParagraph();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_PRIORSEL:
@ -1593,7 +1601,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->cursorPrevious();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_NEXTSEL:
@ -1601,7 +1609,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->cursorNext();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_HOMESEL:
@ -1609,7 +1617,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorHome();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_ENDSEL:
@ -1617,7 +1625,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorEnd();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_WORDRIGHTSEL:
@ -1628,7 +1636,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorRightOneWord();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_WORDLEFTSEL:
@ -1639,7 +1647,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorLeftOneWord();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_BEGINNINGBUFSEL:
@ -1647,7 +1655,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorTop();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_ENDBUFSEL:
@ -1655,7 +1663,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->CursorBottom();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
// --- text changing commands ------------------------
@ -1726,7 +1734,7 @@ string LyXFunc::Dispatch(int ac,
}
SetUpdateTimer();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
owner->view()->setState();
break;
@ -1783,7 +1791,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->update( 1 );
SetUpdateTimer();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
/* -------> Delete word backward. */
@ -1794,7 +1802,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->update( 1 );
SetUpdateTimer();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
/* -------> Kill to end of line. */
@ -1843,7 +1851,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->cut();
}
SetUpdateTimer();
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
owner->view()->setState();
}
break;
@ -1889,7 +1897,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
owner->view()->setState();
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
}
@ -1902,7 +1910,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
owner->view()->setState();
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
}
@ -1935,7 +1943,50 @@ string LyXFunc::Dispatch(int ac,
SetUpdateTimer(0.01);
owner->view()->text->sel_cursor = cursor;
owner->view()->setState();
owner->getMiniBuffer()->Set(CurrentState());
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
}
break;
case LFUN_PARAGRAPH_SPACING:
{
LyXParagraph * par = owner->view()->text->cursor.par;
Spacing::Space cur_spacing = par->spacing.getSpace();
float cur_value = 1.0;
if (cur_spacing == Spacing::Other) {
cur_value = par->spacing.getValue();
}
lyxerr << "all spacing arguments: " << argument << endl;
istringstream istr(argument);
string tmp;
istr >> tmp;
lyxerr << "spacing = " << tmp << endl;
Spacing::Space new_spacing = cur_spacing;
float new_value = cur_value;
if (tmp == "single") {
new_spacing = Spacing::Single;
} else if (tmp == "onehalf") {
new_spacing = Spacing::Onehalf;
} else if (tmp == "double") {
new_spacing = Spacing::Double;
} else if (tmp == "other") {
new_spacing = Spacing::Other;
float tmpval = 0.0;
istr >> tmpval;
lyxerr << "new_value = " << tmpval << endl;
if (tmpval != 0.0)
new_value = tmpval;
} else if (tmp == "default") {
new_spacing = Spacing::Default;
} else {
lyxerr << _("Unknown spacing argument: ")
<< argument << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value) {
par->spacing.set(new_spacing, new_value);
owner->view()->text->RedoParagraph();
owner->view()->update(-1);
}
}
break;
@ -1959,6 +2010,7 @@ string LyXFunc::Dispatch(int ac,
new_inset->Edit(owner->view(), 0, 0, 0);
}
break;
case LFUN_INSET_TEXT:
{
InsetText * new_inset = new InsetText(owner->buffer());
@ -1982,6 +2034,7 @@ string LyXFunc::Dispatch(int ac,
new_inset->Edit(owner->view(), 0, 0, 0);
}
break;
case LFUN_INSET_FOOTNOTE:
{
InsetFoot * new_inset = new InsetFoot(owner->buffer());
@ -2029,10 +2082,10 @@ string LyXFunc::Dispatch(int ac,
case LFUN_GETFONT:
{
LyXFont * font = &(owner->view()->text->current_font);
if(font->shape() == LyXFont::ITALIC_SHAPE)
LyXFont & font = owner->view()->text->current_font;
if(font.shape() == LyXFont::ITALIC_SHAPE)
dispatch_buffer = 'E';
else if(font->shape() == LyXFont::SMALLCAPS_SHAPE)
else if(font.shape() == LyXFont::SMALLCAPS_SHAPE)
dispatch_buffer = 'N';
else
dispatch_buffer = '0';
@ -2042,8 +2095,8 @@ string LyXFunc::Dispatch(int ac,
case LFUN_GETLATEX:
{
LyXFont * font = &(owner->view()->text->current_font);
if(font->latex() == LyXFont::ON)
LyXFont & font = owner->view()->text->current_font;
if(font.latex() == LyXFont::ON)
dispatch_buffer = 'L';
else
dispatch_buffer = '0';
@ -2656,12 +2709,12 @@ void LyXFunc::MenuNew(bool fromTemplate)
initpath = trypath;
}
ProhibitInput();
ProhibitInput(owner->view());
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
fname = fileDlg.Select(_("Enter Filename for new document"),
initpath, "*.lyx", _("newfile"));
AllowInput();
AllowInput(owner->view());
if (fname.empty()) {
owner->getMiniBuffer()->Set(_("Canceled."));
@ -2719,12 +2772,12 @@ void LyXFunc::MenuNew(bool fromTemplate)
// The template stuff
string templname;
if (fromTemplate) {
ProhibitInput();
ProhibitInput(owner->view());
fname = fileDlg.Select(_("Choose template"),
lyxrc.template_path,
"*.lyx");
templname = fname;
AllowInput();
AllowInput(owner->view());
}
// find a free buffer
@ -2746,13 +2799,13 @@ void LyXFunc::MenuOpen()
}
// launches dialog
ProhibitInput();
ProhibitInput(owner->view());
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Examples"),
AddPath(system_lyxdir, "examples"));
string filename = fileDlg.Select(_("Select Document to Open"),
initpath, "*.lyx");
AllowInput();
AllowInput(owner->view());
// check selected filename
if (filename.empty()) {
@ -2795,13 +2848,13 @@ void LyXFunc::doImportASCII(bool linorpar)
}
// launches dialog
ProhibitInput();
ProhibitInput(owner->view());
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Examples"),
AddPath(system_lyxdir, "examples"));
string filename = fileDlg.Select(_("Select ASCII file to Import"),
initpath, "*.txt");
AllowInput();
AllowInput(owner->view());
// check selected filename
if (filename.empty()) {
@ -2868,7 +2921,7 @@ void LyXFunc::doImportLaTeX(bool isnoweb)
}
// launches dialog
ProhibitInput();
ProhibitInput(owner->view());
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Examples"),
AddPath(system_lyxdir, "examples"));
@ -2881,7 +2934,7 @@ void LyXFunc::doImportLaTeX(bool isnoweb)
initpath, "*.tex");
}
AllowInput();
AllowInput(owner->view());
// check selected filename
if (filename.empty()) {
@ -2965,7 +3018,7 @@ void LyXFunc::doImportLinuxDoc()
}
// launches dialog
ProhibitInput();
ProhibitInput(owner->view());
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Examples"),
AddPath(system_lyxdir, "examples"));
@ -2973,7 +3026,7 @@ void LyXFunc::doImportLinuxDoc()
string filename = fileDlg.Select(_("Select LinuxDoc file to Import"),
initpath, "*.sgml");
AllowInput();
AllowInput(owner->view());
// check selected filename
if (filename.empty()) {
@ -3058,13 +3111,13 @@ void LyXFunc::MenuInsertLyXFile(string const & filen)
}
// launches dialog
ProhibitInput();
ProhibitInput(owner->view());
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Examples"),
AddPath(system_lyxdir, "examples"));
filename = fileDlg.Select(_("Select Document to Insert"),
initpath, "*.lyx");
AllowInput();
AllowInput(owner->view());
// check selected filename
if (filename.empty()) {

View File

@ -210,6 +210,9 @@ public:
///
VSpace added_space_bottom;
///
Spacing spacing;
///
LyXTextClass::LayoutList::size_type layout;

View File

@ -44,6 +44,7 @@
#include "lyxtext.h"
#include "gettext.h"
#include "layout.h"
#include "lyx_cb.h"
using std::vector;
using std::endl;
@ -58,8 +59,6 @@ extern void MenuLayoutSave();
extern void ShowCredits();
extern void ShowCopyright();
extern void show_symbols_form(LyXFunc *);
extern void ProhibitInput();
extern void AllowInput();
extern void LaTeXOptions(BufferView *);
// A bunch of wrappers
@ -697,7 +696,7 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
fl_freepup(SubFileExport);
fl_freepup(FileMenu);
AllowInput();
AllowInput(men->currentView());
}
@ -819,7 +818,7 @@ void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
fl_freepup(SubFileImport);
fl_freepup(FileMenu);
AllowInput();
AllowInput(men->currentView());
return;
}
@ -1669,21 +1668,21 @@ void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
switch (choice) {
case 1: case 2: case 3: case 4: case 5:
case 6: case 7: case 8: case 9: case 10:
ProhibitInput();
ProhibitInput(men->currentView());
men->MenuDocu(doc_files[choice - 1]);
AllowInput();
AllowInput(men->currentView());
break;
case 11: ShowCopyright(); break;
case 12: ShowCredits(); break;
case 13:
ProhibitInput();
ProhibitInput(men->currentView());
fl_show_message((string(_("LyX Version ")) + LYX_VERSION
+ _(" of ") + LYX_RELEASE).c_str(),
(_("Library directory: ")
+ MakeDisplayPath(system_lyxdir)).c_str(),
(_("User directory: ")
+ MakeDisplayPath(user_lyxdir)).c_str());
AllowInput();
AllowInput(men->currentView());
break;
}
fl_freepup(HelpMenu);

View File

@ -167,7 +167,10 @@ void LyXParagraph::writeFile(ostream & os, BufferParams const & params,
if (added_space_bottom.kind() != VSpace::NONE)
os << "\\added_space_bottom "
<< added_space_bottom.asLyXCommand() << " ";
// Maybe the paragraph has special spacing
spacing.writeFile(os, true);
// The labelwidth string used in lists.
if (!labelwidthstring.empty())
os << "\\labelwidthstring "
@ -337,6 +340,8 @@ void LyXParagraph::validate(LaTeXFeatures & features) const
// check the params.
if (line_top || line_bottom)
features.lyxline = true;
if (!spacing.isDefault())
features.setspace = true;
// then the layouts
features.layout[GetLayout()] = true;
@ -473,7 +478,8 @@ void LyXParagraph::Clear()
added_space_top = VSpace(VSpace::NONE);
added_space_bottom = VSpace(VSpace::NONE);
spacing.set(Spacing::Default);
align = LYX_ALIGN_LAYOUT;
depth = 0;
noindent = false;
@ -1445,6 +1451,8 @@ void LyXParagraph::MakeSameLayout(LyXParagraph const * par)
pagebreak_top = par->pagebreak_top;
added_space_top = par->added_space_top;
spacing = par->spacing;
pextra_type = par->pextra_type;
pextra_width = par->pextra_width;
pextra_widthp = par->pextra_widthp;
@ -1530,6 +1538,8 @@ bool LyXParagraph::HasSameLayout(LyXParagraph const * par) const
par->pagebreak_top == pagebreak_top &&
par->added_space_top == added_space_top &&
par->spacing == spacing &&
par->pextra_type == pextra_type &&
par->pextra_width == pextra_width &&
par->pextra_widthp == pextra_widthp &&
@ -1768,6 +1778,8 @@ void LyXParagraph::SetLayout(LyXTextClass::size_type new_layout)
par->align = LYX_ALIGN_LAYOUT;
par->added_space_top = VSpace(VSpace::NONE);
par->added_space_bottom = VSpace(VSpace::NONE);
par->spacing.set(Spacing::Default);
/* table stuff -- begin*/
if (table)
par->layout = 0;
@ -1972,6 +1984,13 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
texrow.newline();
}
if (!spacing.isDefault()
&& (!Previous() || !Previous()->HasSameLayout(this))) {
os << "\\begin{spacing}{"
<< spacing.getValue() << "}\n";
texrow.newline();
}
if (tex_code_break_column && style.isCommand()){
os << '\n';
texrow.newline();
@ -2148,6 +2167,12 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
texrow.newline();
}
if (!spacing.isDefault()
&& (!par || !par->HasSameLayout(this))) {
os << "\\end{spacing}\n";
texrow.newline();
}
if (!(footnoteflag != LyXParagraph::NO_FOOTNOTE && par &&
par->footnoteflag == LyXParagraph::NO_FOOTNOTE)) {
os << '\n';

View File

@ -1260,19 +1260,27 @@ void LyXText::SetHeightOfRow(Row * row_ptr) const
LyXLayout const & layout = textclasslist.Style(bparams->textclass,
firstpar->GetLayout());
LyXFont font = GetFont(par, par->Last()-1);
LyXFont font = GetFont(par, par->Last() - 1);
LyXFont::FONT_SIZE size = font.size();
font = GetFont(par, -1);
font.setSize(size);
LyXFont labelfont = GetFont(par, -2);
float spacing_val = 1.0;
if (!row_ptr->par->spacing.isDefault()) {
spacing_val = row_ptr->par->spacing.getValue();
} else {
spacing_val = bparams->spacing.getValue();
}
lyxerr << "spacing_val = " << spacing_val << endl;
int maxasc = int(lyxfont::maxAscent(font) *
layout.spacing.getValue() *
bparams->spacing.getValue());
spacing_val);
int maxdesc = int(lyxfont::maxDescent(font) *
layout.spacing.getValue() *
bparams->spacing.getValue());
spacing_val);
int pos_end = RowLast(row_ptr);
@ -1363,12 +1371,19 @@ void LyXText::SetHeightOfRow(Row * row_ptr) const
* layout is printed in an extra row */
if (layout.labeltype == LABEL_COUNTER_CHAPTER
&& bparams->secnumdepth>= 0) {
float spacing_val = 1.0;
if (!row_ptr->par->spacing.isDefault()) {
spacing_val = row_ptr->par->spacing.getValue();
} else {
spacing_val = bparams->spacing.getValue();
}
labeladdon = int(lyxfont::maxDescent(labelfont) *
layout.spacing.getValue() *
bparams->spacing.getValue())
+ int(lyxfont::maxAscent(labelfont) *
layout.spacing.getValue() *
bparams->spacing.getValue());
spacing_val)
+ int(lyxfont::maxAscent(labelfont) *
layout.spacing.getValue() *
spacing_val);
}
/* special code for the top label */
@ -1377,15 +1392,22 @@ void LyXText::SetHeightOfRow(Row * row_ptr) const
|| layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
&& row_ptr->par->IsFirstInSequence()
&& !row_ptr->par->GetLabelstring().empty()) {
labeladdon = int(
(lyxfont::maxAscent(labelfont) *
layout.spacing.getValue() *
bparams->spacing.getValue())
+(lyxfont::maxDescent(labelfont) *
layout.spacing.getValue() *
bparams->spacing.getValue())
+ layout.topsep * DefaultHeight()
+ layout.labelbottomsep * DefaultHeight());
float spacing_val = 1.0;
if (!row_ptr->par->spacing.isDefault()) {
spacing_val = row_ptr->par->spacing.getValue();
} else {
spacing_val = bparams->spacing.getValue();
}
labeladdon = int(
(lyxfont::maxAscent(labelfont) *
layout.spacing.getValue() *
spacing_val)
+(lyxfont::maxDescent(labelfont) *
layout.spacing.getValue() *
spacing_val)
+ layout.topsep * DefaultHeight()
+ layout.labelbottomsep * DefaultHeight());
}
/* and now the layout spaces, for example before and after a section,
@ -4030,7 +4052,14 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
if (bparams->secnumdepth >= 0){
/* this is special code for the chapter layout. This is printed in
* an extra row and has a pagebreak at the top. */
maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * bparams->spacing.getValue())
float spacing_val = 1.0;
if (!row_ptr->par->spacing.isDefault()) {
spacing_val = row_ptr->par->spacing.getValue();
} else {
spacing_val = bparams->spacing.getValue();
}
maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * spacing_val)
+ int(layout.parsep) * DefaultHeight();
if (is_rtl)
tmpx = paperwidth - LeftMargin(row_ptr) -
@ -4066,8 +4095,14 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
font = GetFont(row_ptr->par, -2);
if (!row_ptr->par->GetLabelstring().empty()) {
string tmpstring = row_ptr->par->GetLabelstring();
maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * bparams->spacing.getValue()
float spacing_val = 1.0;
if (!row_ptr->par->spacing.isDefault()) {
spacing_val = row_ptr->par->spacing.getValue();
} else {
spacing_val = bparams->spacing.getValue();
}
maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * spacing_val
+ (layout.labelbottomsep * DefaultHeight()));
tmpx = x;

View File

@ -3484,6 +3484,7 @@ void LyXText::DeleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const
&& old_cursor.par->IsLineSeparator(old_cursor.pos - 1)) {
old_cursor.par->Erase(old_cursor.pos - 1);
status = LyXText::NEED_MORE_REFRESH;
RedoParagraphs(old_cursor, old_cursor.par->Next());
// correct cursor
if (old_cursor.par == cursor.par &&
cursor.pos > old_cursor.pos) {