2000-05-20 Lars Gullik Bjønnes <larsbj@lyx.org>
+ * src/WorkArea.C (request_clipboard_cb): give "C" linkage.
+
+2000-05-19 Dekel Tsur <dekel@math.tau.ac.il>
+
+ * src/commandtags.h
+
+ * src/LyXAction.C
+
+ * src/lyxfunc.C (Dispatch): Added LFUN_LOFVIEW, LFUN_LOTVIEW
+ and LFUN_LOAVIEW
+
+ * src/insets/insetlo*.[Ch]: Made editable
+
+2000-05-20 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/text2.C (SetSelection): call BufferView::stuffClipboard with
+ the current selection.
+
+ * src/BufferView_pimpl.C (stuffClipboard): new method
+
+ * src/BufferView.C (stuffClipboard): new method
+
+ * src/paragraph.C (String): new method
+
+ * src/LColor.C (getFromLyXName): return LColor::inherit instead of
+ LColor::ignore when lyxname is not found.
+
* src/BufferView.C (pasteSelection): new method
* src/BufferView_pimpl.C (pasteSelection): new method
case $gxx_version in
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
- 2.96*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
+ 2.96*) CXXFLAGS="-g $lyx_opt -fhonor-std";;
*2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
esac
if test x$with_warnings = xyes ; then
case $gxx_version in
2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion -Winline";;
- 2.96*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion";;
+ 2.96*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion -Winline";;
*) CXXFLAGS="$CXXFLAGS -ansi -W -Wall -Wno-return-type";;
esac
if test $lyx_devel_version = yes ; then
case $gxx_version in
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
- 2.96*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
+ 2.96*) CXXFLAGS="-g $lyx_opt -fhonor-std";;
*2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
esac
if test x$with_warnings = xyes ; then
case $gxx_version in
2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion -Winline";;
- 2.96*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion";;
+ 2.96*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion -Winline";;
*) CXXFLAGS="$CXXFLAGS -ansi -W -Wall -Wno-return-type";;
esac
if test $lyx_devel_version = yes ; then
Name: form_toc
Width: 420
Height: 340
-Number of Objects: 4
+Number of Objects: 5
--------------------
class: FL_BOX
callback: TocUpdateCB
argument: 0
+--------------------
+class: FL_CHOICE
+type: NORMAL_CHOICE
+box: 60 300 130 30
+boxtype: FL_FRAME_BOX
+colors: FL_COL1 FL_BLACK
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Type|Tt#t
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: toctype
+callback: TocUpdateCB
+argument: 0
+
=============== FORM ===============
Name: form_ref
Width: 590
#ifdef XFORMS_CLIPBOARD
-void BufferView::pasteSelection(bool asPara)
+void BufferView::pasteClipboard(bool asPara)
{
- pimpl_->pasteSelection(asPara);
+ pimpl_->pasteClipboard(asPara);
+}
+
+
+void BufferView::stuffClipboard(string const & stuff) const
+{
+ pimpl_->stuffClipboard(stuff);
}
#endif
bool ChangeRefs(string const & from, string const & to);
#ifdef XFORMS_CLIPBOARD
///
- void pasteSelection(bool asPara);
+ void pasteClipboard(bool asPara);
+ ///
+ void stuffClipboard(string const &) const;
#endif
private:
struct Pimpl;
owner_->updateWindowTitle();
}
+
void BufferView::Pimpl::resize(int xpos, int ypos, int width, int height)
{
workarea->resize(xpos, ypos, width, height);
void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
{
- if (buffer_ == 0 || !screen) return;
-
// Only use motion with button 1
- if (!state & Button1MotionMask)
- return;
+ if (!(state & Button1MotionMask))
+ return;
+
+ if (buffer_ == 0 || !screen) return;
// Check for inset locking
if (bv_->the_locking_inset) {
// Do we want to close a float? (click on the float-label)
if (bv_->text->cursor.row->par->footnoteflag ==
LyXParagraph::OPEN_FOOTNOTE
- //&& text->cursor.pos == 0
&& bv_->text->cursor.row->previous &&
bv_->text->cursor.row->previous->par->
footnoteflag != LyXParagraph::OPEN_FOOTNOTE){
#ifdef XFORMS_CLIPBOARD
-void BufferView::Pimpl::pasteSelection(bool asPara)
+void BufferView::Pimpl::pasteClipboard(bool asPara)
{
if (buffer_ == 0) return;
}
update(1);
}
+
+
+void BufferView::Pimpl::stuffClipboard(string const & stuff) const
+{
+ workarea->putClipboard(stuff);
+}
#endif
UpdateInset updatelist;
#ifdef XFORMS_CLIPBOARD
///
- void pasteSelection(bool asPara);
+ void pasteClipboard(bool asPara);
+ ///
+ void stuffClipboard(string const &) const;
#endif
private:
bool using_xterm_cursor;
LColor::color LColor::getFromLyXName(string const & lyxname) const
{
+
InfoTab::const_iterator ici = infotab.begin();
for (; ici != infotab.end(); ++ici) {
if (!compare_no_case((*ici).second.lyxname, lyxname))
return (*ici).first;
}
- return LColor::ignore;
+ return LColor::inherit;
}
// The evil global LColor instance
N_("Select to end of line"), ReadOnly },
{ LFUN_LOA_INSERT, "loa-insert",
N_("Insert list of algorithms"), Noop },
+ { LFUN_LOAVIEW, "loa-view",
+ N_("View list of algorithms"), ReadOnly },
{ LFUN_LOF_INSERT, "lof-insert",
N_("Insert list of figures"), Noop },
+ { LFUN_LOFVIEW, "lof-view",
+ N_("View list of figures"), ReadOnly },
{ LFUN_LOT_INSERT, "lot-insert",
N_("Insert list of tables"), Noop },
+ { LFUN_LOTVIEW, "lot-view",
+ N_("View list of tables"), ReadOnly },
{ LFUN_QUIT, "lyx-quit", N_("Exit"), NoBuffer },
{ LFUN_MARGINMELT, "marginpar-insert",
N_("Insert Margin note"), Noop },
static string clipboard_selection;
static bool clipboard_read = false;
-static
+extern "C" {
+ static
int request_clipboard_cb(FL_OBJECT * /*ob*/, long /*type*/,
void const * data, long size)
{
clipboard_selection.reserve(size);
for (int i = 0; i < size; ++i) {
- clipboard_selection.push_back(static_cast<char*>(data)[i]);
+ clipboard_selection += static_cast<char const *>(data)[i];
}
clipboard_read = true;
return 0;
}
-
+}
string WorkArea::getClipboard() const
{
switch (par->footnotekind) {
case LyXParagraph::FIG:
case LyXParagraph::WIDE_FIG:
- l[1].push_back(tmp);
+ l[TOC_LOF].push_back(tmp);
break;
case LyXParagraph::TAB:
case LyXParagraph::WIDE_TAB:
- l[2].push_back(tmp);
+ l[TOC_LOT].push_back(tmp);
break;
case LyXParagraph::ALGORITHM:
- l[3].push_back(tmp);
+ l[TOC_LOA].push_back(tmp);
break;
case LyXParagraph::FOOTNOTE:
case LyXParagraph::MARGIN:
labeltype -
textclasslist.TextClass(params.textclass).maxcounter());
tmp.str = par->String(true);
- l[0].push_back(tmp);
+ l[TOC_TOC].push_back(tmp);
}
}
par = par->next;
par = par->next;
}
//it = 0;
+ // We maintain an invariant that whenever par = 0 then it = 0
}
string str;
};
///
+ enum TocType {
+ ///
+ TOC_TOC = 0,
+ ///
+ TOC_LOF,
+ ///
+ TOC_LOT,
+ ///
+ TOC_LOA
+ };
+ ///
std::vector<std::vector<TocItem> > getTocList();
///
std::vector<string> getLabelList();
*/
BufferView * users;
+public:
class inset_iterator {
public:
inset_iterator() : par(0) /*, it(0)*/ {}
Inset * operator*() {return *it; }
LyXParagraph * getPar() { return par; }
LyXParagraph::size_type getPos() {return it.getPos(); }
- bool operator==(inset_iterator const & iter) const {
- return it == iter.it && par == iter.par;
+ friend
+ bool operator==(inset_iterator const & iter1,
+ inset_iterator const & iter2) {
+ return iter1.par == iter2.par
+ && (iter1.par == 0 || iter1.it == iter2.it);
}
- bool operator!=(inset_iterator const & iter) const {
- return it != iter.it || par != iter.par;
+ friend
+ bool operator!=(inset_iterator const & iter1,
+ inset_iterator const & iter2) {
+ return !(iter1 == iter2);
}
private:
void SetParagraph();
LyXParagraph * par;
LyXParagraph::inset_iterator it;
};
-public:
+
///
inset_iterator inset_iterator_begin() {
return inset_iterator(paragraph);
LFUN_INSET_NUMBER, // Dekel 20000402
LFUN_PARAGRAPH_SPACING, // Lgb 20000411
LFUN_INSET_TABULAR, // Jug 20000412
+ LFUN_LOFVIEW, // Dekel 20000519
+ LFUN_LOTVIEW, // Dekel 20000519
+ LFUN_LOAVIEW, // Dekel 20000519
LFUN_LASTACTION /* this marks the end of the table */
};
} else {
char * msg = 0;
// draw frame
- pain.rectangle(x, baseline - hgh - 1, wid + 1, hgh + 1);
+ pain.rectangle(int(x), baseline - hgh - 1, wid + 1, hgh + 1);
if (figure && figure->data) {
if (figure->data->broken) msg = _("[render error]");
{
// This will draw the graphics. As for now we only draw a
// placeholder rectangele.
- pain.rectangle(x, baseline - ascent(pain, font),
+ pain.rectangle(int(x), baseline - ascent(pain, font),
width(pain, font),
ascent(pain, font) + descent(pain, font));
}
}
if (tmpic != ic) {
char ch = char(tmpic);
- pain.text(x, baseline, ch, font);
+ pain.text(int(x), baseline, ch, font);
x += width(pain, font);
return true;
}
switch (modtype) {
case ACUTE: // acute 0xB4
{
- pain.text(x2 - (lyxfont::rbearing(0xB4, font) - lyxfont::lbearing(0xB4, font)) / 2,
+ pain.text(int(x2 - (lyxfont::rbearing(0xB4, font) - lyxfont::lbearing(0xB4, font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB4, font) - (lyxfont::ascent(0xB4, font) + lyxfont::descent(0xB4, font)) / 2,
char(0xB4), font);
break;
}
case GRAVE: // grave 0x60
{
- pain.text(x2 - (lyxfont::rbearing(0x60, font) - lyxfont::lbearing(0x60, font)) / 2,
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x60, font) - (lyxfont::ascent(0x60, font) + lyxfont::descent(0x60, font)) / 2.0,
+ pain.text(int(x2 - (lyxfont::rbearing(0x60, font) - lyxfont::lbearing(0x60, font)) / 2),
+ int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x60, font) - (lyxfont::ascent(0x60, font) + lyxfont::descent(0x60, font)) / 2.0),
char(0x60), font);
break;
}
case MACRON: // macron
{
- pain.text(x2 - (lyxfont::rbearing(0xAF, font) - lyxfont::lbearing(0xAF, font)) / 2,
+ pain.text(int(x2 - (lyxfont::rbearing(0xAF, font) - lyxfont::lbearing(0xAF, font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xAF, font) - (lyxfont::ascent(0xAF, font) + lyxfont::descent(0xAF, font)),
char(0xAF), font);
break;
}
case TILDE: // tilde
{
- pain.text(x2 - (lyxfont::rbearing('~', font) - lyxfont::lbearing('~', font)) / 2,
+ pain.text(int(x2 - (lyxfont::rbearing('~', font) - lyxfont::lbearing('~', font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('~', font) - (lyxfont::ascent('~', font) + lyxfont::descent('~', font)) / 2,
'~', font);
break;
}
case UNDERBAR: // underbar 0x5F
{
- pain.text(x2 - (lyxfont::rbearing(0x5F, font) - lyxfont::lbearing(0x5F, font)) / 2, baseline,
+ pain.text(int(x2 - (lyxfont::rbearing(0x5F, font) - lyxfont::lbearing(0x5F, font)) / 2), baseline,
char(0x5F), font);
break;
}
case CEDILLA: // cedilla
{
- pain.text(x2 - (lyxfont::rbearing(0xB8, font) - lyxfont::lbearing(0xB8, font)) / 2, baseline,
+ pain.text(int(x2 - (lyxfont::rbearing(0xB8, font) - lyxfont::lbearing(0xB8, font)) / 2), baseline,
char(0xB8), font);
break;
}
case UNDERDOT: // underdot
{
- pain.text(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0,
- baseline + 3.0 / 2.0 * (lyxfont::ascent('.', font) + lyxfont::descent('.', font)),
+ pain.text(int(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0),
+ int(baseline + 3.0 / 2.0 * (lyxfont::ascent('.', font) + lyxfont::descent('.', font))),
'.', font);
break;
}
case DOT: // dot
{
- pain.text(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0,
+ pain.text(int(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('.', font) - (lyxfont::ascent('.', font) + lyxfont::descent('.', font)) / 2,
'.', font);
break;
{
LyXFont tmpf(font);
tmpf.decSize().decSize();
- pain.text(x2 - (lyxfont::rbearing(0xB0, tmpf) - lyxfont::lbearing(0xB0, tmpf)) / 2.0,
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB0, tmpf) - (lyxfont::ascent(0xB0, tmpf) + lyxfont::descent(0xB0, tmpf)) / 3.0,
+ pain.text(int(x2 - (lyxfont::rbearing(0xB0, tmpf) - lyxfont::lbearing(0xB0, tmpf)) / 2.0),
+ int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB0, tmpf) - (lyxfont::ascent(0xB0, tmpf) + lyxfont::descent(0xB0, tmpf)) / 3.0),
char(0xB0), tmpf);
break;
}
case TIE: // tie
{
- pain.arc(int(x2 + hg35), y + hg / 2.0,
- 2 * hg, hg, 0, 360 * 32);
+ pain.arc(int(x2 + hg35), int(y + hg / 2.0),
+ int(2 * hg), int(hg), 0, 360 * 32);
break;
}
case BREVE: // breve
{
pain.arc(int(x2 - (hg / 2.0)), y,
- hg, hg, 0, -360*32);
+ int(hg), int(hg), 0, -360*32);
break;
}
case CARON: // caron
}
case HUNGARIAN_UMLAUT: // hung. umlaut
{
- pain.text(x2 - (lyxfont::rbearing('´', font) - lyxfont::lbearing('´', font)),
+ pain.text(int(x2 - (lyxfont::rbearing('´', font) - lyxfont::lbearing('´', font))),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
'´', font);
- pain.text(x2,
+ pain.text(int(x2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
'´', font);
break;
}
case UMLAUT: // umlaut
{
- pain.text(x2 - (lyxfont::rbearing('¨', font) - lyxfont::lbearing('¨', font)) / 2,
+ pain.text(int(x2 - (lyxfont::rbearing('¨', font) - lyxfont::lbearing('¨', font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('¨', font) - ( lyxfont::ascent('¨', font) + lyxfont::descent('¨', font)) / 2,
'¨', font);
break;
{
LyXFont tmpf(font);
tmpf.decSize().decSize().decSize();
- pain.text(x2 - (lyxfont::rbearing(0x5E, tmpf) - lyxfont::lbearing(0x5E, tmpf)) / 2,
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x5E, tmpf) - (lyxfont::ascent(0x5E, tmpf) + lyxfont::descent(0x5E, tmpf)) / 3.0,
+ pain.text(int(x2 - (lyxfont::rbearing(0x5E, tmpf) - lyxfont::lbearing(0x5E, tmpf)) / 2),
+ int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x5E, tmpf) - (lyxfont::ascent(0x5E, tmpf) + lyxfont::descent(0x5E, tmpf)) / 3.0),
char(0x5E), tmpf);
break;
}
#include "insetloa.h"
#include "LaTeXFeatures.h"
+#include "BufferView.h"
+#include "LyXView.h"
+#include "lyxfunc.h"
+#include "commandtags.h"
void InsetLOA::Validate(LaTeXFeatures & features) const
{
{
return _("List of Algorithms");
}
+
+void InsetLOA::Edit(BufferView * bv, int, int, unsigned int)
+{
+ bv->owner()->getLyXFunc()->Dispatch(LFUN_LOAVIEW);
+}
Inset * Clone() const { return new InsetLOA(owner); }
///
string getScreenLabel() const;
-
+ ///
+ void Edit(BufferView * bv, int, int, unsigned int);
///
EDITABLE Editable() const {
- return NOT_EDITABLE; // not yet
+ return IS_EDITABLE; // not yet
}
///
bool display() const { return true; }
#pragma implementation
#endif
-
#include "insetlof.h"
+#include "BufferView.h"
+#include "LyXView.h"
+#include "lyxfunc.h"
+#include "commandtags.h"
string InsetLOF::getScreenLabel() const
{
return _("List of Figures");
}
+
+void InsetLOF::Edit(BufferView * bv, int, int, unsigned int)
+{
+ bv->owner()->getLyXFunc()->Dispatch(LFUN_LOFVIEW);
+}
#pragma interface
#endif
-class Buffer;
+class Buffer;
/** Used to insert table of contents
*/
Inset * Clone() const { return new InsetLOF(owner); }
///
string getScreenLabel() const;
-
+ ///
+ void Edit(BufferView * bv, int, int, unsigned int);
///
EDITABLE Editable() const {
- return NOT_EDITABLE; // not yet
+ return IS_EDITABLE; // Finally!
}
///
bool display() const { return true; }
#pragma implementation
#endif
-
#include "insetlot.h"
+#include "BufferView.h"
+#include "LyXView.h"
+#include "lyxfunc.h"
+#include "commandtags.h"
+
string InsetLOT::getScreenLabel() const
{
return _("List of Tables");
}
+void InsetLOT::Edit(BufferView * bv, int, int, unsigned int)
+{
+ bv->owner()->getLyXFunc()->Dispatch(LFUN_LOTVIEW);
+}
Inset * Clone() const { return new InsetLOT(owner); }
///
string getScreenLabel() const;
-
+ ///
+ void Edit(BufferView * bv, int, int, unsigned int);
///
EDITABLE Editable() const {
- return NOT_EDITABLE; // not yet
+ return IS_EDITABLE; // not yet
}
///
bool display() const { return true; }
void setPos(Painter &, int x, int y) const;
///
UpdatableInset::RESULT moveRight(BufferView *, bool activate_inset = true);
+ ///
UpdatableInset::RESULT moveLeft(BufferView *, bool activate_inset = true);
+ ///
UpdatableInset::RESULT moveUp(BufferView *);
+ ///
UpdatableInset::RESULT moveDown(BufferView *);
+ ///
bool Delete();
+ ///
bool cutSelection();
+ ///
bool copySelection();
+ ///
bool pasteSelection();
///
bool hasSelection() const
typedef std::vector<row_struct> RowList;
///
mutable RowList rows;
+ ///
InsetText & operator = (InsetText const & it) {
par = it.par;
buffer = it.buffer; // suspect
#endif
#include "insettoc.h"
-#include "buffer.h"
-#include "bufferlist.h"
#include "commandtags.h"
#include "lyxfunc.h"
#include "LyXView.h"
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
fl_set_object_callback(obj, TocUpdateCB, 0);
+ fdui->toctype = obj = fl_add_choice(FL_NORMAL_CHOICE, 60, 300, 130, 30, idex(_("Type|Tt#t")));fl_set_button_shortcut(obj,scex(_("Type|Tt#t")),1);
+ fl_set_object_boxtype(obj, FL_FRAME_BOX);
+ fl_set_object_callback(obj, TocUpdateCB, 0);
fl_end_form();
//fdui->form_toc->fdui = fdui;
char *cdata;
long ldata;
FL_OBJECT *browser_toc;
+ FL_OBJECT *toctype;
} FD_form_toc;
extern FD_form_toc * create_form_form_toc(void);
using std::pair;
using std::vector;
using std::sort;
+using std::equal;
extern Combox * combo_language;
extern Combox * combo_language2;
}
-extern "C" void TocUpdateCB(FL_OBJECT *, long)
+extern "C"
+void TocUpdateCB(FL_OBJECT *, long)
{
if (!current_view->available()) {
toclist.clear();
vector<vector<Buffer::TocItem> > tmp =
current_view->buffer()->getTocList();
- if (toclist == tmp[0])
+ int type = fl_get_choice(fd_form_toc->toctype)-1;
+ //if (toclist == tmp[type])
+ // return;
+ if (toclist.size() == tmp[type].size()
+ && equal(toclist.begin(), toclist.end(), tmp[type].begin()))
return;
- toclist = tmp[0];
+
+ toclist = tmp[type];
static Buffer * buffer = 0;
int topline = 0;
// the toc form
fd_form_toc = create_form_form_toc();
+ fl_addto_choice(fd_form_toc->toctype,
+ _(" TOC | LOF | LOT | LOA "));
fl_set_form_atclose(fd_form_toc->form_toc, CancelCloseBoxCB, 0);
// the ref form
void LyX::init(int */*argc*/, char **argv, bool gui)
{
// Install the signal handlers
- ::signal(SIGHUP, error_handler);
- ::signal(SIGFPE, error_handler);
- ::signal(SIGSEGV, error_handler);
- ::signal(SIGINT, error_handler);
- ::signal(SIGTERM, error_handler);
+ std::signal(SIGHUP, error_handler);
+ std::signal(SIGFPE, error_handler);
+ std::signal(SIGSEGV, error_handler);
+ std::signal(SIGINT, error_handler);
+ std::signal(SIGTERM, error_handler);
//
// Determine path of binary
if (orgfont.color() != color()) {
// To make us file compatible with older
// lyx versions we emit "default" instead
- // of "ignore"
+ // of "inherit"
string col_str(lcolor.getLyXName(color()));
if (col_str == "inherit") col_str = "default";
os << "\\color " << col_str << "\n";
break;
case LFUN_TOCVIEW:
+ case LFUN_LOFVIEW:
+ case LFUN_LOTVIEW:
+ case LFUN_LOAVIEW:
+ {
+ Buffer::TocType type = Buffer::TOC_TOC;
+ if (action == LFUN_LOFVIEW)
+ type = Buffer::TOC_LOF;
+ else if (action == LFUN_LOTVIEW)
+ type = Buffer::TOC_LOT;
+ else if (action == LFUN_LOAVIEW)
+ type = Buffer::TOC_LOA;
+ fl_set_choice(fd_form_toc->toctype,type + 1);
TocUpdateCB(0, 0);
if (fd_form_toc->form_toc->visible) {
fl_raise_form(fd_form_toc->form_toc);
fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
}
break;
-
+ }
case LFUN_TOC_INSERT:
{
Inset * new_inset = new InsetTOC(owner->buffer());
bool asPara = false;
if (argument == "paragraph") asPara = true;
#ifdef XFORMS_CLIPBOARD
- owner->view()->pasteSelection(asPara);
+ owner->view()->pasteClipboard(asPara);
#else
MenuPasteSelection(asPara);
#endif
if (event->type != KeyPress)
lyxerr << "LyXLookupString: wrong event type"
<< event->type << endl;
- Status status_return;
+ Status status_return = 0;
result = XmbLookupString(xic, &event->xkey, buffer_return,
bytes_buffer, keysym_return,
bool isMultiLingual();
///
string String(bool label);
+ ///
+ string String(size_type beg, size_type end);
///
void writeFile(std::ostream &, BufferParams const &, char, char) const;
void SetSelection();
///
void ClearSelection() const;
-
+ ///
+ string selectionAsString() const;
+
/// just selects the word the cursor is in
void SelectWord();
"|Table%m"
"|Spellchecker...."
"|Check TeX"
- "|Table of Contents...%l"
+ "|Table of Contents..."
+ "|List of Figures..."
+ "|List of Tables..."
+ "|List of Algorithms...%l"
"|Version Control%m%l"
"|View LaTeX log file%l"
"|Paste Primary Selection as Lines"
fl_setpup_shortcut(EditMenu, 7, scex(_("EM|Ee#e#E")));
fl_setpup_shortcut(EditMenu, 8, scex(_("EM|Nn#n#N")));
fl_setpup_shortcut(EditMenu, 9, scex(_("EM|Ii#i#I")));
- fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
+ //fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
fl_setpup_shortcut(EditMenu, 11, scex(_("EM|Ss#s#S")));
fl_setpup_shortcut(EditMenu, 12, scex(_("EM|hH#h#H")));
- fl_setpup_shortcut(EditMenu, 13, scex(_("EM|aA#a#A")));
- fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Vv#v#V")));
- fl_setpup_shortcut(EditMenu, 15, scex(_("EM|wW#w#W")));
- fl_setpup_shortcut(EditMenu, 16, scex(_("EM|Ll#l#L")));
- fl_setpup_shortcut(EditMenu, 17, scex(_("EM|gG#g#G")));
+ fl_setpup_shortcut(EditMenu, 13, scex(_("EM|Tt#t#T")));
+ //fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Ff#f#F")));
+ //fl_setpup_shortcut(EditMenu, 15, scex(_("EM|bB#b#B")));
+ //fl_setpup_shortcut(EditMenu, 16, scex(_("EM|mM#m#M")));
+ fl_setpup_shortcut(EditMenu, 17, scex(_("EM|Vv#v#V")));
+ fl_setpup_shortcut(EditMenu, 18, scex(_("EM|wW#w#W")));
+ fl_setpup_shortcut(EditMenu, 19, scex(_("EM|Ll#l#L")));
+ fl_setpup_shortcut(EditMenu, 20, scex(_("EM|gG#g#G")));
// disable unavailable entries.
if(tmpbuffer->undostack.empty())
fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
fl_setpup_mode(EditMenu, 3, FL_PUP_GREY);
fl_setpup_mode(EditMenu, 5, FL_PUP_GREY);
- fl_setpup_mode(EditMenu, 16, FL_PUP_GREY);
- fl_setpup_mode(EditMenu, 17, FL_PUP_GREY);
+ fl_setpup_mode(EditMenu, 19, FL_PUP_GREY);
+ fl_setpup_mode(EditMenu, 20, FL_PUP_GREY);
}
fl_setpup_position(men->_view->getForm()->x + ob->x,
case 11: tmpfunc->Dispatch(LFUN_SPELLCHECK); break;
case 12: tmpfunc->Dispatch(LFUN_RUNCHKTEX); break;
case 13: tmpfunc->Dispatch(LFUN_TOCVIEW); break;
- case 14: // version control
+ case 14: tmpfunc->Dispatch(LFUN_LOFVIEW); break;
+ case 15: tmpfunc->Dispatch(LFUN_LOTVIEW); break;
+ case 16: tmpfunc->Dispatch(LFUN_LOAVIEW); break;
+ case 17: // version control
break;
- case 15: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
- case 16: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
- case 17: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
+ case 18: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
+ case 19: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
+ case 20: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
// floats & insets sub-menu
case 21: men->currentView()->toggleFloat(); break;
fl_addtopup(RefsMenu, _("Insert Reference:%d%x0"));
Add_to_refs_menu(label_list, 1, RefsMenu, menus, ob);
- if (label_list.empty()) {
- fl_setpup_mode(RefsMenu, 1, FL_PUP_GREY);
- fl_setpup_mode(RefsMenu, 2, FL_PUP_GREY);
- }
+ if (label_list.empty())
+ for (int j = 1; j <= 5; ++j)
+ fl_setpup_mode(RefsMenu, j, FL_PUP_GREY);
fl_setpup_position(
men->_view->getForm()->x + ob->x,
using std::ios;
using std::lower_bound;
using std::upper_bound;
+using std::reverse;
int tex_code_break_column = 72; // needs non-zero initialization. set later.
// this is a bad idea, but how can LyXParagraph find its buffer to get
s += labelstring + ' ';
string::size_type len = s.size();
- for (LyXParagraph::size_type i = 0;i < size(); ++i) {
+ for (LyXParagraph::size_type i = 0; i < size(); ++i) {
unsigned char c = GetChar(i);
if (IsPrintable(c))
s += c;
}
return s;
}
+
+
+string LyXParagraph::String(LyXParagraph::size_type beg,
+ LyXParagraph::size_type end)
+{
+ string s;
+
+ for (LyXParagraph::size_type i = beg; i < end; ++i) {
+ unsigned char c = GetChar(i);
+ if (IsPrintable(c))
+ s += c;
+ else if (c == META_INSET) {
+#ifdef HAVE_SSTREAM
+ std::ostringstream ost;
+ GetInset(i)->Ascii(ost);
+#else
+ ostrstream ost;
+ GetInset(i)->Ascii(ost);
+ ost << '\0';
+#endif
+ s += subst(ost.str(),'\n',' ');
+ }
+ }
+
+ if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
+ s += NextAfterFootnote()->String(false);
+
+ if (!IsDummy()) {
+ if (isRightToLeftPar())
+ reverse(s.begin(), s.end());
+ }
+ return s;
+}
{
first = 0;
- /* the cursor isnt yet visible */
+ // the cursor isnt yet visible
cursor_visible = false;
cursor_pixmap = 0;
cursor_pixmap_x = 0;
{
long y_text = first + y1;
- /* get the first needed row */
+ // get the first needed row
Row * row = text->GetRowNearY(y_text);
- /* y_text is now the real beginning of the row */
+ // y_text is now the real beginning of the row
long y = y_text - first;
- /* y1 is now the real beginning of row on the screen */
+ // y1 is now the real beginning of row on the screen
while (row != 0 && y < y2) {
text->GetVisibleRow(y, row, y + first);
row = row->next;
}
- /* maybe we have to clear the screen at the bottom */
+ // maybe we have to clear the screen at the bottom
if (y < y2) {
owner.getPainter().fillRectangle(0, y,
owner.workWidth(),
{
if (cursor_visible) HideCursor();
- //if (y < 0) y = 0;
unsigned long old_first = first;
first = y;
- /* is any optimiziation possible? */
+ // is any optimiziation possible?
if ((y - old_first) < owner.height()
&& (old_first - y) < owner.height()) {
if (first < old_first) {
owner.workWidth(), first - old_first);
}
} else {
- /* make a dumb new-draw */
+ // make a dumb new-draw
DrawFromTo(0, owner.height());
expose(0, 0, owner.workWidth(), owner.height());
}
long newtop = first;
if (y + desc - first >= owner.height())
- newtop = y - 3 * owner.height() / 4; /* the scroll region must be so big!! */
+ newtop = y - 3 * owner.height() / 4; // the scroll region must be so big!!
else if (y - asc < long(first)
&& first > 0) {
newtop = y - owner.height() / 4;
}
- //if (newtop < 0)
+
newtop = max(newtop, 0L); // can newtop ever be < 0? (Lgb)
if (newtop != long(first)) {
unsigned long y2 = min(y - first + desc, ulong(owner.height()));
// Secure against very strange situations
- //if (y2 < y1) y2 = y1;
y2 = max(y2, y1);
if (cursor_pixmap){
newtop = text->cursor.y - text->cursor.row->baseline;
else {
newtop = text->cursor.y - owner.height() / 4;
- //if (newtop > long(first))
newtop = min(newtop, long(first));
}
}
- //if (newtop < 0)
- // newtop = 0;
+
newtop = max(newtop, 0L);
return newtop;
break;
case LyXText::NEED_VERY_LITTLE_REFRESH:
{
- /* ok I will update the current cursor row */
+ // ok I will update the current cursor row
DrawOneRow(text->refresh_row, text->refresh_y);
text->status = LyXText::UNCHANGED;
expose(0, text->refresh_y - first,
void LyXScreen::ToggleSelection(bool kill_selection)
{
- /* only if there is a selection */
+ // only if there is a selection
if (!text->selection) return;
- //long top = text->sel_start_cursor.y
- // - text->sel_start_cursor.row->baseline;
- //long bottom = text->sel_end_cursor.y
- // - text->sel_end_cursor.row->baseline
- // + text->sel_end_cursor.row->height;
-
- //top = max(top, first);
- //bottom = max(bottom, first);
-
- //bottom = min(max(bottom, first), first + owner.height());
- //top = min(max(top, first), first + owner.height());
long bottom = min(max(text->sel_end_cursor.y
- text->sel_end_cursor.row->baseline
+ text->sel_end_cursor.row->height, first),
- text->toggle_end_cursor.row->baseline
+ text->toggle_end_cursor.row->height;
- //top = max(top, first);
- //bottom = max(bottom, first);
typedef unsigned long ulong;
bottom = min(max(ulong(bottom), first), first + owner.height());
// what about underbars?
if (font.underbar() == LyXFont::ON && font.latex() != LyXFont::ON) {
- pain.line(tmpx, offset + row->baseline + 2,
- x, offset + row->baseline + 2);
+ pain.line(int(tmpx), offset + row->baseline + 2,
+ int(x), offset + row->baseline + 2);
}
void LyXText::SelectWord()
{
- /* Move cursor to the beginning, when not already there. */
+ // Move cursor to the beginning, when not already there.
if ( cursor.pos
&& !cursor.par->IsSeparator(cursor.pos-1)
&& !cursor.par->IsKomma(cursor.pos-1) )
CursorLeftOneWord();
- /* set the sel cursor */
+ // set the sel cursor
sel_cursor = cursor;
while ( cursor.pos < cursor.par->Last()
cursor.pos++;
SetCursor( cursor.par, cursor.pos );
- /* finally set the selection */
+ // finally set the selection
SetSelection();
}
if ( (sel_start_cursor.row != row_ptr && !is_rtl) ||
(sel_end_cursor.row != row_ptr && is_rtl))
pain.fillRectangle(0, offset,
- tmpx, row_ptr->height,
+ int(tmpx), row_ptr->height,
LColor::selection);
if (row_ptr->par->table) {
float x_old = x;
sel_start_cursor.pos <= pos) &&
(sel_end_cursor.row != row_ptr ||
pos < sel_end_cursor.pos) )
- pain.fillRectangle(old_tmpx, offset,
- tmpx - old_tmpx + 1,
+ pain.fillRectangle(int(old_tmpx), offset,
+ int(tmpx - old_tmpx + 1),
row_ptr->height,
LColor::selection);
}
sel_start_cursor.pos <= pos) &&
(sel_end_cursor.row != row_ptr ||
pos < sel_end_cursor.pos) )
- pain.fillRectangle(old_tmpx, offset,
- tmpx - old_tmpx + 1,
+ pain.fillRectangle(int(old_tmpx), offset,
+ int(tmpx - old_tmpx + 1),
row_ptr->height,
LColor::selection);
}
}
if ( (sel_start_cursor.row != row_ptr && is_rtl) ||
(sel_end_cursor.row != row_ptr && !is_rtl) )
- pain.fillRectangle(tmpx, offset,
- paperwidth - tmpx,
+ pain.fillRectangle(int(tmpx), offset,
+ int(paperwidth - tmpx),
row_ptr->height,
LColor::selection);
}
/* the cursor set functions have a special mechanism. When they
-* realize, that you left an empty paragraph, they will delete it.
-* They also delet the corresponding row */
+ * realize, that you left an empty paragraph, they will delete it.
+ * They also delete the corresponding row */
// need the selection cursor:
void LyXText::SetSelection()
selection = true;
// first the toggling area
- if (cursor.y < last_sel_cursor.y ||
- (cursor.y == last_sel_cursor.y && cursor.x < last_sel_cursor.x)) {
+ if (cursor.y < last_sel_cursor.y
+ || (cursor.y == last_sel_cursor.y
+ && cursor.x < last_sel_cursor.x)) {
toggle_end_cursor = last_sel_cursor;
toggle_cursor = cursor;
- }
- else {
+ } else {
toggle_end_cursor = cursor;
toggle_cursor = last_sel_cursor;
}
if (sel_start_cursor.x == sel_end_cursor.x &&
sel_start_cursor.y == sel_end_cursor.y)
selection = false;
+
+ // Stuff what we got on the clipboard. Even if there is no selection.
+
+ // There is a problem with having the stuffing here in that the
+ // larger the selection the slower LyX will get. This can be
+ // solved by running the line below only when the selection has
+ // finished. The solution used currently just works, to make it
+ // faster we need to be more clever and probably also have more
+ // calls to stuffClipboard. (Lgb)
+ owner_->stuffClipboard(selectionAsString());
+}
+
+
+string LyXText::selectionAsString() const
+{
+ if (!selection) return string();
+ string result;
+
+ // Special handling if the whole selection is within one paragraph
+ if (sel_start_cursor.par == sel_end_cursor.par) {
+ result += sel_start_cursor.par->String(sel_start_cursor.pos,
+ sel_end_cursor.pos);
+ return result;
+ }
+
+ // The selection spans more than one paragraph
+
+ // First paragraph in selection
+ result += sel_start_cursor.par->String(sel_start_cursor.pos,
+ sel_start_cursor.par->Last());
+
+ // The paragraphs in between (if any)
+ LyXCursor tmpcur(sel_start_cursor);
+ tmpcur.par = tmpcur.par->Next();
+ while (tmpcur.par != sel_end_cursor.par) {
+ result += tmpcur.par->String(false);
+ tmpcur.par = tmpcur.par->Next(); // Or NextAfterFootnote??
+ }
+
+ // Last paragraph in selection
+ result += sel_end_cursor.par->String(0, sel_end_cursor.pos);
+
+ return result;
}