some sun compile fixes the need clipboard code patch from Dekel ans some other fixes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@753 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-05-20 21:37:05 +00:00
parent f007271216
commit 556970623c
40 changed files with 361 additions and 140 deletions

View File

@ -1,5 +1,32 @@
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

View File

@ -185,7 +185,7 @@ dnl Check the version of g++
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
@ -195,7 +195,7 @@ dnl Check the version of g++
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

View File

@ -185,7 +185,7 @@ dnl Check the version of g++
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
@ -195,7 +195,7 @@ dnl Check the version of g++
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

View File

@ -406,7 +406,7 @@ argument: 0
Name: form_toc
Width: 420
Height: 340
Number of Objects: 4
Number of Objects: 5
--------------------
class: FL_BOX
@ -480,6 +480,24 @@ name:
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

View File

@ -328,8 +328,14 @@ void BufferView::center()
#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

View File

@ -226,7 +226,9 @@ public:
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;

View File

@ -160,6 +160,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
owner_->updateWindowTitle();
}
void BufferView::Pimpl::resize(int xpos, int ypos, int width, int height)
{
workarea->resize(xpos, ypos, width, height);
@ -497,11 +498,11 @@ int BufferView::Pimpl::scrollDown(long time)
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) {
@ -844,7 +845,6 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
// 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){
@ -1493,7 +1493,7 @@ void BufferView::Pimpl::center()
#ifdef XFORMS_CLIPBOARD
void BufferView::Pimpl::pasteSelection(bool asPara)
void BufferView::Pimpl::pasteClipboard(bool asPara)
{
if (buffer_ == 0) return;
@ -1511,4 +1511,10 @@ void BufferView::Pimpl::pasteSelection(bool asPara)
}
update(1);
}
void BufferView::Pimpl::stuffClipboard(string const & stuff) const
{
workarea->putClipboard(stuff);
}
#endif

View File

@ -142,7 +142,9 @@ struct BufferView::Pimpl {
UpdateInset updatelist;
#ifdef XFORMS_CLIPBOARD
///
void pasteSelection(bool asPara);
void pasteClipboard(bool asPara);
///
void stuffClipboard(string const &) const;
#endif
private:
bool using_xterm_cursor;

View File

@ -165,12 +165,13 @@ LColor::color LColor::getFromGUIName(string const & guiname) const
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

View File

@ -262,10 +262,16 @@ void LyXAction::init()
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 },

View File

@ -363,7 +363,8 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
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)
{
@ -372,12 +373,12 @@ int request_clipboard_cb(FL_OBJECT * /*ob*/, long /*type*/,
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
{

View File

@ -3797,14 +3797,14 @@ vector<vector<Buffer::TocItem> > Buffer::getTocList()
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:
@ -3824,7 +3824,7 @@ vector<vector<Buffer::TocItem> > Buffer::getTocList()
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;
@ -3980,4 +3980,5 @@ void Buffer::inset_iterator::SetParagraph() {
par = par->next;
}
//it = 0;
// We maintain an invariant that whenever par = 0 then it = 0
}

View File

@ -299,6 +299,17 @@ public:
string str;
};
///
enum TocType {
///
TOC_TOC = 0,
///
TOC_LOF,
///
TOC_LOT,
///
TOC_LOA
};
///
std::vector<std::vector<TocItem> > getTocList();
///
std::vector<string> getLabelList();
@ -420,6 +431,7 @@ private:
*/
BufferView * users;
public:
class inset_iterator {
public:
inset_iterator() : par(0) /*, it(0)*/ {}
@ -440,18 +452,23 @@ private:
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);

View File

@ -247,6 +247,9 @@ enum kb_action {
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 */
};

View File

@ -1058,7 +1058,7 @@ void InsetFig::draw(Painter & pain, LyXFont const & f,
} 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]");

View File

@ -138,7 +138,7 @@ void InsetGraphics::draw(Painter & pain, LyXFont const & font,
{
// 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));
}

View File

@ -345,7 +345,7 @@ bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & 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;
}
@ -417,56 +417,56 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
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;
@ -476,21 +476,21 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
{
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
@ -524,17 +524,17 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
}
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;
@ -543,8 +543,8 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
{
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;
}

View File

@ -19,6 +19,10 @@
#include "insetloa.h"
#include "LaTeXFeatures.h"
#include "BufferView.h"
#include "LyXView.h"
#include "lyxfunc.h"
#include "commandtags.h"
void InsetLOA::Validate(LaTeXFeatures & features) const
{
@ -30,3 +34,8 @@ string InsetLOA::getScreenLabel() const
{
return _("List of Algorithms");
}
void InsetLOA::Edit(BufferView * bv, int, int, unsigned int)
{
bv->owner()->getLyXFunc()->Dispatch(LFUN_LOAVIEW);
}

View File

@ -36,10 +36,11 @@ public:
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; }

View File

@ -4,10 +4,18 @@
#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);
}

View File

@ -21,7 +21,7 @@
#pragma interface
#endif
class Buffer;
class Buffer;
/** Used to insert table of contents
*/
@ -36,10 +36,11 @@ public:
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; }

View File

@ -4,11 +4,19 @@
#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);
}

View File

@ -36,10 +36,11 @@ public:
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; }

View File

@ -184,12 +184,19 @@ private:
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
@ -246,6 +253,7 @@ private:
typedef std::vector<row_struct> RowList;
///
mutable RowList rows;
///
InsetText & operator = (InsetText const & it) {
par = it.par;
buffer = it.buffer; // suspect

View File

@ -5,8 +5,6 @@
#endif
#include "insettoc.h"
#include "buffer.h"
#include "bufferlist.h"
#include "commandtags.h"
#include "lyxfunc.h"
#include "LyXView.h"

View File

@ -130,6 +130,9 @@ FD_form_toc *create_form_form_toc(void)
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;

View File

@ -63,6 +63,7 @@ typedef struct {
char *cdata;
long ldata;
FL_OBJECT *browser_toc;
FL_OBJECT *toctype;
} FD_form_toc;
extern FD_form_toc * create_form_form_toc(void);

View File

@ -57,6 +57,7 @@ using std::istream_iterator;
using std::pair;
using std::vector;
using std::sort;
using std::equal;
extern Combox * combo_language;
extern Combox * combo_language2;
@ -3134,7 +3135,8 @@ extern "C" void TocCancelCB(FL_OBJECT *, long)
}
extern "C" void TocUpdateCB(FL_OBJECT *, long)
extern "C"
void TocUpdateCB(FL_OBJECT *, long)
{
if (!current_view->available()) {
toclist.clear();
@ -3146,9 +3148,14 @@ extern "C" void TocUpdateCB(FL_OBJECT *, long)
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;

View File

@ -558,6 +558,8 @@ void LyXGUI::create_forms()
// 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

View File

@ -161,11 +161,11 @@ extern "C" void error_handler(int err_sig);
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

View File

@ -657,7 +657,7 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const
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";

View File

@ -811,6 +811,18 @@ string LyXFunc::Dispatch(int ac,
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);
@ -827,7 +839,7 @@ string LyXFunc::Dispatch(int ac,
fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
}
break;
}
case LFUN_TOC_INSERT:
{
Inset * new_inset = new InsetTOC(owner->buffer());
@ -908,7 +920,7 @@ string LyXFunc::Dispatch(int ac,
bool asPara = false;
if (argument == "paragraph") asPara = true;
#ifdef XFORMS_CLIPBOARD
owner->view()->pasteSelection(asPara);
owner->view()->pasteClipboard(asPara);
#else
MenuPasteSelection(asPara);
#endif

View File

@ -167,7 +167,7 @@ int LyXLookupString(XEvent * event,
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,

View File

@ -134,6 +134,8 @@ public:
bool isMultiLingual();
///
string String(bool label);
///
string String(size_type beg, size_type end);
///
void writeFile(std::ostream &, BufferParams const &, char, char) const;

View File

@ -227,7 +227,9 @@ public:
void SetSelection();
///
void ClearSelection() const;
///
string selectionAsString() const;
/// just selects the word the cursor is in
void SelectWord();

View File

@ -1133,7 +1133,10 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
"|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"
@ -1149,14 +1152,17 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
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())
@ -1173,8 +1179,8 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
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,
@ -1203,11 +1209,14 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
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;
@ -1442,10 +1451,9 @@ void Menus::ShowRefsMenu(FL_OBJECT * ob, long)
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,

View File

@ -40,6 +40,7 @@ using std::fstream;
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
@ -4268,7 +4269,7 @@ string LyXParagraph::String(bool label)
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;
@ -4295,3 +4296,36 @@ string LyXParagraph::String(bool label)
}
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;
}

View File

@ -50,7 +50,7 @@ LyXScreen::LyXScreen(WorkArea & o, LyXText * text_ptr)
{
first = 0;
/* the cursor isnt yet visible */
// the cursor isnt yet visible
cursor_visible = false;
cursor_pixmap = 0;
cursor_pixmap_x = 0;
@ -91,12 +91,12 @@ void LyXScreen::DrawFromTo(int y1, int y2)
{
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);
@ -104,7 +104,7 @@ void LyXScreen::DrawFromTo(int y1, int y2)
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(),
@ -131,11 +131,10 @@ void LyXScreen::Draw(unsigned long y)
{
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) {
@ -174,7 +173,7 @@ void LyXScreen::Draw(unsigned long y)
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());
}
@ -205,12 +204,12 @@ bool LyXScreen::FitManualCursor(long /*x*/, long y, int asc, int desc)
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)) {
@ -231,7 +230,6 @@ void LyXScreen::ShowManualCursor(long x, long y, int asc, int desc,
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){
@ -351,12 +349,10 @@ unsigned long LyXScreen::TopCursorVisible()
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;
@ -392,7 +388,7 @@ void LyXScreen::Update()
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,
@ -408,20 +404,9 @@ void LyXScreen::Update()
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),
@ -451,8 +436,6 @@ void LyXScreen::ToggleToggle()
- 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());

View File

@ -594,8 +594,8 @@ void LyXText::draw(Row const * row,
// 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);
}
@ -2998,13 +2998,13 @@ void LyXText::CursorLeftOneWord() const
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()
@ -3013,7 +3013,7 @@ void LyXText::SelectWord()
cursor.pos++;
SetCursor( cursor.par, cursor.pos );
/* finally set the selection */
// finally set the selection
SetSelection();
}
@ -3702,7 +3702,7 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
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;
@ -3721,8 +3721,8 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
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);
}
@ -3759,16 +3759,16 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
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);
}

View File

@ -1006,8 +1006,8 @@ bool LyXText::FullRebreak()
/* 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()
@ -1021,12 +1021,12 @@ 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;
}
@ -1057,6 +1057,49 @@ void LyXText::SetSelection()
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;
}