}
-LScreen & BufferView::screen() const
+LyXScreen & BufferView::screen() const
{
return pimpl_->screen();
}
class LyXText;
class TeXErrors;
class Buffer;
-class LScreen;
+class LyXScreen;
class Language;
class Painter;
class UpdatableInset;
///
Painter & painter() const;
///
- LScreen & screen() const;
+ LyXScreen & screen() const;
///
void buffer(Buffer * b);
///
locking_inset))
text->setCursor(this, cursor,
cursor.par(), cursor.pos() - 1);
- LScreen::Cursor_Shape shape = LScreen::BAR_SHAPE;
+ LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE;
LyXText * txt = getLyXText();
if (locking_inset->isTextInset() &&
locking_inset->lyxCode() != Inset::ERT_CODE &&
|| txt->real_current_font.isVisibleRightToLeft()
!= buffer()->params.language->RightToLeft()))
shape = (txt->real_current_font.isVisibleRightToLeft())
- ? LScreen::REVERSED_L_SHAPE
- : LScreen::L_SHAPE;
+ ? LyXScreen::REVERSED_L_SHAPE
+ : LyXScreen::L_SHAPE;
y += cursor.iy() + theLockingInset()->insetInInsetY();
screen().showManualCursor(text, x, y, asc, desc,
shape);
{
if (theLockingInset() && available()) {
y += text->cursor.iy() + theLockingInset()->insetInInsetY();
- if (screen().fitManualCursor(text, this, x, y, asc, desc)) {
+ if (screen().fitManualCursor(this, text, x, y, asc, desc)) {
updateScrollbar();
return true;
}
#include "BufferView_pimpl.h"
#include "frontends/WorkArea.h"
#include "frontends/screen.h"
+#include "frontends/LyXScreenFactory.h"
+#include "frontends/WorkAreaFactory.h"
#include "frontends/Dialogs.h"
#include "frontends/Alert.h"
#include "frontends/FileDialog.h"
const unsigned int saved_positions_num = 20;
-inline
-void waitForX()
-{
- XSync(fl_get_display(), 0);
-}
-
-
-void SetXtermCursor(Window win)
-{
- static Cursor cursor;
- static bool cursor_undefined = true;
- if (cursor_undefined) {
- cursor = XCreateFontCursor(fl_get_display(), XC_xterm);
- XFlush(fl_get_display());
- cursor_undefined = false;
- }
- XDefineCursor(fl_get_display(), win, cursor);
- XFlush(fl_get_display());
-}
} // anon namespace
: bv_(b), owner_(o), buffer_(0), cursor_timeout(400),
using_xterm_cursor(false)
{
- workarea_.reset(new WorkArea(xpos, ypos, width, height));
- screen_.reset(new LScreen(workarea()));
+ workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height));
+ screen_.reset(LyXScreenFactory::create(workarea()));
// Setup the signals
workarea().scrollDocView.connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
}
-LScreen & BufferView::Pimpl::screen() const
+LyXScreen & BufferView::Pimpl::screen() const
{
return *screen_.get();
}
void BufferView::Pimpl::updateScreen()
{
// Regenerate the screen.
- screen().reset();
+ screen().redraw(bv_->text, bv_);
}
screen().draw(bv_->text, bv_, value);
if (!lyxrc.cursor_follows_scrollbar) {
- waitForX();
return;
}
vbt->setCursorFromCoordinates(bv_, 0, first);
else if (vbt->cursor.y() > last)
vbt->setCursorFromCoordinates(bv_, 0, last);
-
- waitForX();
}
}
-void BufferView::Pimpl::workAreaKeyPress(KeySym key, key_modifier::state state)
+void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
+ key_modifier::state state)
{
bv_->owner()->getLyXFunc()->processKeySym(key, state);
}
LyXText * lt = bv_->getLyXText();
if (!lt->selection.set()) {
- if (owner_->getIntl()->getTrans().backspace()) {
+ if (owner_->getIntl()->getTransManager().backspace()) {
lt->backspace(bv_);
lt->selection.cursor = lt->cursor;
update(lt,
owner_->getLyXFunc()->handleKeyFunc(action);
} else {
owner_->getLyXFunc()->handleKeyFunc(action);
- owner_->getIntl()->getTrans()
+ owner_->getIntl()->getTransManager()
.TranslateAndInsert(argument[0], bv_->getLyXText());
update(bv_->getLyXText(),
BufferView::SELECT
}
break;
+ case LFUN_MATH:
+ mathDispatch(bv_, argument);
+ break;
+
case LFUN_MATH_MACRO:
mathDispatchMathMacro(bv_, argument);
break;
string::const_iterator cit = argument.begin();
string::const_iterator end = argument.end();
for (; cit != end; ++cit) {
- owner_->getIntl()->getTrans().TranslateAndInsert(*cit, lt);
+ owner_->getIntl()->getTransManager().
+ TranslateAndInsert(*cit, lt);
}
bv_->update(lt,
#include "frontends/Timeout.h"
#include "frontends/key_state.h"
#include "frontends/mouse_state.h"
+#include "frontends/LyXKeySym.h"
#include "box.h"
#include "insets/insetspecialchar.h"
#include "support/types.h"
class LyXView;
class WorkArea;
-class LScreen;
-
-// FIXME: remove
-#include <X11/Xlib.h>
+class LyXScreen;
///
struct BufferView::Pimpl : public boost::signals::trackable {
/// return the work area for this bview
WorkArea & workarea() const;
/// return the screen for this bview
- LScreen & screen() const;
+ LyXScreen & screen() const;
///
void buffer(Buffer *);
///
/// wheel mouse scroll
int scroll(long time);
///
- void workAreaKeyPress(KeySym key, key_modifier::state state);
+ void workAreaKeyPress(LyXKeySymPtr key,
+ key_modifier::state state);
///
void workAreaMotionNotify(int x, int y, mouse_button::state state);
///
///
Buffer * buffer_;
///
- boost::scoped_ptr<LScreen> screen_;
+ boost::scoped_ptr<LyXScreen> screen_;
///
boost::scoped_ptr<WorkArea> workarea_;
///
+2002-06-16 <alstrup@diku.dk>
+
+ * BufferView_pimpl.C (Pimpl): Use WorkAreaFactory.
+ Got rid of FORMS_H_LOCATION include. Now we are
+ GUII.
+
+2002-06-15 LyX Development team <lyx@rilke>
+
+ * buffer.[Ch] (sgmlOpenTag):
+ (sgmlCloseTag): Added support for avoiding pernicious mixed
+ content. Return number of lines written.
+
+ (makeLinuxDocFile):
+ (makeDocBookFile): Fixed calls to sgml*Tag.
+ Simple white space clean.
+
+ (simpleDocBookOnePar): Simple white space clean.
+
+ * tabular.[Ch] (docBook): Renamed to docbook and got another
+ argument to related with the pernicious mixed content.
+
+ (docbookRow): Fixed calls for docbook inset method.
+
+2002-06-15 Lyx Development team <larsbj@birdstep.com>
+
+ * lyxfunc.[Ch]: Use LyXKeySym instead of KeySym,
+ so it's X11 independent.
+
+ * kb*.[Ch]: ditto.
+
+ * BufferView_pimpl.[Ch] (workAreaKeyPress): ditto.
+
+2002-06-15 Lyx Development team <lyx@electronia>
+
+ * intl.h: Renamed getTrans to getTransManager.
+
2002-06-14 Angus Leeming <leeming@lyx.org>
* Makefile.am: nuke forgotten stl_string_fwd.h.
{ LFUN_MARK_OFF, "mark-off", "", ReadOnly },
{ LFUN_MARK_ON, "mark-on", "", ReadOnly },
{ LFUN_SETMARK, "mark-toggle", "", ReadOnly },
+ { LFUN_MATH, "math", "", Noop },
{ LFUN_MATH_DELIM, "math-delim", "", Noop },
{ LFUN_MATH_DISPLAY, "math-display", "", Noop },
{ LFUN_GREEK, "math-greek", N_("Math Greek"), Noop },
} else if (file_format < 220) {
Alert::alert(_("ERROR!"),
_("Old LyX file format found. "
- "User LyX 1.2.x to read this!"));
+ "Use LyX 1.2.x to read this!"));
return false;
}
}
}
-void Buffer::sgmlOpenTag(ostream & os, Paragraph::depth_type,
+int Buffer::sgmlOpenTag(ostream & os, Paragraph::depth_type depth, bool mixcont,
string const & latexname) const
{
- if (!latexname.empty() && latexname != "!-- --")
- //os << "<!-- " << depth << " -->" << "<" << latexname << ">";
- os << "<" << latexname << ">";
+ if (!latexname.empty() && latexname != "!-- --") {
+ if (!mixcont)
+ os << string(" ",depth);
+ os << "<" << latexname << ">";
+ }
+
+ if (!mixcont)
+ os << endl;
+
+ return mixcont?0:1;
}
-void Buffer::sgmlCloseTag(ostream & os, Paragraph::depth_type,
+int Buffer::sgmlCloseTag(ostream & os, Paragraph::depth_type depth, bool mixcont,
string const & latexname) const
{
- if (!latexname.empty() && latexname != "!-- --")
- //os << "<!-- " << depth << " -->" << "</" << latexname << ">\n";
+ if (!latexname.empty() && latexname != "!-- --") {
+ if (!mixcont)
+ os << endl << string(" ",depth);
os << "</" << latexname << ">";
+ }
+
+ if (!mixcont)
+ os << endl;
+
+ return mixcont?0:1;
}
ofs << ">\n\n";
if (params.options.empty())
- sgmlOpenTag(ofs, 0, top_element);
+ sgmlOpenTag(ofs, 0, false, top_element);
else {
string top = top_element;
top += " ";
top += params.options;
- sgmlOpenTag(ofs, 0, top);
+ sgmlOpenTag(ofs, 0, false, top);
}
}
Inset::Code lyx_code = inset->lyxCode();
if (lyx_code == Inset::TOC_CODE) {
string const temp = "toc";
- sgmlOpenTag(ofs, depth, temp);
+ sgmlOpenTag(ofs, depth, false, temp);
par = par->next();
continue;
// environment tag closing
for (; depth > par->params().depth(); --depth) {
- sgmlCloseTag(ofs, depth, environment_stack[depth]);
+ sgmlCloseTag(ofs, depth, false, environment_stack[depth]);
environment_stack[depth].erase();
}
case LATEX_PARAGRAPH:
if (depth == par->params().depth()
&& !environment_stack[depth].empty()) {
- sgmlCloseTag(ofs, depth, environment_stack[depth]);
+ sgmlCloseTag(ofs, depth, false, environment_stack[depth]);
environment_stack[depth].erase();
if (depth)
--depth;
else
ofs << "</p>";
}
- sgmlOpenTag(ofs, depth, style.latexname());
+ sgmlOpenTag(ofs, depth, false, style.latexname());
break;
case LATEX_COMMAND:
" LatexType Command.\n"));
if (!environment_stack[depth].empty()) {
- sgmlCloseTag(ofs, depth,
- environment_stack[depth]);
+ sgmlCloseTag(ofs, depth, false, environment_stack[depth]);
ofs << "</p>";
}
environment_stack[depth].erase();
- sgmlOpenTag(ofs, depth, style.latexname());
+ sgmlOpenTag(ofs, depth, false, style.latexname());
break;
case LATEX_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT:
if (depth == par->params().depth()
&& environment_stack[depth] != style.latexname()) {
- sgmlCloseTag(ofs, depth,
- environment_stack[depth]);
+ sgmlCloseTag(ofs, depth, false, environment_stack[depth]);
environment_stack[depth].erase();
}
if (depth < par->params().depth()) {
}
if (environment_stack[depth] != style.latexname()) {
if (depth == 0) {
- sgmlOpenTag(ofs, depth, "p");
+ sgmlOpenTag(ofs, depth, false, "p");
}
- sgmlOpenTag(ofs, depth, style.latexname());
+ sgmlOpenTag(ofs, depth, false, style.latexname());
if (environment_stack.size() == depth + 1)
environment_stack.push_back("!-- --");
else
item_name = "item";
- sgmlOpenTag(ofs, depth + 1, item_name);
+ sgmlOpenTag(ofs, depth + 1, false, item_name);
break;
default:
- sgmlOpenTag(ofs, depth, style.latexname());
+ sgmlOpenTag(ofs, depth, false, style.latexname());
break;
}
ofs << "]]>";
break;
default:
- sgmlCloseTag(ofs, depth, style.latexname());
+ sgmlCloseTag(ofs, depth, false, style.latexname());
break;
}
}
// Close open tags
for (int i=depth; i >= 0; --i)
- sgmlCloseTag(ofs, depth, environment_stack[i]);
+ sgmlCloseTag(ofs, depth, false, environment_stack[i]);
if (!body_only) {
ofs << "\n\n";
- sgmlCloseTag(ofs, 0, top_element);
+ sgmlCloseTag(ofs, 0, false, top_element);
}
ofs.close();
top += " ";
top += params.options;
}
- sgmlOpenTag(ofs, 0, top);
+ sgmlOpenTag(ofs, 0, false, top);
ofs << "<!-- DocBook file was created by " << lyx_docversion
<< "\n See http://www.lyx.org/ for more information -->\n";
for (; depth > par->params().depth(); --depth) {
if (environment_inner[depth] != "!-- --") {
item_name = "listitem";
- sgmlCloseTag(ofs, command_depth + depth,
- item_name);
+ sgmlCloseTag(ofs, command_depth + depth, false, item_name);
if (environment_inner[depth] == "varlistentry")
- sgmlCloseTag(ofs, depth+command_depth,
- environment_inner[depth]);
+ sgmlCloseTag(ofs, depth+command_depth, false, environment_inner[depth]);
}
- sgmlCloseTag(ofs, depth + command_depth,
- environment_stack[depth]);
+ sgmlCloseTag(ofs, depth + command_depth, false, environment_stack[depth]);
environment_stack[depth].erase();
environment_inner[depth].erase();
}
&& !environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") {
item_name= "listitem";
- sgmlCloseTag(ofs, command_depth+depth,
- item_name);
+ sgmlCloseTag(ofs, command_depth+depth, false, item_name);
if (environment_inner[depth] == "varlistentry")
- sgmlCloseTag(ofs,
- depth + command_depth,
- environment_inner[depth]);
+ sgmlCloseTag(ofs, depth + command_depth, false, environment_inner[depth]);
}
- sgmlCloseTag(ofs, depth + command_depth,
- environment_stack[depth]);
+ sgmlCloseTag(ofs, depth + command_depth, false, environment_stack[depth]);
environment_stack[depth].erase();
environment_inner[depth].erase();
// Write opening SGML tags.
switch (style.latextype) {
case LATEX_PARAGRAPH:
- sgmlOpenTag(ofs, depth + command_depth,
- style.latexname());
+ sgmlOpenTag(ofs, depth + command_depth, false, style.latexname());
break;
case LATEX_COMMAND:
if (cmd_depth < command_base) {
for (Paragraph::depth_type j = command_depth;
j >= command_base; --j) {
- sgmlCloseTag(ofs, j, command_stack[j]);
+ sgmlCloseTag(ofs, j, false, command_stack[j]);
ofs << endl;
}
command_depth = command_base = cmd_depth;
} else if (cmd_depth <= command_depth) {
for (int j = command_depth;
j >= int(cmd_depth); --j) {
- sgmlCloseTag(ofs, j, command_stack[j]);
+ sgmlCloseTag(ofs, j, false, command_stack[j]);
ofs << endl;
}
command_depth = cmd_depth;
}
}
- sgmlOpenTag(ofs, depth + command_depth, command_name);
- if (c_params.empty())
- item_name = "title";
- else
- item_name = c_params;
- sgmlOpenTag(ofs, depth + 1 + command_depth, item_name);
+ sgmlOpenTag(ofs, depth + command_depth, false, command_name);
+
+ item_name = c_params.empty()?"title":c_params;
+ sgmlOpenTag(ofs, depth + 1 + command_depth, false, item_name);
break;
case LATEX_ENVIRONMENT:
}
environment_stack[depth] = style.latexname();
environment_inner[depth] = "!-- --";
- sgmlOpenTag(ofs, depth + command_depth,
- environment_stack[depth]);
+ sgmlOpenTag(ofs, depth + command_depth, false, environment_stack[depth]);
} else {
if (environment_inner[depth] != "!-- --") {
item_name= "listitem";
- sgmlCloseTag(ofs,
- command_depth + depth,
- item_name);
+ sgmlCloseTag(ofs, command_depth + depth, false, item_name);
if (environment_inner[depth] == "varlistentry")
- sgmlCloseTag(ofs,
- depth + command_depth,
- environment_inner[depth]);
+ sgmlCloseTag(ofs, depth + command_depth, false, environment_inner[depth]);
}
}
if (style.latexparam() == "CDATA")
ofs << "<![CDATA[";
else
- sgmlOpenTag(ofs, depth + command_depth,
- style.latexparam());
+ sgmlOpenTag(ofs, depth + command_depth, false, style.latexparam());
}
break;
}
desc_on = (style.labeltype == LABEL_MANUAL);
- if (desc_on)
- environment_inner[depth]= "varlistentry";
- else
- environment_inner[depth]= "listitem";
-
- sgmlOpenTag(ofs, depth + 1 + command_depth,
- environment_inner[depth]);
+ environment_inner[depth] = desc_on?"varlistentry": "listitem";
+ sgmlOpenTag(ofs, depth + 1 + command_depth, false, environment_inner[depth]);
- if (desc_on) {
- item_name= "term";
- sgmlOpenTag(ofs, depth + 1 + command_depth,
- item_name);
- } else {
- item_name= "para";
- sgmlOpenTag(ofs, depth + 1 + command_depth,
- item_name);
- }
+ item_name = desc_on? "term": "para";
+ sgmlOpenTag(ofs, depth + 1 + command_depth, false, item_name);
break;
default:
- sgmlOpenTag(ofs, depth + command_depth,
- style.latexname());
+ sgmlOpenTag(ofs, depth + command_depth, false, style.latexname());
break;
}
// write closing SGML tags
switch (style.latextype) {
case LATEX_COMMAND:
- if (c_params.empty())
- end_tag = "title";
- else
- end_tag = c_params;
- sgmlCloseTag(ofs, depth + command_depth, end_tag);
+ end_tag = c_params.empty()?"title":c_params;
+ sgmlCloseTag(ofs, depth + command_depth, false, end_tag);
break;
case LATEX_ENVIRONMENT:
if (!style.latexparam().empty()) {
if (style.latexparam() == "CDATA")
ofs << "]]>";
else
- sgmlCloseTag(ofs, depth + command_depth,
- style.latexparam());
+ sgmlCloseTag(ofs, depth + command_depth, false, style.latexparam());
}
break;
case LATEX_ITEM_ENVIRONMENT:
if (desc_on == 1) break;
end_tag= "para";
- sgmlCloseTag(ofs, depth + 1 + command_depth, end_tag);
+ sgmlCloseTag(ofs, depth + 1 + command_depth, false, end_tag);
break;
case LATEX_PARAGRAPH:
- sgmlCloseTag(ofs, depth + command_depth, style.latexname());
+ sgmlCloseTag(ofs, depth + command_depth, false, style.latexname());
break;
default:
- sgmlCloseTag(ofs, depth + command_depth, style.latexname());
+ sgmlCloseTag(ofs, depth + command_depth, false, style.latexname());
break;
}
}
if (!environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") {
item_name = "listitem";
- sgmlCloseTag(ofs, command_depth + depth,
- item_name);
+ sgmlCloseTag(ofs, command_depth + depth, false, item_name);
if (environment_inner[depth] == "varlistentry")
- sgmlCloseTag(ofs, depth + command_depth,
- environment_inner[depth]);
+ sgmlCloseTag(ofs, depth + command_depth, false, environment_inner[depth]);
}
- sgmlCloseTag(ofs, depth + command_depth,
- environment_stack[depth]);
+ sgmlCloseTag(ofs, depth + command_depth, false, environment_stack[depth]);
}
}
for (int j = command_depth; j >= 0 ; --j)
if (!command_stack[j].empty()) {
- sgmlCloseTag(ofs, j, command_stack[j]);
+ sgmlCloseTag(ofs, j, false, command_stack[j]);
ofs << endl;
}
ofs << "\n\n";
- sgmlCloseTag(ofs, 0, top_element);
+ sgmlCloseTag(ofs, 0, false, top_element);
ofs.close();
// How to check for successful close
{
bool emph_flag = false;
- LyXLayout const & style =
- textclasslist[params.textclass][par->layout()];
+ LyXLayout const & style = textclasslist[params.textclass][par->layout()];
LyXFont font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
if ( i || desc_on != 3) {
if(style.latexparam() == "CDATA")
os << "]]>";
- inset->docbook(this, os);
+ inset->docbook(this, os, false);
if(style.latexparam() == "CDATA")
os << "<![CDATA[";
}
void makeDocBookFile(string const & filename,
bool nice, bool only_body = false);
/// Open SGML/XML tag.
- void sgmlOpenTag(std::ostream & os, Paragraph::depth_type depth,
+ int sgmlOpenTag(std::ostream & os, Paragraph::depth_type depth, bool mixcont,
string const & latexname) const;
/// Closes SGML/XML tag.
- void sgmlCloseTag(std::ostream & os, Paragraph::depth_type depth,
+ int sgmlCloseTag(std::ostream & os, Paragraph::depth_type depth, bool mixcont,
string const & latexname) const;
///
void sgmlError(Paragraph * par, int pos, string const & message) const;
LFUN_INSERT_MATH,
LFUN_INSERT_MATRIX,
LFUN_GREEK, // 110
+ LFUN_MATH, // Andre' 2002-06-14
LFUN_MATH_LIMITS,
LFUN_GREEK_TOGGLE,
LFUN_MATH_DELIM, // Alejandro 180696
+2002-06-16 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * add a nother layer of inderection for calling gui specific
+ methods.
+ * guiapi.h: new file
+
+2002-06-16 <alstrup@diku.dk>
+
+ * WorkArea.C: New file for GUII.
+
+ * WorkAreaFactory.h: New file for GUII.
+
+ * WorkArea.h: GUII stuff.
+
+2002-06-15 Lyx Development team <larsbj@birdstep.com>
+
+ * LyXKeySymFactory.h: Added GUII factory for LyXKeySyms.
+
+ * LyXKeySym.[Ch]: Made the LyXKeySym class GUII.
+
+ * LyXKeySym.[Ch]: new LyXKeySym class for representing a
+ keypress. For now, X11 dependent.
+
+ * Makefile.am: Added LyXKeySym.
+
+2002-06-14 Lyx Development team <lyx@electronia>
+
+ * LyXScreenFactory.h: New factory for creating the screen
+ object in the super GUII way.
+
+ * screen.h: Made LyXScreen an abstract base class for the
+ screen object.
+
+ * LyXView.h: Moved last_textclass_ member to Toolbar.C where it
+ belongs.
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* Painter.h:
* Painter.C: s/PainterBase/Painter, remove dead code
-
+
2002-06-12 Angus Leeming <leeming@lyx.org>
- * lyx_gui.h: remove trailing semi-colon after the brace closing
+ * lyx_gui.h: remove trailing semi-colon after the brace closing
the namespace.
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* LyXView.h: cleanup
* LyXView.C: move init() here from xforms/
-
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* screen.h:
* screen.C: change topCursorVisible() prototype
-
+
2002-06-12 Angus Leeming <leeming@lyx.org>
- * font_metrics.h: remove trailing semi-colon after the brace closing
+ * font_metrics.h: remove trailing semi-colon after the brace closing
the namespace.
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* GUIRunTime.h: remove in favour of ...
* Makefile.am:
- * lyx_gui.h: ... namespace for GUI start up
-
- * LyXView.h: remove init(),show(),setPosition()
-
+ * lyx_gui.h: ... namespace for GUI start up
+
+ * LyXView.h: remove init(),show(),setPosition()
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* Menubar.C:
* Timeout.h:
* Toolbar.C:
* LyXView.h:
- * LyXView.C: some cleanup, prefer scoped_ptr
-
+ * LyXView.C: some cleanup, prefer scoped_ptr
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* screen.C:
* Painter.C: use workHeight()
* WorkArea.h: remove confusing duplicate unused code
-
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* screen.h:
* screen.C: rename, add reset()
-
+
2002-06-11 John Levon <moz@compsoc.man.ac.uk>
* font_metrics.h: move X-specific stuff out of namespace
-
+
2002-06-07 Angus Leeming <leeming@lyx.org>
Fixes needed to compile with Compaq cxx 6.5.
2002-05-31 John Levon <moz@compsoc.man.ac.uk>
* Alert.h: better variable name
-
+
2002-05-29 Lars Gullik Bjønnes <larsbj@birdstep.com>
* switch from SigC signals to boost::signals
#endif
#include "Dialogs.h"
+
#include "support/LAssert.h"
+#include "guiapi.h"
+
// Signal enabling all visible dialogs to be redrawn if so desired.
// E.g., when the GUI colours have been remapped.
boost::signal0<void> Dialogs::redrawGUI;
+extern LyXView * dialogs_lyxview;
+
// toggle tooltips on/off in all dialogs.
boost::signal0<void> Dialogs::toggleTooltips;
-void Dialogs::add(DialogBase * ptr)
+void Dialogs::showAboutlyx()
+{
+ gui_ShowAboutlyx(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showBibitem(InsetCommand * ic)
+{
+ gui_ShowBibitem(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showBibtex(InsetCommand * ic)
+{
+ gui_ShowBibtex(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showCharacter()
+{
+ gui_ShowCharacter(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::setUserFreeFont()
+{
+ gui_SetUserFreeFont(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showCitation(InsetCommand * ic)
+{
+ gui_ShowCitation(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::createCitation(string const & s)
+{
+ gui_CreateCitation(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showDocument()
+{
+ gui_ShowDocument(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showError(InsetError * ie)
+{
+ gui_ShowError(ie, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showERT(InsetERT * ie)
+{
+ gui_ShowERT(ie, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::updateERT(InsetERT * ie)
+{
+ gui_UpdateERT(ie, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showExternal(InsetExternal * ie)
+{
+ gui_ShowExternal(ie, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showFile(string const & f)
+{
+ gui_ShowFile(f, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showFloat(InsetFloat * ifl)
+{
+ gui_ShowFloat(ifl, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showForks()
+{
+ gui_ShowForks(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showGraphics(InsetGraphics * ig)
+{
+ gui_ShowGraphics(ig, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showInclude(InsetInclude * ii)
+{
+ gui_ShowInclude(ii, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showIndex(InsetCommand * ic)
+{
+ gui_ShowIndex(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::createIndex(string const & s)
+{
+ gui_CreateIndex(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showInfo(InsetInfo * /*ii*/)
+{
+#if 0
+ gui_ShowInfo(ii, *dialogs_lyxview, *this);
+#endif
+}
+
+
+void Dialogs::showLogFile()
+{
+ gui_ShowLogFile(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showMathPanel()
+{
+ gui_ShowMathPanel(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showMinipage(InsetMinipage * im)
+{
+ gui_ShowMinipage(im, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::updateMinipage(InsetMinipage * im)
+{
+ gui_UpdateMinipage(im, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showParagraph()
+{
+ gui_ShowParagraph(*dialogs_lyxview, *this);
+}
+
+void Dialogs::updateParagraph()
+{
+#if 0
+ gui_UpdateParagraph(*dialogs_lyxview, *this);
+#endif
+}
+
+
+void Dialogs::showPreamble()
+{
+ gui_ShowPreamble(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showPreferences()
+{
+ gui_ShowPreferences(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showPrint()
+{
+ gui_ShowPrint(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showRef(InsetCommand * ic)
{
- lyx::Assert(ptr);
- dialogs_.push_back(db_ptr(ptr));
+ gui_ShowRef(ic, *dialogs_lyxview, *this);
}
+
+
+void Dialogs::createRef(string const & s)
+{
+ gui_CreateRef(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showSearch()
+{
+ gui_ShowSearch(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showSendto()
+{
+ gui_ShowSendto(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showSpellchecker()
+{
+ gui_ShowSpellchecker(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showSpellcheckerPreferences()
+{
+ gui_ShowSpellcheckerPreferences(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showTabular(InsetTabular * it)
+{
+ gui_ShowTabular(it, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::updateTabular(InsetTabular * it)
+{
+ gui_UpdateTabular(it, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showTabularCreate()
+{
+ gui_ShowTabularCreate(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showThesaurus(string const & s)
+{
+ gui_ShowThesaurus(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showTexinfo()
+{
+ gui_ShowTexinfo(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showTOC(InsetCommand * ic)
+{
+ gui_ShowTOC(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::createTOC(string const & s)
+{
+ gui_CreateTOC(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showUrl(InsetCommand * ic)
+{
+ gui_ShowUrl(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::createUrl(string const & s)
+{
+ gui_CreateUrl(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showVCLogFile()
+{
+ gui_ShowVCLogFile(*dialogs_lyxview, *this);
+}
+
+
+//void Dialogs::add(DialogBase * ptr)
+//{
+// lyx::Assert(ptr);
+// dialogs_.push_back(db_ptr(ptr));
+//}
#include <boost/shared_ptr.hpp>
#include <boost/signals/signal0.hpp>
#include <boost/signals/signal1.hpp>
-#include <boost/function.hpp>
-
#include <vector>
#ifdef __GNUG__
Put into some sort of alphabetical order */
//@{
///
- boost::function<void> showAboutlyx;
+ void showAboutlyx();
/// show the key and label of a bibliography entry
- boost::function<void, InsetCommand *> showBibitem;
+ void showBibitem(InsetCommand * ic);
/// show the bibtex dialog
- boost::function<void, InsetCommand *> showBibtex;
+ void showBibtex(InsetCommand * ic);
///
- boost::function<void> showCharacter;
+ void showCharacter();
/// connected to the character dialog also
- boost::function<void> setUserFreeFont;
+ void setUserFreeFont();
///
- boost::function<void, InsetCommand *> showCitation;
+ void showCitation(InsetCommand *);
///
- boost::function<void, string const &> createCitation;
+ void createCitation(string const &);
///
- boost::function<void> showDocument;
+ void showDocument();
///
- boost::function<void, InsetError *> showError;
+ void showError(InsetError *);
/// show the external inset dialog
- boost::function<void, InsetExternal *> showExternal;
+ void showExternal(InsetExternal *);
/// show the contents of a file.
- boost::function<void, string const &> showFile;
+ void showFile(string const &);
/// show all forked child processes
- boost::function<void> showForks;
+ void showForks();
///
- boost::function<void, InsetGraphics *> showGraphics;
+ void showGraphics(InsetGraphics *);
/// show the details of a LyX file include inset
- boost::function<void, InsetInclude *> showInclude;
+ void showInclude(InsetInclude *);
///
- boost::function<void, InsetCommand *> showIndex;
+ void showIndex(InsetCommand *);
///
- boost::function<void, string const &> createIndex;
+ void createIndex(string const &);
///
- boost::function<void, InsetInfo *> showInfo;
+ void showInfo(InsetInfo *);
/// show the LaTeX log or build file
- boost::function<void> showLogFile;
+ void showLogFile();
/// display the top-level maths panel
- boost::function<void> showMathPanel;
+ void showMathPanel();
///
- boost::function<void, InsetMinipage *> showMinipage;
+ void showMinipage(InsetMinipage *);
///
- boost::function<void, InsetMinipage *> updateMinipage;
+ void updateMinipage(InsetMinipage *);
///
- boost::function<void, InsetERT *> showERT;
+ void showERT(InsetERT *);
///
- boost::function<void, InsetERT *> updateERT;
+ void updateERT(InsetERT *);
///
- boost::function<void, InsetFloat *> showFloat;
+ void showFloat(InsetFloat *);
///
- boost::function<void> showParagraph;
+ void showParagraph();
///
- boost::signal0<void> updateParagraph;
+ void updateParagraph();
///
- boost::function<void> showPreamble;
+ void showPreamble();
///
- boost::function<void> showPreferences;
+ void showPreferences();
///
- boost::function<void> showPrint;
+ void showPrint();
///
- boost::function<void, InsetCommand *> showRef;
+ void showRef(InsetCommand *);
///
- boost::function<void, string const &> createRef;
+ void createRef(string const &);
///
- boost::function<void> showSearch;
+ void showSearch();
///
- boost::function<void> showSendto;
+ void showSendto();
/// bring up the spellchecker
- boost::function<void> showSpellchecker;
+ void showSpellchecker();
/// bring up the spellchecker tab in preferences
- boost::function<void> showSpellcheckerPreferences;
+ void showSpellcheckerPreferences();
///
- boost::function<void, InsetTabular *> showTabular;
+ void showTabular(InsetTabular *);
///
- boost::function<void, InsetTabular *> updateTabular;
+ void updateTabular(InsetTabular *);
///
- boost::function<void> showTabularCreate;
+ void showTabularCreate();
/// show the TexInfo
- boost::function<void> showTexinfo;
+ void showTexinfo();
/// show the thesaurus dialog
- boost::function<void, string const &> showThesaurus;
+ void showThesaurus(string const &);
///
- boost::function<void, InsetCommand *> showTOC;
+ void showTOC(InsetCommand *);
///
- boost::function<void, string const &> createTOC;
+ void createTOC(string const &);
///
- boost::function<void, InsetCommand *> showUrl;
+ void showUrl(InsetCommand *);
///
- boost::function<void, string const &> createUrl;
+ void createUrl(string const &);
/// show the version control log
- boost::function<void> showVCLogFile;
+ void showVCLogFile();
//@}
private:
/// Add a dialog to the vector of dialogs.
- void add(DialogBase *);
+ //void add(DialogBase *);
/// the dialogs being managed
- std::vector<db_ptr> dialogs_;
+ //std::vector<db_ptr> dialogs_;
};
#endif
--- /dev/null
+/**
+ * \file LyXKeySym.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger and Juergen
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "LyXKeySym.h"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file LyXKeySym.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger and Juergen
+ */
+
+#ifndef LYXKEYSYM_H
+#define LYXKEYSYM_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+#include <boost/shared_ptr.hpp>
+
+/**
+ * This is a base class for representing a keypress.
+ * Each frontend has to implement this to provide
+ * the functionality that LyX needs in regards to
+ * key presses.
+ */
+class LyXKeySym {
+public:
+ LyXKeySym() {}
+
+ virtual ~LyXKeySym() {}
+
+ /// Initialize with the name of a key. F. ex. "space" or "a"
+ virtual void init(string const & symbolname) = 0;
+
+ /// Is this a valid key?
+ virtual bool isOK() const = 0;
+
+ /// Is this a modifier key only?
+ virtual bool isModifier() const = 0;
+
+ /// What is the symbolic name of this key? F.ex. "Return" or "c"
+ virtual string getSymbolName() const = 0;
+
+ /**
+ * Return the value of the keysym into the local ISO encoding.
+ * This converts the LyXKeySym to a 8-bit encoded character.
+ * This relies on user to use the right encoding.
+ */
+ virtual char getISOEncoded() const = 0;
+
+ /**
+ * We need to be able to equality compare these for the
+ * sake of the keymap business.
+ */
+ virtual bool operator==(LyXKeySym const & k) const = 0;
+};
+
+typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
+
+#endif
--- /dev/null
+/**
+ * \file LyXKeySymFactory.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger & Juergen
+ */
+
+#ifndef LYXKEYSYMFACTORY_H
+#define LYXKEYSYMFACTORY_H
+
+class LyXKeySym;
+
+namespace LyXKeySymFactory {
+ /**
+ * Make a LyXKeySym. Used because we want to
+ * generate a toolkit-specific instance.
+ */
+ LyXKeySym * create();
+}
+
+#endif // LYXKEYSYM_FACTORY_H
--- /dev/null
+/**
+ * \file LyXScreenFactory.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#ifndef LYXSCREENFACTORY_H
+#define LYXSCREENFACTORY_H
+
+class WorkArea;
+class LyXScreen;
+
+namespace LyXScreenFactory {
+ /**
+ * Make a screen renderer. Used because we want to
+ * generate a toolkit-specific instance.
+ */
+ LyXScreen * create(WorkArea & owner);
+}
+
+#endif // LYXSCREEN_FACTORY_H
void LyXView::init()
{
- // Set the textclass choice
- invalidateLayoutChoice();
updateLayoutChoice();
updateMenubar();
}
-void LyXView::invalidateLayoutChoice()
-{
- last_textclass_ = -1;
-}
-
-
void LyXView::updateLayoutChoice()
{
// don't show any layouts without a buffer
}
// update the layout display
- if (last_textclass_ != int(buffer()->params.textclass)) {
- toolbar_->updateLayoutList(true);
- last_textclass_ = int(buffer()->params.textclass);
- current_layout = textclasslist[last_textclass_].defaultLayoutName();
- } else {
- toolbar_->updateLayoutList(false);
+ if (toolbar_->updateLayoutList(buffer()->params.textclass)) {
+ current_layout = textclasslist[buffer()->params.textclass].defaultLayoutName();
}
string const & layout =
virtual ~LyXView();
- /// FIXME: what is the requirement for this be to separate from the ctor ?
+ /**
+ * This is called after the concrete view has been created.
+ * We have to have the toolbar and the other stuff created
+ * before we can populate it with this call.
+ */
void init();
/// start modal operation
void messagePop();
/// show state (font etc.) in minibuffer
void showState();
-
+
/// updates the title of the window
void updateWindowTitle();
/// called on timeout
void autoSave();
- /// FIXME: GUII - toolbar property
- void invalidateLayoutChoice();
-
private:
/**
* setWindowTitle - set title of window
boost::scoped_ptr<LyXFunc> lyxfunc_;
/// dialogs for this view
boost::scoped_ptr<Dialogs> dialogs_;
-
- /**
- * The last textclass layout list in the layout choice selector
- * This should probably be moved to the toolbar, but for now it's
- * here. (Asger)
- *
- * FIXME: GUII
- */
- int last_textclass_;
};
#endif // LYXVIEW_H
FileDialog.h \
Liason.C \
Liason.h \
+ LyXKeySym.C \
+ LyXKeySym.h \
+ LyXKeySymFactory.h \
+ LyXScreenFactory.h \
+ LyXView.C \
+ LyXView.h \
Menubar.C \
Menubar.h \
Painter.C \
Timeout.h \
Toolbar.C \
Toolbar.h \
- LyXView.C \
- LyXView.h \
+ WorkArea.C \
WorkArea.h \
+ WorkAreaFactory.h \
font_loader.h \
font_metrics.h \
+ guiapi.h \
key_state.h \
lyx_gui.h \
mouse_state.h \
Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &tbd)
+ : last_textclass_(-1)
{
pimpl_ = new Pimpl(o, x, y);
}
-void Toolbar::updateLayoutList(bool force)
+bool Toolbar::updateLayoutList(int textclass)
{
- pimpl_->updateLayoutList(force);
+ // update the layout display
+ if (last_textclass_ != textclass) {
+ pimpl_->updateLayoutList(true);
+ last_textclass_ = textclass;
+ return true;
+ } else {
+ pimpl_->updateLayoutList(false);
+ return false;
+ }
}
/// update the layout combox
void setLayout(string const & layout);
- /// Populate the layout combox; re-do everything if force is true.
- void updateLayoutList(bool force);
+ /**
+ * Populate the layout combox - returns whether we did a full
+ * update or not
+ */
+ bool updateLayoutList(int textclass);
/// Drop down the layout list
void openLayoutList();
/// Erase the layout list
friend struct Toolbar::Pimpl;
///
Pimpl * pimpl_;
+
+ /**
+ * The last textclass layout list in the layout choice selector
+ */
+ int last_textclass_;
};
#endif
--- /dev/null
+/**
+ * \file WorkArea.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger and Juergen
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "WorkArea.h"
+
+
+
+
+
+
+
+
-// temporary
-#include "frontends/xforms/XWorkArea.h"
+// -*- C++ -*-
+/**
+ * \file WorkArea.h
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author unknown
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#ifndef WORKAREA_H
+#define WORKAREA_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "frontends/Painter.h"
+#include "frontends/mouse_state.h"
+#include "frontends/key_state.h"
+#include "frontends/LyXKeySym.h"
+
+#include <boost/signals/signal0.hpp>
+#include <boost/signals/signal1.hpp>
+#include <boost/signals/signal2.hpp>
+#include <boost/signals/signal3.hpp>
+
+#include <utility>
+
+///
+class WorkArea {
+public:
+ ///
+ WorkArea() {}
+ ///
+ virtual ~WorkArea() {}
+ ///
+ virtual Painter & getPainter() = 0;
+ ///
+ virtual int workWidth() const = 0;
+ ///
+ virtual int workHeight() const = 0;
+ ///
+ virtual unsigned int width() const = 0;
+
+ ///
+ virtual int xpos() const = 0;
+ ///
+ virtual int ypos() const = 0;
+ ///
+ virtual void resize(int xpos, int ypos, int width, int height) = 0;
+ ///
+ virtual void redraw() const = 0;
+ ///
+ virtual void setFocus() const = 0;
+ ///
+ virtual bool hasFocus() const = 0;
+ ///
+ virtual bool visible() const = 0;
+ ///
+ virtual void greyOut() const = 0;
+ ///
+ virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
+
+ /// a selection exists
+ virtual void haveSelection(bool) const = 0;
+ ///
+ virtual string const getClipboard() const = 0;
+ ///
+ virtual void putClipboard(string const &) const = 0;
+ // Signals
+ ///
+ boost::signal0<void> workAreaExpose;
+ ///
+ boost::signal1<void, int> scrollDocView;
+ ///
+ boost::signal2<void, LyXKeySymPtr, key_modifier::state> workAreaKeyPress;
+ ///
+ boost::signal3<void, int, int, mouse_button::state> workAreaButtonPress;
+ ///
+ boost::signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
+ ///
+ boost::signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
+ ///
+ boost::signal0<void> workAreaFocus;
+ ///
+ boost::signal0<void> workAreaUnfocus;
+ ///
+ boost::signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
+ ///
+ boost::signal3<void, int, int, mouse_button::state> workAreaTripleClick;
+ /// emitted when an X client has requested our selection
+ boost::signal0<void> selectionRequested;
+ /// emitted when another X client has stolen our selection
+ boost::signal0<void> selectionLost;
+};
+
+#endif // WORKAREA_H
--- /dev/null
+/**
+ * \file WorkAreaFactory.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#ifndef WORKAREAFACTORY_H
+#define WORKAREAFACTORY_H
+
+class WorkArea;
+
+namespace WorkAreaFactory {
+ /**
+ * Make a work area. Used because we want to generate
+ * a toolkit-specific instance.
+ */
+ WorkArea * create(int x, int y, int w, int h);
+}
+
+#endif // WORKAREA_FACTORY_H
+2002-06-16 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * changes to simplify function setup, removal of a lot of includes.
+
2002-06-12 Angus Leeming <leeming@lyx.org>
* ControlParagraph.[Ch]: forward declare ParagraphParameters.
* ControlInset.tmpl: add missing header file, ButtonControllerBase.h.
2002-06-11 Edwin Leuven <leuven@fee.uva.nl>
-
- * ControlParagraph.[Ch]: new paragraph controller
- * GUI.h: add new controller
- * Makefile.am: ditto
-
+
+ * ControlParagraph.[Ch]: new paragraph controller
+ * GUI.h: add new controller
+ * Makefile.am: ditto
+
2002-06-10 Lars Gullik Bjønnes <larsbj@birdstep.com>
* GUI.h: do not include ButtonController.tmpl
#pragma implementation
#endif
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "ControlAboutlyx.h"
-#include "Dialogs.h"
#include "frontends/LyXView.h"
#include "Lsstream.h"
#include "BufferView.h"
#include "support/filetools.h" // FileSearch
#include "version.h"
-#include <boost/bind.hpp>
-
// needed for the browser
extern string system_lyxdir;
extern string user_lyxdir;
+
ControlAboutlyx::ControlAboutlyx(LyXView & lv, Dialogs & d)
: ControlDialogBI(lv, d)
-{
- d_.showAboutlyx = boost::bind(&ControlAboutlyx::show, this);
-}
+{}
stringstream & ControlAboutlyx::getCredits(stringstream & ss) const
return ss;
}
+
string const ControlAboutlyx::getCopyright() const
{
return _("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2001 LyX Team");
}
+
string const ControlAboutlyx::getLicense() const
{
return _("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.");
}
+
string const ControlAboutlyx::getDisclaimer() const
{
return _("LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.");
}
+
string const ControlAboutlyx::getVersion() const
{
stringstream ss;
#endif
#include "ControlBibitem.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "buffer.h"
#include "BufferView.h"
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
-
-#include <algorithm>
ControlBibitem::ControlBibitem(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d)
-{
- d_.showBibitem = boost::bind(&ControlBibitem::showInset, this, _1);
-}
+{}
void ControlBibitem::applyParamsToInset()
#pragma implementation
#endif
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "ControlBibtex.h"
-#include "Dialogs.h"
-#include "buffer.h"
#include "BufferView.h"
#include "lyxrc.h"
#include "helper_funcs.h"
#include "frontends/LyXView.h"
-#include <boost/bind.hpp>
-
-#include <algorithm>
-
using std::pair;
-using std::make_pair;
+
ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d)
-{
- d_.showBibtex = boost::bind(&ControlBibtex::showInset, this, _1);
-}
+{}
+
void ControlBibtex::applyParamsToInset()
{
#include "ViewBase.h"
#include "ButtonControllerBase.h"
#include "buffer.h"
-#include "Dialogs.h"
#include "Liason.h"
#include "bufferview_funcs.h" // ToggleAndShow
#include "gettext.h"
#include "frontends/LyXView.h"
-#include <boost/bind.hpp>
-
-#include <vector>
-
using Liason::setMinibuffer;
-using std::vector;
ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d),
font_(0), toggleall_(false)
-{
- d_.showCharacter = boost::bind(&ControlCharacter::show, this);
- d_.setUserFreeFont = boost::bind(&ControlCharacter::apply, this);
-}
+{}
void ControlCharacter::setParams()
///
bool getToggleAll() const;
-private:
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
+private:
/// set the params before show or update.
virtual void setParams();
#endif
#include "ControlCitation.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "buffer.h"
-#include "Dialogs.h"
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
-
-#include <algorithm>
-
-using std::pair;
using std::vector;
+using std::pair;
vector<biblio::CiteStyle> ControlCitation::citeStyles_;
+
ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d, LFUN_CITATION_INSERT)
-{
- // These are permanent connections so we won't bother
- // storing a copy because we won't be disconnecting.
- d_.showCitation = boost::bind(&ControlCitation::showInset, this, _1);
- d_.createCitation = boost::bind(&ControlCitation::createInset, this, _1);
-}
+{}
void ControlCitation::clearDaughterParams()
disconnect();
view().hide();
}
-
#pragma implementation
#endif
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "ControlERT.h"
-#include "Dialogs.h"
-#include "frontends/LyXView.h"
-#include "buffer.h"
-#include "BufferView.h"
-
-#include <boost/bind.hpp>
-
-using std::vector;
// sorry this is just a temporary hack we should include vspace.h! (Jug)
extern const char * stringFromUnit(int);
+
ControlERT::ControlERT(LyXView & lv, Dialogs & d)
: ControlInset<InsetERT, ERTParams>(lv, d)
-{
- d_.showERT = boost::bind(&ControlERT::showInset, this, _1);
-
- // We could have an extra method updateInset that calls
- // view().update() rather than view().show(), but I don't see why
- // it is really needed.
- d_.updateERT = boost::bind(&ControlERT::showInset, this, _1);
-}
+{}
void ControlERT::applyParamsToInset()
: status(InsetERT::Collapsed)
{}
+
ERTParams::ERTParams(InsetERT const & inset)
: status(inset.status())
{}
#endif
#include "ControlError.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "buffer.h"
#include "insets/inseterror.h"
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
ControlError::ControlError(LyXView & lv, Dialogs & d)
: ControlInset<InsetError, string>(lv, d)
-{
- d_.showError = boost::bind(&ControlError::showInset, this, _1);
-}
+{}
string const ControlError::getParams(InsetError const & inset)
#pragma implementation
#endif
-#include "BufferView.h"
-#include "ButtonControllerBase.h"
#include "ControlExternal.h"
-#include "Dialogs.h"
-#include "Liason.h"
-#include "frontends/LyXView.h"
-#include "ViewBase.h"
-#include "buffer.h"
-#include "frontends/Alert.h"
+#include "BufferView.h"
#include "gettext.h"
#include "helper_funcs.h"
#include "lyxrc.h"
#include "support/filetools.h"
-#include "support/lstrings.h"
-
-#include <boost/scoped_ptr.hpp>
-#include <boost/bind.hpp>
-#include <utility>
#include <vector>
-using std::make_pair;
using std::vector;
ControlExternal::ControlExternal(LyXView & lv, Dialogs & d)
: ControlInset<InsetExternal, InsetExternal::Params>(lv, d)
-{
- d_.showExternal = boost::bind(&ControlExternal::showInset, this, _1);
-}
+{}
InsetExternal::Params const ControlExternal::getParams(string const &)
#endif
#include "ControlFloat.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "buffer.h"
-#include "BufferView.h"
-
-#include "insets/insetfloat.h"
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
-
-using std::vector;
ControlFloat::ControlFloat(LyXView & lv, Dialogs & d)
: ControlInset<InsetFloat, FloatParams>(lv, d)
-{
- d_.showFloat = boost::bind(&ControlFloat::showInset, this, _1);
-
- // We could have an extra method updateInset that calls
- // view().update() rather than view().show(), but I don't see why
- // it is really needed.
- //d_.updateFloat.connect(slot(this, &ControlFloat::showInset));
-}
+{}
void ControlFloat::applyParamsToInset()
#endif
#include "ControlForks.h"
-#include "ButtonControllerBase.h"
#include "ViewBase.h"
#include "BufferView.h"
#include "frontends/LyXView.h"
#include "lyxfunc.h"
-#include "frontends/Dialogs.h"
-
#include "support/forkedcontr.h"
#include "support/lstrings.h"
ControlForks::ControlForks(LyXView & lv, Dialogs & d)
: ControlDialogBI(lv, d)
-{
- d_.showForks = boost::bind(&ControlForks::show, this);
-}
+{}
vector<pid_t> const ControlForks::getPIDs() const
#pragma implementation
#endif
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "ControlGraphics.h"
#include "helper_funcs.h"
#include "support/filetools.h"
#include "support/FileInfo.h"
-#include <boost/bind.hpp>
-
-#include <fstream>
-
using std::pair;
using std::make_pair;
-using std::ifstream;
using std::vector;
namespace {
ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
: ControlInset<InsetGraphics, InsetGraphicsParams>(lv, d)
-{
- d_.showGraphics = boost::bind(&ControlGraphics::showInset, this, _1);
-}
+{}
InsetGraphicsParams const ControlGraphics::getParams(string const &)
} // namespace anon
+
vector<RotationOriginPair> getRotationOriginData()
{
static vector<RotationOriginPair> data;
data.resize(rorigin_size);
for (lyx::size_type i = 0; i < rorigin_size; ++i) {
- data[i] = std::make_pair(_(rorigin_gui_strs[i]),
- rorigin_lyx_strs[i]);
+ data[i] = make_pair(_(rorigin_gui_strs[i]),
+ rorigin_lyx_strs[i]);
}
return data;
*/
#include <config.h>
-#include <utility>
#ifdef __GNUG__
#pragma implementation
#endif
#include "ControlInclude.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "buffer.h"
#include "Alert.h"
#include "BufferView.h"
-#include "Dialogs.h"
#include "lyxfunc.h"
#include "gettext.h"
#include "helper_funcs.h"
#include "support/filetools.h"
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
+#include <utility>
using std::pair;
-using std::make_pair;
+
ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
: ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
-{
- d_.showInclude = boost::bind(&ControlInclude::showInset, this, _1);
-}
+{}
void ControlInclude::applyParamsToInset()
#endif
#include "ControlIndex.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "buffer.h"
-#include "Dialogs.h"
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
ControlIndex::ControlIndex(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d, LFUN_INDEX_INSERT)
-{
- d_.showIndex = boost::bind(&ControlIndex::showInset, this, _1);
- d_.createIndex = boost::bind(&ControlIndex::createInset, this, _1);
-}
+{}
#include "buffer.h"
#include "debug.h"
#include "frontends/LyXView.h"
+#include "insets/insetfloat.h"
+#include "insets/insetgraphics.h"
#include "support/LAssert.h"
+
#include <boost/bind.hpp>
template <class Inset, class Params>
#endif
#include "ControlLog.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "lyxrc.h"
#include "BufferView.h"
#include "frontends/LyXView.h"
-#include <boost/bind.hpp>
ControlLog::ControlLog(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d)
-{
- d_.showLogFile = boost::bind(&ControlLog::show, this);
-}
+{}
void ControlLog::setParams()
#endif
#include "ControlMinipage.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "frontends/LyXView.h"
-#include "buffer.h"
#include "BufferView.h"
-#include "helper_funcs.h"
-
-#include <boost/bind.hpp>
-
-using std::vector;
ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
: ControlInset<InsetMinipage, MinipageParams>(lv, d)
-{
- d_.showMinipage = boost::bind(&ControlMinipage::showInset, this, _1);
-
- // We could have an extra method updateInset that calls
- // view().update() rather than view().show(), but I don't see why
- // it is really needed.
- d_.updateMinipage = boost::bind(&ControlMinipage::showInset, this, _1);
-}
+{}
void ControlMinipage::applyParamsToInset()
#pragma implementation
#endif
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "ControlParagraph.h"
+#include "ViewBase.h"
#include "ParagraphParameters.h"
-#include "Dialogs.h"
#include "Liason.h"
#include "LyXView.h"
#include "BufferView.h"
#include "lyxtextclasslist.h"
#include "support/LAssert.h"
-#include <boost/bind.hpp>
-
using Liason::setMinibuffer;
ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d), pp_(0), ininset_(false)
-{
- d_.showParagraph = boost::bind(&ControlParagraph::show, this);
-}
+{}
ControlParagraph::~ControlParagraph()
pp_->noindent());
// Actually apply these settings
- lv_.view()->update(text,
+ lv_.view()->update(text,
BufferView::SELECT |
BufferView::FITCUR |
BufferView::CHANGE);
-
+
lv_.buffer()->markDirty();
-
+
setMinibuffer(&lv_, _("Paragraph layout set"));
}
/// get paragraph
Paragraph const * par_ = lv_.view()->getLyXText()->cursor.par();
-
+
/// Set the paragraph parameters
- *pp_ = par_->params();
-
+ *pp_ = par_->params();
+
/// this needs to be done separately
pp_->labelWidthString(par_->getLabelWidthString());
-
+
/// alignment
LyXTextClass const & tclass =
textclasslist[lv_.view()->buffer()->params.textclass];
alignpos_ = tclass[par_->layout()].alignpossible;
/// is paragraph in inset
- ininset_ = par_->inInset();
+ ininset_ = par_->inInset();
}
};
#endif // CONTROLPARAGRAPH_H
-
#pragma implementation
#endif
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "ControlPreamble.h"
+#include "ViewBase.h"
#include "frontends/LyXView.h"
-#include "Dialogs.h"
#include "buffer.h"
-#include "lyxrc.h"
#include "Liason.h"
#include "gettext.h"
#include "BufferView.h"
#include "support/LAssert.h"
-#include <boost/bind.hpp>
ControlPreamble::ControlPreamble(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d),
params_(0)
-{
- d_.showPreamble = boost::bind(&ControlPreamble::show, this);
-}
+{}
void ControlPreamble::apply()
void ControlPreamble::setParams()
{
- if (params_) delete params_;
+ delete params_;
params_ = new string(lv_.buffer()->params.preamble);
}
void ControlPreamble::clearParams()
{
- if (params_) {
- delete params_;
- params_ = 0;
- }
+ delete params_;
+ params_ = 0;
}
#include "ControlDialog_impl.h"
+#include "LString.h"
+
/** A controller for Preamble dialogs.
*/
class ControlPreamble : public ControlDialogBD {
*/
#include <config.h>
-#include <utility>
#ifdef __GNUG__
#pragma implementation
#endif
+#include "ControlPrint.h"
#include "ViewBase.h"
#include "ButtonControllerBase.h"
-#include "ControlPrint.h"
#include "buffer.h"
-#include "Dialogs.h"
#include "frontends/LyXView.h"
#include "PrinterParams.h"
#include "Liason.h"
#include "BufferView.h"
#include "support/LAssert.h"
-#include <boost/bind.hpp>
-
using Liason::printBuffer;
using Liason::getPrinterParams;
-using std::make_pair;
+
ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d),
params_(0)
-{
- d_.showPrint = boost::bind(&ControlPrint::show, this);
-}
+{}
void ControlPrint::apply()
#include "ControlDialog_impl.h"
+#include "LString.h"
+
class PrinterParams;
/** A controller for Print dialogs.
#endif
#include "ControlRef.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "buffer.h"
#include "lyxfunc.h"
#include "bufferlist.h"
-#include "debug.h"
-
-#include "frontends/LyXView.h"
#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
-#include <boost/bind.hpp>
-
-#include <algorithm>
-
using std::vector;
-using std::find;
extern BufferList bufferlist;
+
ControlRef::ControlRef(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d, LFUN_REF_INSERT)
-{
- d_.showRef = boost::bind(&ControlRef::showInset, this, _1);
- d_.createRef = boost::bind(&ControlRef::createInset, this, _1);
-}
+{}
vector<string> const ControlRef::getLabelList(string const & name) const
#endif
#include "ControlSearch.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
#include "Liason.h"
#include "buffer.h"
#include "lyxfind.h"
-#include "debug.h"
#include "gettext.h"
#include "BufferView.h"
#include "support/lstrings.h"
-#include <boost/bind.hpp>
-
using Liason::setMinibuffer;
+
ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d)
-{
- d_.showSearch = boost::bind(&ControlSearch::show, this);
-
- // perhaps in the future we'd like a
- // "search again" button/keybinding
- // d_.searchAgain.connect(SigC::slot(this, &ControlSearch::FindNext));
-}
+{}
void ControlSearch::find(string const & search,
bool casesensitive, bool matchword, bool forward) const
{
- bool const found = LyXFind(lv_.view(), search,
- forward, false, casesensitive, matchword);
+ bool const found = lyxfind::LyXFind(lv_.view(), search,
+ forward, casesensitive,
+ matchword);
if (!found)
setMinibuffer(&lv_, _("String not found!"));
// move on to the next instance once the present instance has been
// changed
bool const once = !all;
- int const replace_count = LyXReplace(lv_.view(),
- search, replace, true, casesensitive,
- matchword, all, once);
+ int const replace_count =
+ lyxfind::LyXReplace(lv_.view(),
+ search, replace, true, casesensitive,
+ matchword, all, once);
if (replace_count == 0) {
setMinibuffer(&lv_, _("String not found!"));
#pragma implementation
#endif
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "ControlSendto.h"
-#include "Dialogs.h"
+#include "ViewBase.h"
#include "frontends/LyXView.h"
#include "BufferView.h"
#include "buffer.h"
#include "support/lstrings.h"
#include "support/systemcall.h"
-#include <boost/bind.hpp>
-
-#include <fstream>
-
using std::vector;
+
ControlSendto::ControlSendto(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d),
format_(0),
command_(lyxrc.custom_export_command)
-{
- d_.showSendto = boost::bind(&ControlSendto::show, this);
-}
+{}
vector<Format const *> const ControlSendto::allFormats() const
#endif
#include "ControlDialog_impl.h"
+#include "LString.h"
+
#include <vector>
class Format;
#endif
#include "ControlShowFile.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "frontends/LyXView.h"
-#include "BufferView.h"
-#include "gettext.h"
#include "support/filetools.h" // FileSearch
-#include <boost/bind.hpp>
-
-#include <fstream>
ControlShowFile::ControlShowFile(LyXView & lv, Dialogs & d)
: ControlDialogBI(lv, d)
-{
- d_.showFile = boost::bind(&ControlShowFile::showFile, this, _1);
-}
+{}
void ControlShowFile::showFile(string const & file)
#include "language.h"
#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "Dialogs.h"
#include "Liason.h"
# include "sp_pspell.h"
#endif
-#include "debug.h"
-
-#include <boost/bind.hpp>
-
#include <sys/types.h> // needed by <sys/select.h> at least on freebsd
#ifdef HAVE_SYS_SELECT_H
: ControlDialogBD(lv, d),
rtl_(false), newval_(0.0), oldval_(0), newvalue_(0), count_(0),
stop_(false), result_(SpellBase::ISP_OK), speller_(0)
-{
- d_.showSpellchecker = boost::bind(&ControlSpellchecker::show, this);
-}
+{}
void ControlSpellchecker::setParams()
#include "ViewBase.h"
#include "ButtonControllerBase.h"
#include "BufferView.h"
-#include "Dialogs.h"
#include "lyxfunc.h"
#include "frontends/LyXView.h"
#include "support/lstrings.h"
-#include <boost/bind.hpp>
ControlTabularCreate::ControlTabularCreate(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d)
-{
- d_.showTabularCreate = boost::bind(&ControlTabularCreate::show, this);
-}
+{}
ControlTabularCreate::rowsCols & ControlTabularCreate::params()
#endif
#include "ControlTexinfo.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "Dialogs.h"
#include "BufferView.h"
#include "gettext.h"
#include "support/path.h"
#include "support/lstrings.h"
-#include <boost/bind.hpp>
-
extern string user_lyxdir; // home of *Files.lst
ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
: ControlDialogBI(lv, d)
-{
- d_.showTexinfo = boost::bind(&ControlTexinfo::show, this);
-}
+{}
// build filelists of all availabe bst/cls/sty-files. done through
#endif
#include "ControlThesaurus.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
#include "Liason.h"
#include "lyxfind.h"
#include "buffer.h"
-#include "debug.h"
#include "gettext.h"
#include "BufferView.h"
#include "frontends/LyXView.h"
-#include <boost/bind.hpp>
-
using Liason::setMinibuffer;
+
ControlThesaurus::ControlThesaurus(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d)
-{
- d_.showThesaurus = boost::bind(&ControlThesaurus::showEntry, this, _1);
-}
+{}
void ControlThesaurus::showEntry(string const & entry)
* on a particular charpos in a paragraph that is broken on
* deletion/change !
*/
- int const replace_count = LyXReplace(lv_.view(), oldstr_, newstr,
- true, true, true, false, true);
+ int const replace_count =
+ lyxfind::LyXReplace(lv_.view(), oldstr_, newstr,
+ true, true, true, false, true);
oldstr_ = newstr;
#endif
#include "ControlToc.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "buffer.h"
#include "Dialogs.h"
#include "lyxfunc.h"
#include "gettext.h"
#include "BufferView.h"
-#include "frontends/LyXView.h"
-
#include "support/lstrings.h" // tostr
-#include <boost/bind.hpp>
-
using std::vector;
+
ControlToc::ControlToc(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d, LFUN_TOC_INSERT)
-{
- d_.showTOC = boost::bind(&ControlToc::showInset, this, _1);
- d_.createTOC = boost::bind(&ControlToc::createInset, this, _1);
-}
+{}
void ControlToc::Goto(int const & id) const
#endif
#include "ControlUrl.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "buffer.h"
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
ControlUrl::ControlUrl(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d, LFUN_INSERT_URL)
-{
- d_.showUrl = boost::bind(&ControlUrl::showInset, this, _1);
- d_.createUrl = boost::bind(&ControlUrl::createInset, this, _1);
-}
+{}
#include "ControlVCLog.h"
#include "Lsstream.h"
-#include "ViewBase.h"
#include "ButtonControllerBase.h"
#include "buffer.h"
#include "BufferView.h"
-#include "Dialogs.h"
#include "lyxrc.h"
#include "gettext.h"
#include "support/lyxlib.h"
-#include <boost/bind.hpp>
-
#include <fstream>
using std::endl;
+
ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d)
-{
- d_.showVCLogFile = boost::bind(&ControlVCLog::show, this);
-}
+{}
+
string const ControlVCLog::getBufferFileName() const
{
#define GUI_H
#include "ButtonController.h"
-#include "ButtonPolicies.h"
-#include "ControlAboutlyx.h"
-#include "ControlBibitem.h"
-#include "ControlBibtex.h"
-#include "ControlCharacter.h"
-#include "ControlCitation.h"
-#include "ControlError.h"
-#include "ControlERT.h"
-#include "ControlExternal.h"
-#include "ControlFloat.h"
-#include "ControlForks.h"
-#include "ControlGraphics.h"
-#include "insets/insetgraphicsParams.h"
-#include "ControlInclude.h"
-#include "ControlIndex.h"
-#include "ControlLog.h"
-#include "ControlMinipage.h"
-#include "ControlParagraph.h"
-#include "ControlPreamble.h"
-#include "ControlPrint.h"
-#include "ControlRef.h"
-#include "ControlSearch.h"
-#include "ControlSendto.h"
-#include "ControlShowFile.h"
-#include "ControlSpellchecker.h"
-#include "ControlTabularCreate.h"
-#include "ControlTexinfo.h"
-#include "ControlThesaurus.h"
-#include "ControlToc.h"
-#include "ControlUrl.h"
-#include "ControlVCLog.h"
-
+#include "ViewBase.h"
/** This class instantiates and makes available the GUI-specific
ButtonController and View.
///
virtual ViewBase & view() { return view_; }
+ friend void gui_ShowAboutlyx(LyXView &, Dialogs &);
+ friend void gui_ShowBibitem(InsetCommand *, LyXView &, Dialogs &);
+ friend void gui_ShowBibtex(InsetCommand *, LyXView &, Dialogs &);
+ friend void gui_ShowCharacter(LyXView &, Dialogs &);
+ friend void gui_SetUserFreeFont(LyXView &, Dialogs &);
+ friend void gui_ShowCitation(InsetCommand *, LyXView &, Dialogs &);
+ friend void gui_CreateCitation(string const &, LyXView &, Dialogs &);
+ friend void gui_ShowDocument(LyXView &, Dialogs &);
+ friend void gui_ShowError(InsetError *, LyXView &, Dialogs &);
+ friend void gui_ShowERT(InsetERT *, LyXView &, Dialogs &);
+ friend void gui_UpdateERT(InsetERT *, LyXView &, Dialogs &);
+ friend void gui_ShowExternal(InsetExternal *, LyXView &, Dialogs &);
+ friend void gui_ShowFloat(InsetFloat *, LyXView &, Dialogs &);
+ friend void gui_ShowForks(LyXView &, Dialogs &);
+ friend void gui_ShowGraphics(InsetGraphics *, LyXView &, Dialogs &);
+ friend void gui_ShowInclude(InsetInclude *, LyXView &, Dialogs &);
+ friend void gui_ShowIndex(InsetCommand *, LyXView &, Dialogs &);
+ friend void gui_CreateIndex(string const &, LyXView &, Dialogs &);
+ friend void gui_ShowLogFile(LyXView &, Dialogs &);
+ friend void gui_ShowMathPanel(LyXView &, Dialogs &);
+ friend void gui_ShowMinipage(InsetMinipage *, LyXView &, Dialogs &);
+ friend void gui_UpdateMinipage(InsetMinipage *, LyXView &, Dialogs &);
+ friend void gui_ShowParagraph(LyXView &, Dialogs &);
+ friend void gui_ShowPreamble(LyXView &, Dialogs &);
+ friend void gui_ShowPreferences(LyXView &, Dialogs &);
+ friend void gui_ShowPrint(LyXView &, Dialogs &);
+ friend void gui_ShowRef(InsetCommand *, LyXView &, Dialogs &);
+ friend void gui_CreateRef(string const &, LyXView &, Dialogs &);
+ friend void gui_ShowSearch(LyXView &, Dialogs &);
+ friend void gui_ShowSendto(LyXView &, Dialogs &);
+ friend void gui_ShowSpellchecker(LyXView &, Dialogs &);
+ friend void gui_ShowTabularCreate(LyXView &, Dialogs &);
+ friend void gui_ShowTexinfo(LyXView &, Dialogs &);
+ friend void gui_ShowTOC(InsetCommand *, LyXView &, Dialogs &);
+ friend void gui_CreateTOC(string const &, LyXView &, Dialogs &);
+ friend void gui_ShowUrl(InsetCommand *, LyXView &, Dialogs &);
+ friend void gui_CreateUrl(string const &, LyXView &, Dialogs &);
+ friend void gui_ShowVCLogFile(LyXView &, Dialogs &);
+
private:
///
ButtonController<Policy, GUIbc> bc_;
GUIview view_;
};
-#if 0
-/** Specialization for About LyX dialog
- */
-template <class GUIview, class GUIbc>
-class GUIAboutlyx :
- public GUI<ControlAboutlyx, GUIview, OkCancelPolicy, GUIbc> {
-public:
- ///
- GUIAboutlyx(LyXView & lv, Dialogs & d)
- : GUI<ControlAboutlyx, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Bibitem dialog
- */
-template <class GUIview, class GUIbc>
-class GUIBibitem :
- public GUI<ControlBibitem, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIBibitem(LyXView & lv, Dialogs & d)
- : GUI<ControlBibitem, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Bibtex dialog
- */
-template <class GUIview, class GUIbc>
-class GUIBibtex :
- public GUI<ControlBibtex, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIBibtex(LyXView & lv, Dialogs & d)
- : GUI<ControlBibtex, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Character dialog
- */
-template <class GUIview, class GUIbc>
-class GUICharacter : public GUI<ControlCharacter, GUIview,
- OkApplyCancelReadOnlyPolicy, GUIbc>
-{
-public:
- ///
- GUICharacter(LyXView & lv, Dialogs & d)
- : GUI<ControlCharacter, GUIview,
- OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Citation dialog
- */
-template <class GUIview, class GUIbc>
-class GUICitation : public GUI<ControlCitation, GUIview,
- NoRepeatedApplyReadOnlyPolicy, GUIbc>
-{
-public:
- ///
- GUICitation(LyXView & lv, Dialogs & d)
- : GUI<ControlCitation, GUIview,
- NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Error dialog
- */
-template <class GUIview, class GUIbc>
-class GUIError :
- public GUI<ControlError, GUIview, OkCancelPolicy, GUIbc> {
-public:
- ///
- GUIError(LyXView & lv, Dialogs & d)
- : GUI<ControlError, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for ERT dialog
- */
-template <class GUIview, class GUIbc>
-class GUIERT :
- public GUI<ControlERT, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIERT(LyXView & lv, Dialogs & d)
- : GUI<ControlERT, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for External dialog
- */
-template <class GUIview, class GUIbc>
-class GUIExternal :
- public GUI<ControlExternal, GUIview, OkApplyCancelReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIExternal(LyXView & lv, Dialogs & d)
- : GUI<ControlExternal, GUIview, OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Forks dialog
- */
-template <class GUIview, class GUIbc>
-class GUIForks :
- public GUI<ControlForks, GUIview, OkApplyCancelPolicy, GUIbc> {
-public:
- ///
- GUIForks(LyXView & lv, Dialogs & d)
- : GUI<ControlForks, GUIview, OkApplyCancelPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Graphics dialog
- */
-template <class GUIview, class GUIbc>
-class GUIGraphics :
- public GUI<ControlGraphics, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIGraphics(LyXView & lv, Dialogs & d)
- : GUI<ControlGraphics, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Include dialog
- */
-template <class GUIview, class GUIbc>
-class GUIInclude :
- public GUI<ControlInclude, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIInclude(LyXView & lv, Dialogs & d)
- : GUI<ControlInclude, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Index dialog
- */
-template <class GUIview, class GUIbc>
-class GUIIndex :
- public GUI<ControlIndex, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIIndex(LyXView & lv, Dialogs & d)
- : GUI<ControlIndex, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Log dialog
- */
-template <class GUIview, class GUIbc>
-class GUILog :
- public GUI<ControlLog, GUIview, OkCancelPolicy, GUIbc> {
-public:
- ///
- GUILog(LyXView & lv, Dialogs & d)
- : GUI<ControlLog, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Minipage dialog
- */
-template <class GUIview, class GUIbc>
-class GUIMinipage :
- public GUI<ControlMinipage, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIMinipage(LyXView & lv, Dialogs & d)
- : GUI<ControlMinipage, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Float dialog
- */
-template <class GUIview, class GUIbc>
-class GUIFloat :
- public GUI<ControlFloat, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIFloat(LyXView & lv, Dialogs & d)
- : GUI<ControlFloat, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Paragraph dialog
- */
-template <class GUIview, class GUIbc>
-class GUIParagraph : public GUI<ControlParagraph, GUIview,
- OkApplyCancelReadOnlyPolicy, GUIbc>
-{
-public:
- ///
- GUIParagraph(LyXView & lv, Dialogs & d)
- : GUI<ControlParagraph, GUIview,
- OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Preamble dialog
- */
-template <class GUIview, class GUIbc>
-class GUIPreamble :
- public GUI<ControlPreamble, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIPreamble(LyXView & lv, Dialogs & d)
- : GUI<ControlPreamble, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Print dialog
- */
-template <class GUIview, class GUIbc>
-class GUIPrint :
- public GUI<ControlPrint, GUIview, OkApplyCancelPolicy, GUIbc> {
-public:
- ///
- GUIPrint(LyXView & lv, Dialogs & d)
- : GUI<ControlPrint, GUIview, OkApplyCancelPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Ref dialog
- */
-template <class GUIview, class GUIbc>
-class GUIRef :
- public GUI<ControlRef, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIRef(LyXView & lv, Dialogs & d)
- : GUI<ControlRef, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Search dialog
- */
-template <class GUIview, class GUIbc>
-class GUISearch :
- public GUI<ControlSearch, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUISearch(LyXView & lv, Dialogs & d)
- : GUI<ControlSearch, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Sendto dialog
- */
-template <class GUIview, class GUIbc>
-class GUISendto :
- public GUI<ControlSendto, GUIview, OkApplyCancelPolicy, GUIbc> {
-public:
- ///
- GUISendto(LyXView & lv, Dialogs & d)
- : GUI<ControlSendto, GUIview, OkApplyCancelPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for ShowFile dialog
- */
-template <class GUIview, class GUIbc>
-class GUIShowFile :
- public GUI<ControlShowFile, GUIview, OkCancelPolicy, GUIbc> {
-public:
- ///
- GUIShowFile(LyXView & lv, Dialogs & d)
- : GUI<ControlShowFile, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Spellchecker dialog
- */
-template <class GUIview, class GUIbc>
-class GUISpellchecker :
- public GUI<ControlSpellchecker, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUISpellchecker(LyXView & lv, Dialogs & d)
- : GUI<ControlSpellchecker, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Toc dialog
- */
-template <class GUIview, class GUIbc>
-class GUIToc :
- public GUI<ControlToc, GUIview, OkCancelPolicy, GUIbc> {
-public:
- ///
- GUIToc(LyXView & lv, Dialogs & d)
- : GUI<ControlToc, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for TabularCreate dialog
- */
-template <class GUIview, class GUIbc>
-class GUITabularCreate :
- public GUI<ControlTabularCreate, GUIview,
- OkApplyCancelReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUITabularCreate(LyXView & lv, Dialogs & d)
- : GUI<ControlTabularCreate, GUIview,
- OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Texinfo dialog
- */
-template <class GUIview, class GUIbc>
-class GUITexinfo :
- public GUI<ControlTexinfo, GUIview, OkCancelPolicy, GUIbc> {
-public:
- ///
- GUITexinfo(LyXView & lv, Dialogs & d)
- : GUI<ControlTexinfo, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Thesaurus dialog
- */
-template <class GUIview, class GUIbc>
-class GUIThesaurus :
- public GUI<ControlThesaurus, GUIview,
- OkApplyCancelReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIThesaurus(LyXView & lv, Dialogs & d)
- : GUI<ControlThesaurus, GUIview,
- OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Url dialog
- */
-template <class GUIview, class GUIbc>
-class GUIUrl :
- public GUI<ControlUrl, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
- ///
- GUIUrl(LyXView & lv, Dialogs & d)
- : GUI<ControlUrl, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for VCLog dialog
- */
-template <class GUIview, class GUIbc>
-class GUIVCLog :
- public GUI<ControlVCLog, GUIview, OkCancelPolicy, GUIbc> {
-public:
- ///
- GUIVCLog(LyXView & lv, Dialogs & d)
- : GUI<ControlVCLog, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-#endif
-
#endif // GUI_H
--- /dev/null
+// -*- C++ -*-
+
+#include "LString.h"
+
+class LyXView;
+class Dialogs;
+class InsetCommand;
+class InsetError;
+class InsetERT;
+class InsetExternal;
+class InsetFloat;
+class InsetGraphics;
+class InsetInclude;
+class InsetInfo;
+class InsetMinipage;
+class InsetTabular;
+
+extern "C" {
+
+ void gui_ShowAboutlyx(LyXView &, Dialogs &);
+ void gui_ShowBibitem(InsetCommand * ic, LyXView & lv, Dialogs & d);
+ void gui_ShowBibtex(InsetCommand * ic, LyXView & lv, Dialogs & d);
+ void gui_ShowCharacter(LyXView & lv, Dialogs & d);
+ void gui_SetUserFreeFont(LyXView & lv, Dialogs & d);
+ void gui_ShowCitation(InsetCommand * ic, LyXView & lv, Dialogs & d);
+ void gui_CreateCitation(string const &, LyXView & lv, Dialogs & d);
+ void gui_ShowDocument(LyXView & lv, Dialogs & d);
+ void gui_ShowError(InsetError * ie, LyXView & lv, Dialogs & d);
+ void gui_ShowERT(InsetERT * ie, LyXView & lv, Dialogs & d);
+ void gui_UpdateERT(InsetERT * ie, LyXView & lv, Dialogs & d);
+ void gui_ShowExternal(InsetExternal * ie, LyXView & lv, Dialogs & d);
+ void gui_ShowFile(string const & f, LyXView & lv, Dialogs & d);
+ void gui_ShowFloat(InsetFloat *, LyXView & lv, Dialogs &);
+ void gui_ShowForks(LyXView & lv, Dialogs & d);
+ void gui_ShowGraphics(InsetGraphics *, LyXView & lv, Dialogs & d);
+ void gui_ShowInclude(InsetInclude *, LyXView & lv, Dialogs & d);
+ void gui_ShowIndex(InsetCommand *, LyXView & lv, Dialogs & d);
+ void gui_CreateIndex(string const &, LyXView & lv, Dialogs & d);
+ void gui_ShowInfo(InsetInfo *, LyXView & lv, Dialogs & d);
+ void gui_ShowLogFile(LyXView & lv, Dialogs & d);
+ void gui_ShowMathPanel(LyXView & lv, Dialogs & d);
+ void gui_ShowMinipage(InsetMinipage *, LyXView & lv, Dialogs & d);
+ void gui_UpdateMinipage(InsetMinipage *, LyXView & lv, Dialogs & d);
+ void gui_ShowParagraph(LyXView & lv, Dialogs & d);
+ void gui_UpdateParagraph(LyXView & lv, Dialogs & d);
+ void gui_ShowPreamble(LyXView & lv, Dialogs & d);
+ void gui_ShowPreferences(LyXView & lv, Dialogs & d);
+ void gui_ShowPrint(LyXView & lv, Dialogs & d);
+ void gui_ShowRef(InsetCommand *, LyXView &, Dialogs &);
+ void gui_CreateRef(string const &, LyXView &, Dialogs &);
+ void gui_ShowSearch(LyXView & lv, Dialogs & d);
+ void gui_ShowSendto(LyXView & lv, Dialogs & d);
+ void gui_ShowSpellchecker(LyXView & lv, Dialogs & d);
+ void gui_ShowSpellcheckerPreferences(LyXView & lv, Dialogs & d);
+ void gui_ShowTabular(InsetTabular *, LyXView &, Dialogs &);
+ void gui_UpdateTabular(InsetTabular *, LyXView &, Dialogs &);
+ void gui_ShowTabularCreate(LyXView & lv, Dialogs & d);
+ void gui_ShowTexinfo(LyXView & lv, Dialogs & d);
+ void gui_ShowThesaurus(string const &, LyXView &, Dialogs &);
+ void gui_ShowTOC(InsetCommand *, LyXView &, Dialogs &);
+ void gui_CreateTOC(string const &, LyXView &, Dialogs &);
+ void gui_ShowUrl(InsetCommand *, LyXView &, Dialogs &);
+ void gui_CreateUrl(string const &, LyXView &, Dialogs &);
+ void gui_ShowVCLogFile(LyXView & lv, Dialogs & d);
+
+} // extern "C"
-/* This file is part of
-* ======================================================
-*
-* LyX, The Document Processor
-*
-* Copyright 1995 Matthias Ettrich
-* Copyright 1995-1998 The LyX Team
-*
-* ====================================================== */
-
-#include <config.h>
+/**
+ * \file screen.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
#ifdef __GNUG__
#pragma implementation
#endif
-#include <algorithm>
+#include <config.h>
#include "screen.h"
#include "lyxtext.h"
#include "lyxrow.h"
-#include "frontends/Painter.h"
-#include "frontends/WorkArea.h"
-#include "buffer.h"
#include "BufferView.h"
+#include "buffer.h"
+#include "WorkArea.h"
+#include "Painter.h"
#include "font_metrics.h"
-#include "insets/insettext.h"
-#include "frontends/xforms/ColorHandler.h"
#include "language.h"
+#include "debug.h"
-using std::max;
using std::min;
-
-namespace {
-
-GC createGC()
-{
- XGCValues val;
- val.foreground = BlackPixel(fl_get_display(),
- DefaultScreen(fl_get_display()));
-
- val.function = GXcopy;
- val.graphics_exposures = false;
- val.line_style = LineSolid;
- val.line_width = 0;
- return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
- GCForeground | GCFunction | GCGraphicsExposures
- | GCLineWidth | GCLineStyle , &val);
-}
-
-} // namespace anon
-
-
-// Constructor
-LScreen::LScreen(WorkArea & o)
- : owner(o), force_clear(true)
+using std::max;
+using std::endl;
+
+LyXScreen::LyXScreen()
+ : force_clear_(true), cursor_visible_(false)
{
- // the cursor isnt yet visible
- cursor_visible = false;
- cursor_pixmap = 0;
- cursor_pixmap_x = 0;
- cursor_pixmap_y = 0;
- cursor_pixmap_w = 0;
- cursor_pixmap_h = 0;
-
- // We need this GC
- gc_copy = createGC();
}
-LScreen::~LScreen()
+LyXScreen::~LyXScreen()
{
- XFreeGC(fl_get_display(), gc_copy);
}
+// FIXME: GUII these cursor methods need to decide
+// whether the workarea is focused or not
-void LScreen::reset()
+void LyXScreen::showCursor(LyXText const * text, BufferView const * bv)
{
- XFreeGC(fl_get_display(), gc_copy);
- // the cursor isnt yet visible
- cursor_visible = false;
- cursor_pixmap = 0;
- cursor_pixmap_x = 0;
- cursor_pixmap_y = 0;
- cursor_pixmap_w = 0;
- cursor_pixmap_h = 0;
-
- // We need this GC
- gc_copy = createGC();
-}
+ if (cursor_visible_)
+ return;
+ workarea().getPainter().start();
-void LScreen::setCursorColor()
-{
- if (!lyxColorHandler.get()) return;
-
- GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
-
- XGCValues val;
- XGetGCValues(fl_get_display(),
- gc, GCForeground, &val);
- XChangeGC(fl_get_display(), gc_copy, GCForeground, &val);
-}
-
-
-void LScreen::redraw(LyXText * text, BufferView * bv)
-{
- drawFromTo(text, bv, 0, owner.workHeight(), 0, 0, text == bv->text);
- expose(0, 0, owner.workWidth(), owner.workHeight());
- if (cursor_visible) {
- cursor_visible = false;
- bv->showCursor();
- }
-}
-
-
-void LScreen::expose(int x, int y, int exp_width, int exp_height)
-{
- XCopyArea(fl_get_display(),
- owner.getPixmap(),
- owner.getWin(),
- gc_copy,
- x, y,
- exp_width, exp_height,
- x + owner.xpos(),
- y + owner.ypos());
-}
-
-
-void LScreen::drawFromTo(LyXText * text, BufferView * bv,
- int y1, int y2, int y_offset, int x_offset,
- bool internal)
-{
- int y_text = text->first_y + y1;
-
- // get the first needed row
- Row * row = text->getRowNearY(y_text);
- // y_text is now the real beginning of the row
-
- int y = y_text - text->first_y;
- // y1 is now the real beginning of row on the screen
-
- while (row != 0 && y < y2) {
- LyXText::text_status st = text->status();
- text->getVisibleRow(bv, y + y_offset,
- x_offset, row, y + text->first_y);
- internal = internal && (st != LyXText::CHANGED_IN_DRAW);
- while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
- text->fullRebreak(bv);
- st = LyXText::NEED_MORE_REFRESH;
- text->setCursor(bv, text->cursor.par(),
- text->cursor.pos());
- text->status(bv, st);
- // we should be sure our row-pointer is still valid, so it's
- // better to recompute it.
- y_text = y + text->first_y;
- row = text->getRowNearY(y_text);
- y = y_text - text->first_y;
- text->getVisibleRow(bv, y + y_offset,
- x_offset, row, y + text->first_y);
- }
- y += row->height();
- row = row->next();
- }
- force_clear = false;
-
- // maybe we have to clear the screen at the bottom
- if ((y < y2) && text->bv_owner) {
- owner.getPainter().fillRectangle(0, y,
- owner.workWidth(),
- y2 - y,
- LColor::bottomarea);
- }
-}
-
-
-void LScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
- int y_text, int y_offset, int x_offset)
-{
- int const y = y_text - text->first_y + y_offset;
-
- if (((y + row->height()) > 0) &&
- ((y - row->height()) <= static_cast<int>(owner.workHeight()))) {
- // ok there is something visible
- text->getVisibleRow(bv, y, x_offset, row, y + text->first_y);
- }
- force_clear = false;
-}
-
-
-/* draws the screen, starting with textposition y. uses as much already
- * printed pixels as possible */
-void LScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
-{
- if (cursor_visible) hideCursor();
-
- int const old_first = text->first_y;
- bool internal = (text == bv->text);
- text->first_y = y;
-
- // is any optimiziation possible?
- if ((y - old_first) < owner.workHeight()
- && (old_first - y) < owner.workHeight())
- {
- if (text->first_y < old_first) {
- drawFromTo(text, bv, 0,
- old_first - text->first_y, 0, 0, internal);
- XCopyArea (fl_get_display(),
- owner.getWin(),
- owner.getWin(),
- gc_copy,
- owner.xpos(),
- owner.ypos(),
- owner.workWidth(),
- owner.workHeight() - old_first + text->first_y,
- owner.xpos(),
- owner.ypos() + old_first - text->first_y
- );
- // expose the area drawn
- expose(0, 0,
- owner.workWidth(),
- old_first - text->first_y);
- } else {
- drawFromTo(text, bv,
- owner.workHeight() + old_first - text->first_y,
- owner.workHeight(), 0, 0, internal);
- XCopyArea (fl_get_display(),
- owner.getWin(),
- owner.getWin(),
- gc_copy,
- owner.xpos(),
- owner.ypos() + text->first_y - old_first,
- owner.workWidth(),
- owner.workHeight() + old_first - text->first_y,
- owner.xpos(),
- owner.ypos());
- // expose the area drawn
- expose(0, owner.workHeight() + old_first - text->first_y,
- owner.workWidth(), text->first_y - old_first);
- }
- } else {
- // make a dumb new-draw
- drawFromTo(text, bv, 0, owner.workHeight(), 0, 0, internal);
- expose(0, 0, owner.workWidth(), owner.workHeight());
- }
-}
-
-
-void LScreen::showCursor(LyXText const * text, BufferView const * bv)
-{
- if (!cursor_visible) {
- Cursor_Shape shape = BAR_SHAPE;
- if (text->real_current_font.language() !=
- bv->buffer()->params.language
- || text->real_current_font.isVisibleRightToLeft()
- != bv->buffer()->params.language->RightToLeft())
- shape = (text->real_current_font.isVisibleRightToLeft())
- ? REVERSED_L_SHAPE : L_SHAPE;
- showManualCursor(text, text->cursor.x(), text->cursor.y(),
- font_metrics::maxAscent(text->real_current_font),
- font_metrics::maxDescent(text->real_current_font),
- shape);
+ Cursor_Shape shape = BAR_SHAPE;
+ BufferParams const & bp(bv->buffer()->params);
+ LyXFont const & realfont(text->real_current_font);
+
+ if (realfont.language() != bp.language
+ || realfont.isVisibleRightToLeft()
+ != bp.language->RightToLeft()) {
+ shape = (realfont.isVisibleRightToLeft())
+ ? REVERSED_L_SHAPE : L_SHAPE;
}
+
+ showManualCursor(text, text->cursor.x(), text->cursor.y(),
+ font_metrics::maxAscent(realfont),
+ font_metrics::maxDescent(realfont),
+ shape);
+
+ workarea().getPainter().end();
}
-/* returns true if first has changed, otherwise false */
-bool LScreen::fitManualCursor(LyXText * text, BufferView * bv,
- int /*x*/, int y, int asc, int desc)
+bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
+ int /*x*/, int y, int asc, int desc)
{
+ int const vheight = workarea().workHeight();
int newtop = text->first_y;
-
- if (y + desc - text->first_y >= static_cast<int>(owner.workHeight()))
- newtop = y - 3 * owner.workHeight() / 4; // the scroll region must be so big!!
+
+ if (y + desc - text->first_y >= vheight)
+ newtop = y - 3 * vheight / 4; // the scroll region must be so big!!
else if (y - asc < text->first_y
&& text->first_y > 0) {
- newtop = y - owner.workHeight() / 4;
+ newtop = y - vheight / 4;
}
newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb)
-
+
if (newtop != text->first_y) {
draw(text, bv, newtop);
text->first_y = newtop;
}
-void LScreen::showManualCursor(LyXText const * text, int x, int y,
- int asc, int desc, Cursor_Shape shape)
+void LyXScreen::cursorToggle(BufferView * bv) const
{
- // Update the cursor color.
- setCursorColor();
-
- int const y1 = max(y - text->first_y - asc, 0);
- int const y_tmp = min(y - text->first_y + desc,
- static_cast<int>(owner.workHeight()));
-
- // Secure against very strange situations
- int const y2 = max(y_tmp, y1);
-
- if (cursor_pixmap) {
- XFreePixmap(fl_get_display(), cursor_pixmap);
- cursor_pixmap = 0;
- }
-
- if (y2 > 0 && y1 < int(owner.workHeight())) {
- cursor_pixmap_h = y2 - y1 + 1;
- cursor_pixmap_y = y1;
-
- switch (shape) {
- case BAR_SHAPE:
- cursor_pixmap_w = 1;
- cursor_pixmap_x = x;
- break;
- case L_SHAPE:
- cursor_pixmap_w = cursor_pixmap_h/3;
- cursor_pixmap_x = x;
- break;
- case REVERSED_L_SHAPE:
- cursor_pixmap_w = cursor_pixmap_h/3;
- cursor_pixmap_x = x - cursor_pixmap_w + 1;
- break;
- }
-
- cursor_pixmap =
- XCreatePixmap (fl_get_display(),
- fl_root,
- cursor_pixmap_w,
- cursor_pixmap_h,
- fl_get_visual_depth());
- XCopyArea (fl_get_display(),
- owner.getWin(),
- cursor_pixmap,
- gc_copy,
- owner.xpos() + cursor_pixmap_x,
- owner.ypos() + cursor_pixmap_y,
- cursor_pixmap_w,
- cursor_pixmap_h,
- 0, 0);
- XDrawLine(fl_get_display(),
- owner.getWin(),
- gc_copy,
- x + owner.xpos(),
- y1 + owner.ypos(),
- x + owner.xpos(),
- y2 + owner.ypos());
- switch (shape) {
- case BAR_SHAPE:
- break;
- case L_SHAPE:
- case REVERSED_L_SHAPE:
- int const rectangle_h = (cursor_pixmap_h + 10) / 20;
- XFillRectangle(fl_get_display(),
- owner.getWin(),
- gc_copy,
- cursor_pixmap_x + owner.xpos(),
- y2 - rectangle_h + 1 + owner.ypos(),
- cursor_pixmap_w - 1, rectangle_h);
- break;
- }
-
- }
- cursor_visible = true;
-}
-
-
-void LScreen::hideCursor()
-{
- if (!cursor_visible) return;
-
- if (cursor_pixmap) {
- XCopyArea (fl_get_display(),
- cursor_pixmap,
- owner.getWin(),
- gc_copy,
- 0, 0,
- cursor_pixmap_w, cursor_pixmap_h,
- cursor_pixmap_x + owner.xpos(),
- cursor_pixmap_y + owner.ypos());
- }
- cursor_visible = false;
-}
-
-
-void LScreen::cursorToggle(BufferView * bv) const
-{
- if (cursor_visible)
+ if (cursor_visible_)
bv->hideCursor();
else
bv->showCursor();
}
-/* returns a new top so that the cursor is visible */
-unsigned int LScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
+unsigned int LyXScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
{
- int const vheight = owner.workHeight();
- int newtop = top_y;
+ int const vheight = workarea().workHeight();
+ int newtop = top_y;
Row * row = cursor.row();
// Is this a hack? Yes, probably... (Lgb)
if (!row)
return max(newtop, 0);
-
+
if (cursor.y() - row->baseline() + row->height()
- top_y >= vheight) {
if (row->height() < vheight
newtop = cursor.y()
- vheight / 2; /* the scroll region must be so big!! */
}
-
- } else if (static_cast<int>(cursor.y() - row->baseline()) <
+
+ } else if (static_cast<int>((cursor.y()) - row->baseline()) <
top_y && top_y > 0) {
if (row->height() < vheight
&& row->height() > vheight / 4) {
}
-/* scrolls the screen so that the cursor is visible, if necessary.
-* returns true if a change was made, otherwise false */
-bool LScreen::fitCursor(LyXText * text, BufferView * bv)
+bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
{
// Is a change necessary?
int const newtop = topCursorVisible(text->cursor, text->first_y);
return result;
}
-
-void LScreen::update(LyXText * text, BufferView * bv,
- int y_offset, int x_offset)
+
+void LyXScreen::update(LyXText * text, BufferView * bv,
+ int yo, int xo)
{
+ int const vwidth = workarea().workWidth();
+ int const vheight = workarea().workHeight();
+
+ workarea().getPainter().start();
+
switch (text->status()) {
case LyXText::NEED_MORE_REFRESH:
{
int const y = max(int(text->refresh_y - text->first_y), 0);
- drawFromTo(text, bv, y, owner.workHeight(), y_offset, x_offset);
+ drawFromTo(text, bv, y, vheight, yo, xo);
text->refresh_y = 0;
// otherwise this is called ONLY from BufferView_pimpl(update)
// or we should see to set this flag accordingly
if (text != bv->text)
text->status(bv, LyXText::UNCHANGED);
- expose(0, y, owner.workWidth(), owner.workHeight() - y);
+ expose(0, y, vwidth, vheight - y);
}
break;
case LyXText::NEED_VERY_LITTLE_REFRESH:
{
// ok I will update the current cursor row
drawOneRow(text, bv, text->refresh_row, text->refresh_y,
- y_offset, x_offset);
+ yo, xo);
// this because if we had a major update the refresh_row could
// have been set to 0!
if (text->refresh_row) {
// or we should see to set this flag accordingly
if (text != bv->text)
text->status(bv, LyXText::UNCHANGED);
- expose(0, text->refresh_y - text->first_y + y_offset,
- owner.workWidth(), text->refresh_row->height());
+ expose(0, text->refresh_y - text->first_y + yo,
+ vwidth, text->refresh_row->height());
}
}
break;
// Nothing needs done
break;
}
+
+ workarea().getPainter().end();
}
-void LScreen::toggleSelection(LyXText * text, BufferView * bv,
+void LyXScreen::toggleSelection(LyXText * text, BufferView * bv,
bool kill_selection,
- int y_offset, int x_offset)
+ int yo, int xo)
{
// only if there is a selection
if (!text->selection.set()) return;
- text->selection.end.row()->baseline()
+ text->selection.end.row()->height()),
text->first_y),
- static_cast<int>(text->first_y + owner.workHeight()));
+ static_cast<int>(text->first_y + workarea().workHeight()));
int const top = min(
max(static_cast<int>(text->selection.start.y() -
text->selection.start.row()->baseline()),
text->first_y),
- static_cast<int>(text->first_y + owner.workHeight()));
+ static_cast<int>(text->first_y + workarea().workHeight()));
if (kill_selection)
text->selection.set(false);
+
+ workarea().getPainter().start();
+
drawFromTo(text, bv, top - text->first_y, bottom - text->first_y,
- y_offset, x_offset);
+ yo, xo);
expose(0, top - text->first_y,
- owner.workWidth(),
- bottom - text->first_y - (top - text->first_y));
+ workarea().workWidth(),
+ bottom - text->first_y - (top - text->first_y));
+
+ workarea().getPainter().end();
}
-
-
-void LScreen::toggleToggle(LyXText * text, BufferView * bv,
- int y_offset, int x_offset)
+
+
+void LyXScreen::toggleToggle(LyXText * text, BufferView * bv,
+ int yo, int xo)
{
if (text->toggle_cursor.par() == text->toggle_end_cursor.par()
&& text->toggle_cursor.pos() == text->toggle_end_cursor.pos())
return;
-
+
int const top_tmp = text->toggle_cursor.y()
- text->toggle_cursor.row()->baseline();
int const bottom_tmp = text->toggle_end_cursor.y()
- text->toggle_end_cursor.row()->baseline()
+ text->toggle_end_cursor.row()->height();
-
- int const offset = y_offset < 0 ? y_offset : 0;
+
+ int const offset = yo < 0 ? yo : 0;
int const bottom = min(max(bottom_tmp, text->first_y),
- static_cast<int>(text->first_y + owner.workHeight()))-offset;
+ static_cast<int>(text->first_y + workarea().workHeight())) - offset;
int const top = min(max(top_tmp, text->first_y),
- static_cast<int>(text->first_y + owner.workHeight()))-offset;
+ static_cast<int>(text->first_y + workarea().workHeight())) - offset;
+
+ workarea().getPainter().start();
drawFromTo(text, bv, top - text->first_y,
- bottom - text->first_y, y_offset,
- x_offset);
- expose(0, top - text->first_y, owner.workWidth(),
+ bottom - text->first_y, yo,
+ xo);
+ expose(0, top - text->first_y, workarea().workWidth(),
bottom - text->first_y - (top - text->first_y));
+
+ workarea().getPainter().end();
+}
+
+
+void LyXScreen::redraw(LyXText * text, BufferView * bv)
+{
+ workarea().getPainter().start();
+
+ if (!text) {
+ greyOut();
+ expose(0, 0, workarea().workWidth(), workarea().workHeight());
+ workarea().getPainter().end();
+ return;
+ }
+
+ drawFromTo(text, bv, 0, workarea().workHeight(), 0, 0, text == bv->text);
+ expose(0, 0, workarea().workWidth(), workarea().workHeight());
+
+ workarea().getPainter().end();
+
+ if (cursor_visible_) {
+ cursor_visible_ = false;
+ bv->showCursor();
+ }
+
+}
+
+
+void LyXScreen::greyOut()
+{
+ workarea().getPainter().fillRectangle(0, 0,
+ workarea().workWidth(),
+ workarea().workHeight(),
+ LColor::bottomarea);
+}
+
+
+void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
+ int y1, int y2, int yo, int xo,
+ bool internal)
+{
+ int y_text = text->first_y + y1;
+
+ // get the first needed row
+ Row * row = text->getRowNearY(y_text);
+ // y_text is now the real beginning of the row
+
+ int y = y_text - text->first_y;
+ // y1 is now the real beginning of row on the screen
+
+ while (row != 0 && y < y2) {
+ LyXText::text_status st = text->status();
+ text->getVisibleRow(bv, y + yo,
+ xo, row, y + text->first_y);
+ internal = internal && (st != LyXText::CHANGED_IN_DRAW);
+ while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
+ text->fullRebreak(bv);
+ st = LyXText::NEED_MORE_REFRESH;
+ text->setCursor(bv, text->cursor.par(), text->cursor.pos());
+ text->status(bv, st);
+ text->getVisibleRow(bv, y + yo,
+ xo, row, y + text->first_y);
+ }
+ y += row->height();
+ row = row->next();
+ }
+ force_clear_ = false;
+
+ // maybe we have to clear the screen at the bottom
+ if ((y < y2) && text->bv_owner) {
+ workarea().getPainter().fillRectangle(0, y,
+ workarea().workWidth(), y2 - y,
+ LColor::bottomarea);
+ }
+}
+
+
+void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
+ int y_text, int yo, int xo)
+{
+ int const y = y_text - text->first_y + yo;
+
+ if (((y + row->height()) > 0) &&
+ ((y - row->height()) <= static_cast<int>(workarea().workHeight()))) {
+ text->getVisibleRow(bv, y, xo, row, y + text->first_y);
+ }
+ force_clear_ = false;
}
*
* \author unknown
* \author John Levon <moz@compsoc.man.ac.uk>
- */
+ */
-#ifndef LYXSCREEN_H
-#define LYXSCREEN_H
+#ifndef SCREEN_H
+#define SCREEN_H
#ifdef __GNUG__
#pragma interface
#endif
-
-#include <X11/Xlib.h>
-
+
class LyXText;
class LyXCursor;
class WorkArea;
-class Buffer;
class BufferView;
-
struct Row;
/**
- * LScreen - document rendering management
+ * LyXScreen - document rendering management
*
- * This class is used to manage the on-screen rendering inside the
+ * This class is used to manage the on-screen rendering inside the
* work area; it is responsible for deciding which LyXText rows
* need re-drawing.
*
*
* The blinking cursor is also handled here.
*/
-class LScreen {
+class LyXScreen {
public:
- ///
+ /// types of cursor in work area
enum Cursor_Shape {
- ///
+ /// normal I-beam
BAR_SHAPE,
- ///
+ /// L-shape for locked insets of a different language
L_SHAPE,
- ///
+ /// reverse L-shape for RTL text
REVERSED_L_SHAPE
};
- ///
- LScreen(WorkArea &);
+ LyXScreen();
- ///
- ~LScreen();
-
- void reset();
+ virtual ~LyXScreen();
+
+ /**
+ * draw the screen from a given position
+ * @param y the text position to draw from
+ *
+ * Uses as much of the already printed pixmap as possible
+ */
+ virtual void draw(LyXText *, BufferView *, unsigned int y) = 0;
+
+ /**
+ * showManualCursor - display the cursor on the work area
+ * @param text the lyx text containing the cursor
+ * @param x the x position of the cursor
+ * @param y the y position of the row's baseline
+ * @param asc ascent of the row
+ * @param desc descent of the row
+ * @param shape the current shape
+ */
+ virtual void showManualCursor(LyXText const *, int x, int y,
+ int asc, int desc,
+ Cursor_Shape shape) = 0;
+
+ /// unpaint the cursor painted by showManualCursor()
+ virtual void hideCursor() = 0;
+
+ /**
+ * fit the cursor onto the visible work area, scrolling if necessary
+ * @param bv the buffer view
+ * @param vheight the height of the visible region
+ * @param base_y the top of the lyxtext to look at
+ * @param x the new x position
+ * @param y the new y position
+ * @param a ascent of the cursor's row
+ * @param d descent of the cursor's row
+ * @return true if the work area needs scrolling as a result
+ */
+ bool fitManualCursor(BufferView * bv, LyXText * text,
+ int x, int y, int a, int d);
+
+ /// redraw the screen, without using existing pixmap
+ virtual void redraw(LyXText *, BufferView *);
+
+ /// draw the cursor if it's not already shown
+ virtual void showCursor(LyXText const *, BufferView const *);
- /// Sets the cursor color to LColor::cursor.
- void setCursorColor();
-
- /** Draws the screen form textposition y. Uses as much of
- the already printed pixmap as possible */
- void draw(LyXText *, BufferView *, unsigned int y);
-
- /// Redraws the screen, without using existing pixmap
- void redraw(LyXText *, BufferView *);
-
/**
* topCursorVisible - get a new "top" to make the cursor visible
* @param c the cursor
* This helper function calculates a new y co-ordinate for
* the top of the containing region such that the cursor contained
* within the LyXText is "nicely" visible.
- */
- unsigned int topCursorVisible(LyXCursor const & c, int top_y);
+ */
+ virtual unsigned int topCursorVisible(LyXCursor const & c, int top_y);
- /// Redraws the screen such that the cursor is visible
- bool fitCursor(LyXText *, BufferView *);
- ///
- void showCursor(LyXText const *, BufferView const *);
- ///
- void hideCursor();
- ///
- void cursorToggle(BufferView *) const;
- ///
- void showManualCursor(LyXText const *, int x, int y,
- int asc, int desc,
- Cursor_Shape shape);
- /// returns 1 if first has changed, otherwise 0
- bool fitManualCursor(LyXText *, BufferView *, int, int, int, int);
- ///
- void toggleSelection(LyXText *, BufferView *, bool = true,
+ /**
+ * fitCursor - fit the cursor onto the work area
+ * @param text the text containing the cursor
+ * @param bv the bufferview
+ * @return true if a change was necessary
+ *
+ * Scrolls the screen so that the cursor is visible,
+ */
+ virtual bool fitCursor(LyXText *, BufferView *);
+
+ /// show the cursor if it's not, and vice versa
+ virtual void cursorToggle(BufferView *) const;
+
+ /**
+ * update - update part of the screen rendering
+ * @param text the containing text region
+ * @param bv the bufferview
+ * @param xo the x offset into the text
+ * @param yo the x offset into the text
+ *
+ * Updates part of the screen. If text->status is
+ * LyXText::NEED_MORE_REFRESH, we update from the
+ * point of change and to the end of the screen.
+ * If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
+ * we only update the current row.
+ */
+ virtual void update(LyXText * text, BufferView * bv, int yo = 0, int xo = 0);
+
+ /// FIXME
+ virtual void toggleSelection(LyXText *, BufferView *, bool = true,
int y_offset = 0, int x_offset = 0);
- ///
- void toggleToggle(LyXText *, BufferView *,
+
+ /// FIXME - at least change the name !!
+ virtual void toggleToggle(LyXText *, BufferView *,
int y_offset = 0, int x_offset = 0);
+
+ /// FIXME
+ virtual bool forceClear() const { return force_clear_; }
- /** Updates part of the screen. If text->status is
- LyXText::NEED_MORE_REFRESH, we update from the
- point of change and to the end of the screen.
- If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
- we only update the current row. */
- void update(LyXText *, BufferView *, int y_offset=0, int x_offset=0);
- ///
- bool forceClear() const { return force_clear; }
-
- ///
- bool cursor_visible;
-private:
- /// Copies specified area of pixmap to screen
- void expose(int x, int y, int exp_width, int exp_height);
+protected:
+ /// copies specified area of pixmap to screen
+ virtual void expose(int x, int y, int exp_width, int exp_height) = 0;
+ /// get the work area
+ virtual WorkArea & workarea() const = 0;
+
/// y1 and y2 are coordinates of the screen
- void drawFromTo(LyXText *, BufferView *, int y1, int y2,
- int y_offset = 0, int x_offset = 0, bool internal=false);
+ virtual void drawFromTo(LyXText *, BufferView *, int y1, int y2,
+ int y_offset = 0, int x_offset = 0, bool internal = false);
/// y is a coordinate of the text
- void drawOneRow(LyXText *, BufferView *, Row * row,
+ virtual void drawOneRow(LyXText *, BufferView *, Row * row,
int y_text, int y_offset = 0, int x_offset = 0);
-
- ///
- WorkArea & owner;
-
- ///
- Pixmap cursor_pixmap;
- ///
- int cursor_pixmap_x;
- ///
- int cursor_pixmap_y;
- ///
- int cursor_pixmap_w;
- ///
- int cursor_pixmap_h;
- ///
- GC gc_copy;
- ///
- bool force_clear;
+
+ /// grey out (no buffer)
+ void greyOut();
+
+ /// FIXME ?
+ bool force_clear_;
+
+ /// is the blinking cursor currently drawn
+ bool cursor_visible_;
};
-#endif
+#endif // SCREEN_H
-2002-06-13 Juergen Spitzmueller <j.spitzmueller@gmx.de>
+2002-06-16 Lars Gullik Bjønnes <larsbj@birdstep.com>
- * FormRef.C: Add Tooltips
+ * changes to let the function setup happen in frontends
+ * guiapi.C: new file
-2002-06-18 Angus Leeming <leeming@lyx.org>
+2002-06-16 <alstrup@diku.dk>
- * forms/.cvsignore: ignore any generated files/dirs.
+ * xscreen.C (draw): After drawing, we wait for X with XSync..
+
+ * XWorkArea.[Ch]: Xforms implementation of GUII WorkArea.
+
+ * XPainter.[Ch]: Use XWorkArea instead of WorkArea.
+
+ * xscreen.[Ch]: Use XWorkArea instead of WorkArea.
+
+ * WorkAreaFactory.C: New file for GUII WorkArea.
+
+ * LyXScreenFactory.C: WorkArea GUIIized.
+
+2002-06-15 Lyx Development team <larsbj@birdstep.com>
+
+ * LyXKeySymFactory.C: Added XForms implementation.
+
+ * XLyXKeySym.[Ch]: Added XForms implementation of the LyXKeySym
+ stuff.
+
+ * XWorkArea.[Ch]: Use LyXKeySym in signal interface for keypress.
+
+2002-06-14 Lyx Development team <lyx@electronia>
+
+ * LyXScreenFactory.C: Implementation for XForms.
+
+ * xscreen.[Ch]: Added implementation of LyXScreen for XForms,
+ called XScreen (surprise!).
2002-06-14 Angus Leeming <leeming@lyx.org>
* xforms_helpers.[Ch]: removed scex, idex functions.
* Most other files: minor changes associated with the above.
-
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* XWorkArea.h:
* XWorkArea.C: move scrolling logic into here
-
+
* ColorHandler.h:
* ColorHandler.C:
* XPainter.h:
* XPainter.C: remove unused stuff, s/PainterBase/Painter/,
s/Painter/XPainter/
-
+
2002-06-12 Angus Leeming <leeming@lyx.org>
* lyx_gui.C (parse_init): exit isn't in namespace lyx_gui!
2002-05-24 Martin Vermeer <martin.vermeer@hut.fi>
- * FormMathsDelim.C: fix delimiter pre-display rendering
+ * FormMathsDelim.C: fix delimiter pre-display rendering
mess-up bug (354)
2002-06-12 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* XFormsView.h:
* XFormsView.C: move init() back to LyXView
-
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* GUIRunTime.C: remove in favour of ...
* XFormsView.h:
* XFormsView.C: change show() prototype
-
+
* XPainter.C:
* xfont_loader.C: don't use GUIRunTime any more
-
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
- * ColorHandler.C:
+ * ColorHandler.C:
* FontInfo.h:
* FormBase.C:
* FormBaseDeprecated.C:
* MathsSymbols.C:
* Menubar_pimpl.C: minor cleanups
-
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* xformsGImage.C:
* FontInfo.h:
* FontInfo.C: some cleanup
-
- * XWorkArea.C:
+
+ * XWorkArea.C:
* XFormsView.h:
* XFormsView.C: some minor cleanup, use of
scoped_ptr
* XWorkArea.h:
* XWorkArea.C: use workHeight(), remove enter/leaveView
-
+
2002-06-11 John Levon <moz@compsoc.man.ac.uk>
* XWorkArea.h:
* XWorkArea.C: remove belowMouse() and active()
-
+
2002-06-11 John Levon <moz@compsoc.man.ac.uk>
* xfont_metrics.h:
* XPainter.C: X-specific metrics stuff moved into xforms/ only
2002-06-11 Edwin Leuven <leuven@fee.uva.nl>
-
- * FormParagraph.[Ch]: moved to mvc
- * form_paragraph.[Ch]: idem
- * forms/form_paragraph.fd: idem
- * Dialogs.C: idem
+
+ * FormParagraph.[Ch]: moved to mvc
+ * form_paragraph.[Ch]: idem
+ * forms/form_paragraph.fd: idem
+ * Dialogs.C: idem
2002-06-06 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* xformsGImage.h: use FLIMAGE_H_LOCATION to include flimage.h.
2002-06-10 Lars Gullik Bjønnes <larsbj@birdstep.com>
-
+
* FormMathsPanel.C: do not include ButtonController.tmpl
* FormPreferences.C: ditto
* xformsBC.C: ditto
2002-06-04 John Levon <moz@compsoc.man.ac.uk>
* xformsGImage.h: an xforms build fix
-
+
2002-06-02 Michael A. Koziarski <michael@koziarski.com>
-
+
* Tooltips.C: fix some sigc++ -> boost errors.
-
+
2002-06-02 John Levon <moz@compsoc.man.ac.uk>
* GUIRunTime.C:
2002-05-10 Herbert Voss <voss@perce.de>
- * FormInclude.C (input, update): disable load-button when
+ * FormInclude.C (input, update): disable load-button when
"use verbatim" is enabled
2002-05-30 Lars Gullik Bjønnes <larsbj@birdstep.com>
#endif
#include "Dialogs.h"
+#include "Tooltips.h"
-#include "GUI.h"
-#include "xformsBC.h"
-
-#include "combox.h" // needed for clean destruction of boost::scoped_ptr
-#include "forms/form_aboutlyx.h"
-#include "forms/form_bibitem.h"
-#include "forms/form_bibtex.h"
-#include "forms/form_browser.h"
-#include "forms/form_character.h"
-#include "forms/form_citation.h"
-#include "forms/form_error.h"
-#include "forms/form_ert.h"
-#include "forms/form_external.h"
-#include "forms/form_float.h"
-#include "forms/form_forks.h"
-#include "forms/form_graphics.h"
-#include "forms/form_include.h"
-#include "forms/form_index.h"
-#include "forms/form_minipage.h"
-#include "forms/form_paragraph.h"
-#include "forms/form_preamble.h"
-#include "forms/form_print.h"
-#include "forms/form_ref.h"
-#include "forms/form_search.h"
-#include "forms/form_sendto.h"
-#include "forms/form_spellchecker.h"
-#include "forms/form_tabular_create.h"
-#include "forms/form_texinfo.h"
-#include "forms/form_thesaurus.h"
-#include "forms/form_toc.h"
-#include "forms/form_url.h"
-
-#include "FormAboutlyx.h"
-#include "FormBibitem.h"
-#include "FormBibtex.h"
-#include "FormCharacter.h"
-#include "FormCitation.h"
-#include "FormError.h"
-#include "FormERT.h"
-#include "FormExternal.h"
-#include "FormFloat.h"
-#include "FormForks.h"
-#include "FormGraphics.h"
-#include "FormInclude.h"
-#include "FormIndex.h"
-#include "FormLog.h"
-#include "FormMinipage.h"
-#include "FormParagraph.h"
-#include "FormPreamble.h"
-#include "FormPrint.h"
-#include "FormRef.h"
-#include "FormSearch.h"
-#include "FormSendto.h"
-#include "FormShowFile.h"
-#include "FormSpellchecker.h"
-#include "FormTabularCreate.h"
-#include "FormTexinfo.h"
-#include "FormThesaurus.h"
-#include "FormToc.h"
-#include "FormUrl.h"
-#include "FormVCLog.h"
+LyXView * dialogs_lyxview;
-#include "FormDocument.h"
-#include "FormMathsPanel.h"
-#include "FormPreferences.h"
-#include "FormTabular.h"
-
-#include "Tooltips.h"
/// Are the tooltips on or off?
bool Dialogs::tooltipsEnabled()
Dialogs::Dialogs(LyXView * lv)
{
- add(new GUI<ControlAboutlyx, FormAboutlyx,
- OkCancelPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlBibitem, FormBibitem,
- OkCancelReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlBibtex, FormBibtex,
- OkCancelReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlCharacter, FormCharacter,
- OkApplyCancelReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlCitation, FormCitation,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlError, FormError,
- OkCancelPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlERT, FormERT,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlExternal, FormExternal,
- OkApplyCancelReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlForks, FormForks,
- OkApplyCancelPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlGraphics, FormGraphics,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlInclude, FormInclude,
- OkCancelReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlIndex, FormIndex,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlLog, FormLog,
- OkCancelPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlMinipage, FormMinipage,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlFloat, FormFloat,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlParagraph, FormParagraph,
- OkApplyCancelReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlPreamble, FormPreamble,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlPrint, FormPrint,
- OkApplyCancelPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlRef, FormRef,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlSearch, FormSearch,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlSendto, FormSendto,
- OkApplyCancelPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlShowFile, FormShowFile,
- OkCancelPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlSpellchecker, FormSpellchecker,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlTabularCreate, FormTabularCreate,
- OkApplyCancelReadOnlyPolicy, xformsBC>(*lv, *this));
-#ifdef HAVE_LIBAIKSAURUS
- add(new GUI<ControlThesaurus, FormThesaurus,
- OkApplyCancelReadOnlyPolicy, xformsBC>(*lv, *this));
+#if 1
+ dialogs_lyxview = lv;
#endif
- add(new GUI<ControlTexinfo, FormTexinfo,
- OkCancelPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlToc, FormToc,
- OkCancelPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlUrl, FormUrl,
- NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
- add(new GUI<ControlVCLog, FormVCLog,
- OkCancelPolicy, xformsBC>(*lv, *this));
-
- add(new FormDocument(lv, this));
- add(new FormMathsPanel(lv, this));
- add(new FormPreferences(lv, this));
- add(new FormTabular(lv, this));
-
// reduce the number of connections needed in
// dialogs by a simple connection here.
hideAll.connect(hideBufferDependent);
boost::scoped_ptr<FD_aboutlyx_license> license_;
};
+
#endif // FORMABOUTLYX_H
Tooltips & tooltips();
+ friend void gui_ShowDocument(LyXView &, Dialogs &);
+
protected: // methods
/// Pointer to the actual instantiation of the ButtonController.
ActCell(0), Confirmed(0),
current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
{
+#if 0
// let the dialog be shown
// This is a permanent connection so we won't bother
// storing a copy because we won't be disconnecting.
d->showDocument = boost::bind(&FormDocument::show, this);
+#endif
}
ams_ops_.reset(new FormMathsBitmap(lv, d, *this, _("AMS Operators"), latex));
//showUnderMouse(false);
+#if 0
d->showMathPanel = boost::bind(&FormMathsPanel::show, this);
+#endif
}
*/
class FormMathsPanel : public FormBaseBD {
public:
+ friend void gui_ShowMathPanel(LyXView &, Dialogs &);
///
FormMathsPanel(LyXView *, Dialogs *);
///
public:
///
FormMathsSub(LyXView *, Dialogs *, FormMathsPanel const &,
- string const &, bool allowResize=true);
+ string const &, bool allowResize = true);
protected:
/// Pointer to the actual instantiation of the ButtonController.
} // namespace anon
-FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
- : FormBaseBI(lv, d, _("Preferences"), false),
+FormPreferences::FormPreferences(LyXView & lv, Dialogs & d)
+ : FormBaseBI(&lv, &d, _("Preferences"), false),
colors_(*this), converters_(*this), inputs_misc_(*this),
formats_(*this), interface_(*this), language_(*this),
lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
// let the dialog be shown
// This is a permanent connection so we won't bother
// storing a copy because we won't be disconnecting.
+#if 0
d->showPreferences = boost::bind(&FormPreferences::show, this);
+#endif
+#if 0
d->showSpellcheckerPreferences = boost::bind(&FormPreferences::showSpellPref, this);
+#endif
}
*/
class FormPreferences : public FormBaseBI {
public:
+ friend void gui_ShowPreferences(LyXView &, Dialogs &);
+ friend void gui_ShowSpellcheckerPreferences(LyXView &, Dialogs &);
///
- FormPreferences(LyXView *, Dialogs *);
+ FormPreferences(LyXView &, Dialogs &);
private:
/// Pointer to the actual instantiation of the ButtonController.
#include "ControlRef.h"
#include "FormRef.h"
#include "forms/form_ref.h"
-#include "Tooltips.h"
#include "xforms_helpers.h"
#include "insets/insetref.h"
#include "helper_funcs.h" // getStringFromVector
bc().addReadOnly(dialog_->button_update);
bc().addReadOnly(dialog_->input_name);
bc().addReadOnly(dialog_->input_ref);
-
- //set up the tooltip mechanism
- string str = _("Show the labels of another opened document. Useful if you are working with multipart documents, where you might want to refer to another doc.");
- tooltips().init(dialog_->choice_buffer, str);
-
- str = _("Choose a label to refer to.");
- tooltips().init(dialog_->browser_refs, str);
-
- str = _("Type in a label name. We recommend that you use the browser instead.");
- tooltips().init(dialog_->input_ref, str);
-
- str = _("Choose the reference style.");
- tooltips().init(dialog_->choice_type, str);
-
- str = _("Sort labels in alphabetical order.");
- tooltips().init(dialog_->check_sort, str);
-
- str = _("Refresh the list of labels.");
- tooltips().init(dialog_->button_update, str);
}
#include "gettext.h"
#include FORMS_H_LOCATION
+
FormShowFile::FormShowFile(ControlShowFile & c)
: FormCB<ControlShowFile, FormBrowser>(c, string())
{}
using std::remove_if;
-FormTabular::FormTabular(LyXView * lv, Dialogs * d)
- : FormInset(lv, d, _("Tabular Layout")),
+FormTabular::FormTabular(LyXView & lv, Dialogs & d)
+ : FormInset(&lv, &d, _("Tabular Layout")),
inset_(0), actCell_(-1), closing_(false)
{
+#if 0
// let the dialog be shown
// This is a permanent connection so we won't bother
// storing a copy because we won't be disconnecting.
d->showTabular = boost::bind(&FormTabular::showInset, this, _1);
d->updateTabular = boost::bind(&FormTabular::updateInset, this, _1);
+#endif
}
*/
class FormTabular : public FormInset {
public:
+ friend void gui_ShowTabular(InsetTabular *, LyXView &, Dialogs &);
+ friend void gui_UpdateTabular(InsetTabular *, LyXView &, Dialogs &);
+
/// #FormTabular x(LyXFunc ..., Dialogs ...);#
- FormTabular(LyXView *, Dialogs *);
+ FormTabular(LyXView &, Dialogs &);
private:
/// Pointer to the actual instantiation of the ButtonController.
--- /dev/null
+/**
+ * \file LyXKeySymFactory.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger & Juergen
+ */
+
+#include <config.h>
+
+#include "frontends/LyXKeySymFactory.h"
+
+#include "XLyXKeySym.h"
+
+namespace LyXKeySymFactory {
+
+LyXKeySym * create()
+{
+ return new XLyXKeySym();
+}
+
+}
--- /dev/null
+/**
+ * \file LyXScreenFactory.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#include <config.h>
+
+#include "frontends/LyXScreenFactory.h"
+
+#include "XWorkArea.h"
+#include "xscreen.h"
+
+namespace LyXScreenFactory {
+
+LyXScreen * create(WorkArea & owner)
+{
+ return new XScreen(static_cast<XWorkArea &>(owner));
+}
+
+}
xforms_resize.h \
$(XFORMSGIMAGE) xformsBC.C \
xformsBC.h \
+ xscreen.C \
+ xscreen.h \
Alert_pimpl.C \
Color.C \
Color.h \
FormUrl.h \
FormVCLog.C \
FormVCLog.h \
+ guiapi.C \
+ LyXKeySymFactory.C \
+ LyXScreenFactory.C \
MathsSymbols.C \
MathsSymbols.h \
Menubar_pimpl.C \
Toolbar_pimpl.h \
Tooltips.C \
Tooltips.h \
+ WorkAreaFactory.C \
XFormsView.C \
XFormsView.h \
+ XLyXKeySym.C \
+ XLyXKeySym.h \
XPainter.C \
XPainter.h \
XWorkArea.h \
--- /dev/null
+/**
+ * \file WorkAreaFactory.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#include <config.h>
+
+#include "frontends/WorkAreaFactory.h"
+
+#include "XWorkArea.h"
+
+namespace WorkAreaFactory {
+
+WorkArea * create(int x, int y, int w, int h)
+{
+ return new XWorkArea(x, y, w, h);
+}
+
+}
--- /dev/null
+/**
+ * \file XLyXKeySym.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger and Juergen
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "XLyXKeySym.h"
+
+#include "debug.h"
+
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+
+using std::endl;
+
+XLyXKeySym::XLyXKeySym()
+ : LyXKeySym(), keysym(NoSymbol)
+{
+}
+
+void XLyXKeySym::initFromKeySym(KeySym ks)
+{
+ keysym = ks;
+}
+
+void XLyXKeySym::init(string const & symbolname)
+{
+ keysym = XStringToKeysym(symbolname.c_str());
+ if (keysym == NoSymbol) {
+ lyxerr[Debug::KBMAP]
+ << "XLyXKeySym.C: No such keysym: "
+ << symbolname << endl;
+ }
+}
+
+bool XLyXKeySym::isOK() const
+{
+ return keysym != NoSymbol;
+}
+
+bool XLyXKeySym::isModifier() const
+{
+ // Can we be sure that this will work for all X Window
+ // implementations? (Lgb)
+ // Perhaps all of them should be explictly mentioned?
+ return ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
+ || keysym == XK_Mode_switch || keysym == 0x0);
+}
+
+string
+XLyXKeySym::getSymbolName() const
+{
+ char * name = XKeysymToString(keysym);
+ return name ? name : string();
+}
+
+char
+XLyXKeySym::getISOEncoded() const
+{
+ if (keysym == NoSymbol) {
+ return 0;
+ }
+
+ unsigned int c = keysym;
+
+ switch (c & 0x0000FF00) {
+ // latin 1 byte 3 = 0
+ case 0x00000000: break;
+ // latin 2 byte 3 = 1
+ case 0x00000100:
+ // latin 3 byte 3 = 2
+ case 0x00000200:
+ // latin 4 byte 3 = 3
+ case 0x00000300:
+ // cyrillic KOI8 & Co
+ case 0x00000600:
+ // greek
+ case 0x00000700:
+ // latin 8 byte 3 = 18 (0x12)
+ case 0x00001200:
+ // latin 9 byte 3 = 19 (0x13)
+ case 0x00001300:
+ c &= 0x000000FF;
+ break;
+ default:
+ c = 0;
+ }
+ return c;
+}
+
+bool XLyXKeySym::operator==(LyXKeySym const & k) const
+{
+ // This is dangerous! Ideally, we should use dynamic_cast instead,
+ // but on the other hand, we are sure that we will always get
+ // the right type, because we decide at compile time which
+ // frontend we use. (Asger)
+ return keysym == static_cast<XLyXKeySym const &>(k).keysym;
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file XLyXKeySym.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger and Juergen
+ */
+
+#ifndef XLYXKEYSYM_H
+#define XLYXKEYSYM_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+#include <X11/Xlib.h>
+#include "frontends/LyXKeySym.h"
+
+/**
+ * This is a base class for representing a keypress.
+ * Each frontend has to implement this to provide
+ * the functionality that LyX needs in regards to
+ * key presses.
+ */
+class XLyXKeySym : public LyXKeySym {
+public:
+ XLyXKeySym();
+
+ /// X11 specific initialization with an X11 KeySym
+ void initFromKeySym(KeySym);
+
+ virtual void init(string const & symbolname);
+
+ virtual ~XLyXKeySym() {}
+
+ /// Is this a valid key?
+ virtual bool isOK() const;
+
+ /// Is this a modifier key only?
+ virtual bool isModifier() const;
+
+ virtual string getSymbolName() const;
+
+ /**
+ * Return the value of the keysym into the local ISO encoding.
+ * This converts the LyXKeySym to a 8-bit encoded character.
+ * This relies on user to use the right encoding.
+ */
+ virtual char getISOEncoded() const;
+
+ virtual bool operator==(LyXKeySym const & k) const;
+
+private:
+ unsigned int keysym;
+};
+
+#endif
+
using std::max;
-XPainter::XPainter(WorkArea & xwa)
+XPainter::XPainter(XWorkArea & xwa)
: Painter(), owner_(xwa)
{
}
class LyXFont;
-class WorkArea;
+class XWorkArea;
/**
* XPainter - a painter implementation for Xlib
*/
class XPainter : public Painter {
public:
- XPainter(WorkArea &);
+ XPainter(XWorkArea &);
/// return the width of the work area in pixels
virtual int paperWidth() const;
private:
/// our owner who we paint upon
- WorkArea & owner_;
+ XWorkArea & owner_;
};
#endif // XPAINTER_H
#include "LyXView.h"
#include "lyxrc.h" // lyxrc.show_banner
#include "version.h" // lyx_version
+#include "XLyXKeySym.h"
#if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5))
#include "lyxlookup.h"
extern "C" {
- // Just a bunch of C wrappers around static members of WorkArea
+ // Just a bunch of C wrappers around static members of XWorkArea
static
- void C_WorkArea_scroll_cb(FL_OBJECT * ob, long)
+ void C_XWorkArea_scroll_cb(FL_OBJECT * ob, long)
{
- WorkArea * area = static_cast<WorkArea*>(ob->u_vdata);
+ XWorkArea * area = static_cast<XWorkArea*>(ob->u_vdata);
area->scroll_cb();
}
static
- int C_WorkArea_work_area_handler(FL_OBJECT * ob, int event,
+ int C_XWorkArea_work_area_handler(FL_OBJECT * ob, int event,
FL_Coord, FL_Coord,
int key, void * xev)
{
- return WorkArea::work_area_handler(ob, event,
+ return XWorkArea::work_area_handler(ob, event,
0, 0, key, xev);
}
static
- int C_WorkAreaEventCB(FL_FORM * form, void * xev) {
- WorkArea * wa = static_cast<WorkArea*>(form->u_vdata);
+ int C_XWorkAreaEventCB(FL_FORM * form, void * xev) {
+ XWorkArea * wa = static_cast<XWorkArea*>(form->u_vdata);
return wa->event_cb(static_cast<XEvent*>(xev));
}
}
-WorkArea::WorkArea(int x, int y, int w, int h)
+XWorkArea::XWorkArea(int x, int y, int w, int h)
: splash_(0), splash_text_(0), workareapixmap(0), painter_(*this)
{
fl_freeze_all_forms();
fl_set_object_resize(obj, FL_RESIZE_ALL);
fl_set_object_gravity(obj, NorthEastGravity, SouthEastGravity);
obj->u_vdata = this;
- fl_set_object_callback(obj, C_WorkArea_scroll_cb, 0);
+ fl_set_object_callback(obj, C_XWorkArea_scroll_cb, 0);
fl_set_scrollbar_bounds(scrollbar, 0.0, 0.0);
fl_set_scrollbar_value(scrollbar, 0.0);
fl_set_scrollbar_size(scrollbar, scrollbar->h);
x + bw, y + bw,
w - 15 - 2 * bw, // scrollbarwidth
h - 2 * bw, "",
- C_WorkArea_work_area_handler);
+ C_XWorkArea_work_area_handler);
obj->wantkey = FL_KEY_ALL;
- obj->u_vdata = this; /* This is how we pass the WorkArea
+ obj->u_vdata = this; /* This is how we pass the XWorkArea
to the work_area_handler. */
fl_set_object_boxtype(obj,FL_DOWN_BOX);
fl_set_object_resize(obj, FL_RESIZE_ALL);
/// X selection hook - xforms gets it wrong
fl_current_form->u_vdata = this;
- fl_register_raw_callback(fl_current_form, FL_ALL_EVENT, C_WorkAreaEventCB);
+ fl_register_raw_callback(fl_current_form, FL_ALL_EVENT, C_XWorkAreaEventCB);
fl_unfreeze_all_forms();
}
-WorkArea::~WorkArea()
+XWorkArea::~XWorkArea()
{
if (workareapixmap)
XFreePixmap(fl_get_display(), workareapixmap);
}
-void WorkArea::resize(int xpos, int ypos, int width, int height)
+void XWorkArea::resize(int xpos, int ypos, int width, int height)
{
fl_freeze_all_forms();
} // namespace anon
-void WorkArea::createPixmap(int width, int height)
+void XWorkArea::createPixmap(int width, int height)
{
// Three calls to createPixmap are needed to draw the initial view
// of LyX. Any more and the splash is destroyed.
}
-void WorkArea::greyOut() const
+void XWorkArea::greyOut() const
{
if (!splash_) {
fl_winset(FL_ObjWin(work_area));
}
-void WorkArea::setFocus() const
+void XWorkArea::setFocus() const
{
fl_set_focus_object(work_area->form, work_area);
}
-void WorkArea::setScrollbarParams(int height, int pos, int line_height)
+void XWorkArea::setScrollbarParams(int height, int pos, int line_height)
{
// we need to cache this for scroll_cb
doc_height_ = height;
// callback for scrollbar slider
-void WorkArea::scroll_cb()
+void XWorkArea::scroll_cb()
{
double const val = fl_get_scrollbar_value(scrollbar);
lyxerr[Debug::GUI] << "scroll: val: " << val << endl;
}
-int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
+int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
FL_Coord, FL_Coord ,
int key, void * xev)
{
static long scrollbar_value_old = -1;
XEvent * ev = static_cast<XEvent*>(xev);
- WorkArea * area = static_cast<WorkArea*>(ob->u_vdata);
+ XWorkArea * area = static_cast<XWorkArea*>(ob->u_vdata);
if (!area) return 1;
// lyxerr << "We have " << num_keys << " keys in the returned buffer" << endl;
// lyxerr << "Our dummy string is " << dummy << endl;
#endif
+
if (lyxerr.debugging(Debug::KEY)) {
char const * tmp = XKeysymToString(key);
char const * tmp2 = XKeysymToString(keysym);
string const stm = (tmp ? tmp : "");
string const stm2 = (tmp2 ? tmp2 : "");
- lyxerr[Debug::KEY] << "WorkArea: Key is `" << stm << "' ["
+ lyxerr[Debug::KEY] << "XWorkArea: Key is `" << stm << "' ["
<< key << "]" << endl;
- lyxerr[Debug::KEY] << "WorkArea: Keysym is `" << stm2 << "' ["
+ lyxerr[Debug::KEY] << "XWorkArea: Keysym is `" << stm2 << "' ["
<< keysym << "]" << endl;
}
last_key_pressed = xke->keycode;
last_state_pressed = ret_state;
- area->workAreaKeyPress(ret_key, x_key_state(ret_state));
+ XLyXKeySym * xlk = new XLyXKeySym;
+ xlk->initFromKeySym(ret_key);
+
+ area->workAreaKeyPress(LyXKeySymPtr(xlk),
+ x_key_state(ret_state));
}
break;
} // namespace anon
-int WorkArea::event_cb(XEvent * xev)
+int XWorkArea::event_cb(XEvent * xev)
{
int ret = 0;
switch (xev->type) {
}
-void WorkArea::haveSelection(bool yes) const
+void XWorkArea::haveSelection(bool yes) const
{
if (!yes) {
XSetSelectionOwner(fl_get_display(), XA_PRIMARY, None, CurrentTime);
}
-string const WorkArea::getClipboard() const
+string const XWorkArea::getClipboard() const
{
clipboard_read = false;
}
-void WorkArea::putClipboard(string const & s) const
+void XWorkArea::putClipboard(string const & s) const
{
static string hold;
hold = s;
#pragma interface
#endif
+#include "frontends/WorkArea.h"
#include "XPainter.h"
-#include "frontends/mouse_state.h"
-#include "frontends/key_state.h"
-
-#include <boost/signals/signal0.hpp>
-#include <boost/signals/signal1.hpp>
-#include <boost/signals/signal2.hpp>
-#include <boost/signals/signal3.hpp>
#include FORMS_H_LOCATION
-#include <utility>
///
-class WorkArea {
+class XWorkArea : public WorkArea {
public:
///
- WorkArea(int xpos, int ypos, int width, int height);
+ XWorkArea(int xpos, int ypos, int width, int height);
///
- ~WorkArea();
+ ~XWorkArea();
///
- Painter & getPainter() { return painter_; }
+ virtual Painter & getPainter() { return painter_; }
///
- int workWidth() const { return work_area->w; }
+ virtual int workWidth() const { return work_area->w; }
///
- int workHeight() const { return work_area->h; }
+ virtual int workHeight() const { return work_area->h; }
///
- unsigned int width() const { return work_area->w + scrollbar->w; }
- //unsigned int width() const { return backgroundbox->w + 15; }
+ virtual unsigned int width() const { return work_area->w + scrollbar->w; }
///
- int xpos() const { return work_area->x; }
- //int xpos() const { return backgroundbox->x; }
+ virtual int xpos() const { return work_area->x; }
///
- int ypos() const { return work_area->y; }
- //int ypos() const { return backgroundbox->y; }
+ virtual int ypos() const { return work_area->y; }
///
- void resize(int xpos, int ypos, int width, int height);
+ virtual void resize(int xpos, int ypos, int width, int height);
///
- void redraw() const {
+ virtual void redraw() const {
fl_redraw_object(work_area);
fl_redraw_object(scrollbar);
}
///
- void setFocus() const;
+ virtual void setFocus() const;
///
Window getWin() const { return work_area->form->window; }
///
- bool hasFocus() const { return work_area->focus; }
+ virtual bool hasFocus() const { return work_area->focus; }
///
- bool visible() const { return work_area->form->visible; }
+ virtual bool visible() const { return work_area->form->visible; }
///
- void greyOut() const;
+ virtual void greyOut() const;
///
- void setScrollbarParams(int height, int pos, int line_height);
+ virtual void setScrollbarParams(int height, int pos, int line_height);
///
Pixmap getPixmap() const { return workareapixmap; }
/// xforms callback
/// xforms callback from scrollbar
void scroll_cb();
/// a selection exists
- void haveSelection(bool) const;
- ///
- string const getClipboard() const;
- ///
- void putClipboard(string const &) const;
- // Signals
- ///
- boost::signal0<void> workAreaExpose;
- ///
- boost::signal1<void, int> scrollDocView;
- ///
- boost::signal2<void, KeySym, key_modifier::state> workAreaKeyPress;
- ///
- boost::signal3<void, int, int, mouse_button::state> workAreaButtonPress;
- ///
- boost::signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
- ///
- boost::signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
- ///
- boost::signal0<void> workAreaFocus;
- ///
- boost::signal0<void> workAreaUnfocus;
+ virtual void haveSelection(bool) const;
///
- boost::signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
+ virtual string const getClipboard() const;
///
- boost::signal3<void, int, int, mouse_button::state> workAreaTripleClick;
- /// emitted when an X client has requested our selection
- boost::signal0<void> selectionRequested;
- /// emitted when another X client has stolen our selection
- boost::signal0<void> selectionLost;
+ virtual void putClipboard(string const &) const;
/// handles SelectionRequest X Event, to fill the clipboard
int event_cb(XEvent * xev);
*.h
*.C
*.tmp
-*.lo
-.deps
-.libs
=============== FORM ===============
Name: form_maths_delim
Width: 250
-Height: 307
+Height: 221
Number of Objects: 11
--------------------
class: FL_BOX
type: UP_BOX
-box: 0 0 250 307
+box: 0 0 250 221
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
--------------------
class: FL_BUTTON
type: PUSH_BUTTON
-box: 42 112 170 140
+box: 28 108 192 64
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
-box: 168 268 70 30
+box: 168 182 70 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
-box: 90 268 70 30
+box: 90 182 70 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
-box: 12 268 70 30
+box: 14 182 70 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
-name:
+name:
callback:
argument:
--- /dev/null
+#include <config.h>
+
+#include "guiapi.h"
+
+#include "FormAboutlyx.h"
+#include "forms/form_aboutlyx.h"
+
+#include "FormBibitem.h"
+#include "forms/form_bibitem.h"
+
+#include "FormBibtex.h"
+#include "forms/form_bibtex.h"
+
+#include "FormBrowser.h"
+#include "forms/form_browser.h"
+
+#include "FormCharacter.h"
+#include "forms/form_character.h"
+
+#include "FormCitation.h"
+#include "forms/form_citation.h"
+
+#include "FormDocument.h"
+#include "forms/form_document.h"
+
+#include "FormError.h"
+#include "forms/form_error.h"
+
+#include "FormERT.h"
+#include "forms/form_ert.h"
+
+#include "FormExternal.h"
+#include "forms/form_external.h"
+
+#include "FormFloat.h"
+#include "forms/form_float.h"
+
+#include "FormForks.h"
+#include "forms/form_forks.h"
+
+#include "FormGraphics.h"
+#include "forms/form_graphics.h"
+
+#include "FormInclude.h"
+#include "forms/form_include.h"
+
+#include "FormIndex.h"
+#include "forms/form_index.h"
+
+#include "FormLog.h"
+
+#include "FormMathsPanel.h"
+#include "FormMathsBitmap.h"
+#include "FormMathsDeco.h"
+#include "FormMathsDelim.h"
+#include "FormMathsMatrix.h"
+#include "FormMathsSpace.h"
+#include "FormMathsStyle.h"
+
+#include "forms/form_maths_deco.h"
+#include "forms/form_maths_delim.h"
+#include "forms/form_maths_matrix.h"
+#include "forms/form_maths_panel.h"
+#include "forms/form_maths_space.h"
+#include "forms/form_maths_style.h"
+
+#include "FormMinipage.h"
+#include "forms/form_minipage.h"
+
+#include "FormParagraph.h"
+#include "forms/form_paragraph.h"
+
+#include "FormPreamble.h"
+#include "forms/form_preamble.h"
+
+#include "FormPreferences.h"
+#include "forms/form_preferences.h"
+
+#include "FormPrint.h"
+#include "forms/form_print.h"
+
+#include "FormRef.h"
+#include "forms/form_ref.h"
+
+#include "FormSearch.h"
+#include "forms/form_search.h"
+
+#include "FormSendto.h"
+#include "forms/form_sendto.h"
+
+#include "FormShowFile.h"
+
+#include "FormSpellchecker.h"
+#include "forms/form_spellchecker.h"
+
+#include "FormTabular.h"
+#include "forms/form_tabular.h"
+
+#include "FormTabularCreate.h"
+#include "forms/form_tabular_create.h"
+
+#include "FormTexinfo.h"
+#include "forms/form_texinfo.h"
+
+#include "FormToc.h"
+#include "forms/form_toc.h"
+
+#include "FormUrl.h"
+#include "forms/form_url.h"
+
+#include "FormVCLog.h"
+
+#include "xformsBC.h"
+#include "combox.h"
+
+#include "controllers/GUI.h"
+#include "insets/inseterror.h"
+
+#include "LyXView.h"
+
+#include "ControlAboutlyx.h"
+#include "ControlBibitem.h"
+#include "ControlBibtex.h"
+#include "ControlCharacter.h"
+#include "ControlCitation.h"
+#include "ControlError.h"
+#include "ControlERT.h"
+#include "ControlExternal.h"
+#include "ControlFloat.h"
+#include "ControlForks.h"
+#include "ControlGraphics.h"
+#include "insets/insetgraphicsParams.h"
+#include "ControlInclude.h"
+#include "ControlIndex.h"
+#include "ControlLog.h"
+#include "ControlMinipage.h"
+#include "ControlParagraph.h"
+#include "ControlPreamble.h"
+#include "ControlPrint.h"
+#include "ControlRef.h"
+#include "ControlSearch.h"
+#include "ControlSendto.h"
+#include "ControlShowFile.h"
+#include "ControlSpellchecker.h"
+#include "ControlTabularCreate.h"
+#include "ControlTexinfo.h"
+#include "ControlThesaurus.h"
+#include "ControlToc.h"
+#include "ControlUrl.h"
+#include "ControlVCLog.h"
+
+
+namespace { // anon
+
+// I belive that this one is buggy (Lgb)
+// But not if used correctly. (Lgb)
+template <class T>
+class GUISingleton {
+public:
+ static
+ T & get(LyXView & lv, Dialogs & d) {
+ static T t(lv, d);
+ return t;
+ }
+};
+
+
+GUISingleton<GUI<ControlCharacter, FormCharacter,
+ OkApplyCancelReadOnlyPolicy, xformsBC> >
+controlCharacterSingleton;
+
+GUISingleton<GUI<ControlCitation, FormCitation,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlCitationSingleton;
+
+
+GUISingleton<GUI<ControlERT, FormERT,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlERTSingleton;
+
+GUISingleton<GUI<ControlIndex, FormIndex,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlIndexSingleton;
+
+GUISingleton<GUI<ControlMinipage, FormMinipage,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlMinipageSingleton;
+
+GUISingleton<FormPreferences> formPreferencesSingleton;
+
+GUISingleton<GUI<ControlRef, FormRef,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlRefSingleton;
+
+GUISingleton<FormTabular> formTabularSingleton;
+
+GUISingleton<GUI<ControlToc, FormToc,
+ OkCancelPolicy, xformsBC> >
+controlTocSingleton;
+
+GUISingleton<GUI<ControlUrl, FormUrl,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlUrlSingleton;
+
+} // anon
+
+
+extern "C" {
+
+ void gui_ShowAboutlyx(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlAboutlyx, FormAboutlyx,
+ OkCancelPolicy, xformsBC> cal(lv, d);
+ cal.show();
+ }
+
+
+ void gui_ShowBibitem(InsetCommand * ic, LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlBibitem, FormBibitem,
+ OkCancelReadOnlyPolicy, xformsBC> cbi(lv, d);
+ cbi.showInset(ic);
+ }
+
+
+ void gui_ShowBibtex(InsetCommand * ic, LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlBibtex, FormBibtex,
+ OkCancelReadOnlyPolicy, xformsBC> cbt(lv, d);
+ cbt.showInset(ic);
+ }
+
+
+ void gui_ShowCharacter(LyXView & lv, Dialogs & d)
+ {
+ controlCharacterSingleton.get(lv, d).show();
+ }
+
+
+ void gui_SetUserFreeFont(LyXView & lv, Dialogs & d)
+ {
+ controlCharacterSingleton.get(lv, d).apply();
+ }
+
+
+ void gui_ShowCitation(InsetCommand * ic, LyXView & lv, Dialogs & d)
+ {
+ controlCitationSingleton.get(lv, d).showInset(ic);
+ }
+
+
+ void gui_CreateCitation(string const & s, LyXView & lv, Dialogs & d)
+ {
+ controlCitationSingleton.get(lv, d).createInset(s);
+ }
+
+
+ void gui_ShowDocument(LyXView & lv, Dialogs & d)
+ {
+ static FormDocument fd(&lv, &d);
+ fd.show();
+ }
+
+
+ void gui_ShowError(InsetError * ie, LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlError, FormError,
+ OkCancelPolicy, xformsBC> ce(lv, d);
+ ce.showInset(ie);
+ }
+
+
+ void gui_ShowERT(InsetERT * ie, LyXView & lv, Dialogs & d)
+ {
+ controlERTSingleton.get(lv, d).showInset(ie);
+ }
+
+
+ void gui_UpdateERT(InsetERT * ie, LyXView & lv, Dialogs & d)
+ {
+ controlERTSingleton.get(lv, d).showInset(ie);
+ }
+
+
+ void gui_ShowExternal(InsetExternal * ie, LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlExternal, FormExternal,
+ OkApplyCancelReadOnlyPolicy, xformsBC> ce(lv, d);
+ ce.showInset(ie);
+ }
+
+
+ void gui_ShowFile(string const & f, LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlShowFile, FormShowFile,
+ OkCancelPolicy, xformsBC> csf(lv, d);
+ csf.showFile(f);
+ }
+
+
+ void gui_ShowFloat(InsetFloat * ifl, LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlFloat, FormFloat,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> cf(lv, d);
+ cf.showInset(ifl);
+ }
+
+
+ void gui_ShowForks(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlForks, FormForks,
+ OkApplyCancelPolicy, xformsBC> cf(lv, d);
+ cf.show();
+ }
+
+
+ void gui_ShowGraphics(InsetGraphics * ig, LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlGraphics, FormGraphics,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> cg(lv, d);
+ cg.showInset(ig);
+ }
+
+
+ void gui_ShowInclude(InsetInclude * ii, LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlInclude, FormInclude,
+ OkCancelReadOnlyPolicy, xformsBC> ci(lv, d);
+ ci.showInset(ii);
+ }
+
+
+ void gui_ShowIndex(InsetCommand * ic, LyXView & lv, Dialogs & d)
+ {
+ controlIndexSingleton.get(lv, d).showInset(ic);
+ }
+
+
+ void gui_CreateIndex(string const & s, LyXView & lv, Dialogs & d)
+ {
+ controlIndexSingleton.get(lv, d).createInset(s);
+ }
+
+
+#if 0
+ void gui_ShowInfo(InsetInfo *, LyXView & lv, Dialogs & d)
+ {
+ }
+#endif
+
+
+ void gui_ShowLogFile(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlLog, FormLog,
+ OkCancelPolicy, xformsBC> cl(lv, d);
+ cl.show();
+ }
+
+
+ void gui_ShowMathPanel(LyXView & lv, Dialogs & d)
+ {
+ static FormMathsPanel fmp(&lv, &d);
+ fmp.show();
+ }
+
+
+ void gui_ShowMinipage(InsetMinipage * im, LyXView & lv, Dialogs & d)
+ {
+ controlMinipageSingleton.get(lv, d).showInset(im);
+ }
+
+
+ void gui_UpdateMinipage(InsetMinipage * im, LyXView & lv, Dialogs & d)
+ {
+ controlMinipageSingleton.get(lv, d).showInset(im);
+ }
+
+
+ void gui_ShowParagraph(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlParagraph, FormParagraph,
+ OkApplyCancelReadOnlyPolicy, xformsBC> cp(lv, d);
+ cp.show();
+ }
+
+
+#if 0
+ void gui_UpdateParagraph(LyXView & lv, Dialogs & d)
+ {
+#warning FIXME!
+ // This should be the same object as in gui_ShowParagraph
+ static GUI<ControlParagraph, FormParagraph,
+ OkApplyCancelReadOnlyPolicy, xformsBC> cp(lv, d);
+#if 0
+ cp.
+#endif
+ }
+#endif
+
+
+ void gui_ShowPreamble(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlPreamble, FormPreamble,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> cp(lv, d);
+ cp.show();
+ }
+
+
+ void gui_ShowPreferences(LyXView & lv, Dialogs & d)
+ {
+ formPreferencesSingleton.get(lv, d).show();
+ }
+
+
+ void gui_ShowPrint(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlPrint, FormPrint,
+ OkApplyCancelPolicy, xformsBC> cp(lv, d);
+ cp.show();
+ }
+
+
+ void gui_ShowRef(InsetCommand * ic, LyXView & lv, Dialogs & d)
+ {
+ controlRefSingleton.get(lv, d).showInset(ic);
+ }
+
+
+ void gui_CreateRef(string const & s, LyXView & lv, Dialogs & d)
+ {
+ controlRefSingleton.get(lv, d).createInset(s);
+ }
+
+
+ void gui_ShowSearch(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlSearch, FormSearch,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> cs(lv, d);
+ cs.show();
+ }
+
+
+ void gui_ShowSendto(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlSendto, FormSendto,
+ OkApplyCancelPolicy, xformsBC> cs(lv, d);
+ cs.show();
+ }
+
+
+ void gui_ShowSpellchecker(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlSpellchecker, FormSpellchecker,
+ NoRepeatedApplyReadOnlyPolicy, xformsBC> cp(lv, d);
+ cp.show();
+ }
+
+
+ void gui_ShowSpellcheckerPreferences(LyXView & lv, Dialogs & d)
+ {
+ formPreferencesSingleton.get(lv, d).showSpellPref();
+ }
+
+
+ void gui_ShowTabular(InsetTabular * it, LyXView & lv, Dialogs & d)
+ {
+ formTabularSingleton.get(lv, d).showInset(it);
+ }
+
+
+ void gui_UpdateTabular(InsetTabular * it, LyXView & lv, Dialogs & d)
+ {
+ formTabularSingleton.get(lv, d).updateInset(it);
+ }
+
+
+ void gui_ShowTabularCreate(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlTabularCreate, FormTabularCreate,
+ OkApplyCancelReadOnlyPolicy, xformsBC> ctc(lv, d);
+ ctc.show();
+ }
+
+
+ void gui_ShowTexinfo(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlTexinfo, FormTexinfo,
+ OkCancelPolicy, xformsBC> ct(lv, d);
+ ct.show();
+ }
+
+
+ void gui_ShowThesaurus(string const & /*s*/, LyXView & , Dialogs &)
+ {
+#ifdef HAVE_LIBAIKSAURUS
+ static GUI<ControlThesaurus, FormThesaurus,
+ OkApplyCancelReadOnlyPolicy, xformsBC> ct(lv, d);
+ ct.showEntry(s);
+#endif
+ }
+
+
+ void gui_ShowTOC(InsetCommand * ic, LyXView & lv, Dialogs & d)
+ {
+ controlTocSingleton.get(lv, d).showInset(ic);
+ }
+
+
+ void gui_CreateTOC(string const & s, LyXView & lv, Dialogs & d)
+ {
+ controlTocSingleton.get(lv, d).createInset(s);
+ }
+
+
+ void gui_ShowUrl(InsetCommand * ic, LyXView & lv, Dialogs & d)
+ {
+ controlUrlSingleton.get(lv, d).showInset(ic);
+ }
+
+
+ void gui_CreateUrl(string const & s, LyXView & lv, Dialogs & d)
+ {
+ controlUrlSingleton.get(lv, d).createInset(s);
+ }
+
+
+ void gui_ShowVCLogFile(LyXView & lv, Dialogs & d)
+ {
+ static GUI<ControlVCLog, FormVCLog,
+ OkCancelPolicy, xformsBC> cv(lv, d);
+ cv.show();
+ }
+
+} // extern "C"
--- /dev/null
+/**
+ * \file xscreen.C
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author unknown
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <algorithm>
+#include <X11/Xlib.h>
+
+#include "frontends/screen.h"
+#include "frontends/font_metrics.h"
+#include "XWorkArea.h"
+#include "xscreen.h"
+#include "lyxtext.h"
+#include "lyxrow.h"
+#include "Painter.h"
+#include "WorkArea.h"
+#include "buffer.h"
+#include "BufferView.h"
+#include "insets/insettext.h"
+#include "ColorHandler.h"
+#include "language.h"
+
+using std::max;
+using std::min;
+
+namespace {
+
+GC createGC()
+{
+ XGCValues val;
+ val.foreground = BlackPixel(fl_get_display(),
+ DefaultScreen(fl_get_display()));
+
+ val.function = GXcopy;
+ val.graphics_exposures = false;
+ val.line_style = LineSolid;
+ val.line_width = 0;
+ return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
+ GCForeground | GCFunction | GCGraphicsExposures
+ | GCLineWidth | GCLineStyle , &val);
+}
+
+} // namespace anon
+
+
+// Constructor
+XScreen::XScreen(XWorkArea & o)
+ : LyXScreen(), owner_(o)
+{
+ // the cursor isnt yet visible
+ cursor_pixmap = 0;
+ cursor_pixmap_x = 0;
+ cursor_pixmap_y = 0;
+ cursor_pixmap_w = 0;
+ cursor_pixmap_h = 0;
+
+ // We need this GC
+ gc_copy = createGC();
+}
+
+
+XScreen::~XScreen()
+{
+ XFreeGC(fl_get_display(), gc_copy);
+}
+
+
+void XScreen::setCursorColor()
+{
+ if (!lyxColorHandler.get()) return;
+
+ GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
+
+ XGCValues val;
+ XGetGCValues(fl_get_display(),
+ gc, GCForeground, &val);
+ XChangeGC(fl_get_display(), gc_copy, GCForeground, &val);
+}
+
+
+void XScreen::showManualCursor(LyXText const * text, int x, int y,
+ int asc, int desc, Cursor_Shape shape)
+{
+ // Update the cursor color.
+ setCursorColor();
+
+ int const y1 = max(y - text->first_y - asc, 0);
+ int const y_tmp = min(y - text->first_y + desc,
+ static_cast<int>(owner_.workHeight()));
+
+ // Secure against very strange situations
+ int const y2 = max(y_tmp, y1);
+
+ if (cursor_pixmap) {
+ XFreePixmap(fl_get_display(), cursor_pixmap);
+ cursor_pixmap = 0;
+ }
+
+ if (y2 > 0 && y1 < int(owner_.workHeight())) {
+ cursor_pixmap_h = y2 - y1 + 1;
+ cursor_pixmap_y = y1;
+
+ switch (shape) {
+ case BAR_SHAPE:
+ cursor_pixmap_w = 1;
+ cursor_pixmap_x = x;
+ break;
+ case L_SHAPE:
+ cursor_pixmap_w = cursor_pixmap_h/3;
+ cursor_pixmap_x = x;
+ break;
+ case REVERSED_L_SHAPE:
+ cursor_pixmap_w = cursor_pixmap_h/3;
+ cursor_pixmap_x = x - cursor_pixmap_w + 1;
+ break;
+ }
+
+ cursor_pixmap =
+ XCreatePixmap (fl_get_display(),
+ fl_root,
+ cursor_pixmap_w,
+ cursor_pixmap_h,
+ fl_get_visual_depth());
+ XCopyArea (fl_get_display(),
+ owner_.getWin(),
+ cursor_pixmap,
+ gc_copy,
+ owner_.xpos() + cursor_pixmap_x,
+ owner_.ypos() + cursor_pixmap_y,
+ cursor_pixmap_w,
+ cursor_pixmap_h,
+ 0, 0);
+ XDrawLine(fl_get_display(),
+ owner_.getWin(),
+ gc_copy,
+ x + owner_.xpos(),
+ y1 + owner_.ypos(),
+ x + owner_.xpos(),
+ y2 + owner_.ypos());
+ switch (shape) {
+ case BAR_SHAPE:
+ break;
+ case L_SHAPE:
+ case REVERSED_L_SHAPE:
+ int const rectangle_h = (cursor_pixmap_h + 10) / 20;
+ XFillRectangle(fl_get_display(),
+ owner_.getWin(),
+ gc_copy,
+ cursor_pixmap_x + owner_.xpos(),
+ y2 - rectangle_h + 1 + owner_.ypos(),
+ cursor_pixmap_w - 1, rectangle_h);
+ break;
+ }
+
+ }
+ cursor_visible_ = true;
+}
+
+
+void XScreen::hideCursor()
+{
+ if (!cursor_visible_) return;
+
+ if (cursor_pixmap) {
+ XCopyArea (fl_get_display(),
+ cursor_pixmap,
+ owner_.getWin(),
+ gc_copy,
+ 0, 0,
+ cursor_pixmap_w, cursor_pixmap_h,
+ cursor_pixmap_x + owner_.xpos(),
+ cursor_pixmap_y + owner_.ypos());
+ }
+ cursor_visible_ = false;
+}
+
+
+void XScreen::expose(int x, int y, int exp_width, int exp_height)
+{
+ // FIXME: here we should definitely NOT do this.
+ // we need to generate an expose event for the workarea
+ // and then copy from the pixmap to the screen. This
+ // is the Sane Way (tm)
+ XCopyArea(fl_get_display(),
+ owner_.getPixmap(),
+ owner_.getWin(),
+ gc_copy,
+ x, y,
+ exp_width, exp_height,
+ x + owner_.xpos(),
+ y + owner_.ypos());
+}
+
+
+void XScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
+{
+ if (cursor_visible_) hideCursor();
+
+ int const old_first = text->first_y;
+ bool internal = (text == bv->text);
+ text->first_y = y;
+
+ // is any optimization possible?
+ if ((y - old_first) < owner_.workHeight()
+ && (old_first - y) < owner_.workHeight())
+ {
+ if (text->first_y < old_first) {
+ drawFromTo(text, bv, 0,
+ old_first - text->first_y, 0, 0, internal);
+ XCopyArea (fl_get_display(),
+ owner_.getWin(),
+ owner_.getWin(),
+ gc_copy,
+ owner_.xpos(),
+ owner_.ypos(),
+ owner_.workWidth(),
+ owner_.workHeight() - old_first + text->first_y,
+ owner_.xpos(),
+ owner_.ypos() + old_first - text->first_y
+ );
+ // expose the area drawn
+ expose(0, 0,
+ owner_.workWidth(),
+ old_first - text->first_y);
+ } else {
+ drawFromTo(text, bv,
+ owner_.workHeight() + old_first - text->first_y,
+ owner_.workHeight(), 0, 0, internal);
+ XCopyArea (fl_get_display(),
+ owner_.getWin(),
+ owner_.getWin(),
+ gc_copy,
+ owner_.xpos(),
+ owner_.ypos() + text->first_y - old_first,
+ owner_.workWidth(),
+ owner_.workHeight() + old_first - text->first_y,
+ owner_.xpos(),
+ owner_.ypos());
+ // expose the area drawn
+ expose(0, owner_.workHeight() + old_first - text->first_y,
+ owner_.workWidth(), text->first_y - old_first);
+ }
+ } else {
+ // make a dumb new-draw
+ drawFromTo(text, bv, 0, owner_.workHeight(), 0, 0, internal);
+ expose(0, 0, owner_.workWidth(), owner_.workHeight());
+ }
+
+ XSync(fl_get_display(), 0);
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file xscreen.h
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author unknown
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#ifndef XSCREEN_H
+#define XSCREEN_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <X11/Xlib.h>
+
+#include "screen.h"
+
+#include "XWorkArea.h"
+
+/** The class XScreen is used for the main Textbody.
+ Concretely, the screen is held in a pixmap. This pixmap is kept up to
+ date and used to optimize drawing on the screen.
+ This class also handles the drawing of the cursor and partly the selection.
+ */
+class XScreen : public LyXScreen {
+public:
+ ///
+ XScreen(XWorkArea &);
+
+ ///
+ virtual ~XScreen();
+
+ /// Sets the cursor color to LColor::cursor.
+ virtual void setCursorColor();
+ ///
+ virtual void hideCursor();
+ ///
+ virtual void showManualCursor(LyXText const *, int x, int y,
+ int asc, int desc,
+ Cursor_Shape shape);
+
+ /** Draws the screen form textposition y. Uses as much of
+ the already printed pixmap as possible */
+ virtual void draw(LyXText *, BufferView *, unsigned int y);
+
+protected:
+ /// get the work area
+ virtual WorkArea & workarea() const { return owner_; }
+
+ /// Copies specified area of pixmap to screen
+ virtual void expose(int x, int y, int exp_width, int exp_height);
+
+private:
+ /// our owning widget
+ XWorkArea & owner_;
+
+ ///
+ Pixmap cursor_pixmap;
+ ///
+ int cursor_pixmap_x;
+ ///
+ int cursor_pixmap_y;
+ ///
+ int cursor_pixmap_w;
+ ///
+ int cursor_pixmap_h;
+ ///
+ GC gc_copy;
+};
+
+#endif
+2002-06-15 LyX Development team <lyx@rilke>
+
+ * inset*.[Ch] (docbook): Added new argument to take the pernicious
+ mixed content. Small white spaces clean.
+
2002-06-14 Angus Leeming <leeming@lyx.org>
* inseetexternal.C: remove the using std::difftime declaration.
///
virtual int linuxdoc(Buffer const *, std::ostream &) const = 0;
///
- virtual int docbook(Buffer const *, std::ostream &) const = 0;
+ virtual int docbook(Buffer const *, std::ostream &, bool) const = 0;
/// Updates needed features for this inset.
virtual void validate(LaTeXFeatures & features) const;
///
}
-int InsetCaption::docbook(Buffer const * buf, ostream & os) const
+int InsetCaption::docbook(Buffer const * buf, ostream & os, bool mixcont) const
{
int ret;
os << "<title>";
- ret = InsetText::docbook(buf, os);
+ ret = InsetText::docbook(buf, os, mixcont);
os << "</title>\n";
return ret;
}
int ascii(Buffer const * buf, std::ostream & os, int linelen) const;
///
virtual
- int docbook(Buffer const * buf, std::ostream & os) const;
+ int docbook(Buffer const * buf, std::ostream & os, bool mixcont) const;
protected:
private:
};
}
-int InsetCollapsable::docbook(Buffer const * buf, ostream & os) const
+int InsetCollapsable::docbook(Buffer const * buf, ostream & os, bool mixcont) const
{
- return inset.docbook(buf, os);
+ return inset.docbook(buf, os, mixcont);
}
#if 0
bool found = inset.searchForward(bv, str, cs, mw);
if (first_after_edit && !found)
close(bv);
- first_after_edit = false;
+ else if (!found)
+ first_after_edit = false;
return found;
}
bool found = inset.searchBackward(bv, str, cs, mw);
if (first_after_edit && !found)
close(bv);
- first_after_edit = false;
+ else if (!found)
+ first_after_edit = false;
return found;
}
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
void validate(LaTeXFeatures & features) const;
///
}
-int InsetCommand::docbook(Buffer const *, ostream &) const
+int InsetCommand::docbook(Buffer const *, ostream &, bool) const
{
return 0;
}
///
virtual int linuxdoc(Buffer const *, std::ostream &) const;
///
- virtual int docbook(Buffer const *, std::ostream &) const;
+ virtual int docbook(Buffer const *, std::ostream &, bool) const;
///
Inset::Code lyxCode() const { return Inset::NO_CODE; }
///
int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
///
- int docbook(Buffer const *, std::ostream &) const { return 0; }
+ int docbook(Buffer const *, std::ostream &, bool) const { return 0; }
///
bool autoDelete() const { return true; }
/// what appears in the minibuffer when opening
}
-int InsetERT::docbook(Buffer const *, ostream & os) const
+int InsetERT::docbook(Buffer const *, ostream & os, bool) const
{
Paragraph * par = inset.paragraph();
int lines = 0;
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
void validate(LaTeXFeatures &) const {}
///
}
-int InsetExternal::docbook(Buffer const * buf, ostream & os) const
+int InsetExternal::docbook(Buffer const * buf, ostream & os, bool) const
{
return write("DocBook", buf, os);
}
/// write LinuxDoc output to the ostream
virtual int linuxdoc(Buffer const *, std::ostream &) const;
/// write DocBook output to the ostream
- virtual int docbook(Buffer const *, std::ostream &) const;
+ virtual int docbook(Buffer const *, std::ostream &, bool mixcont) const;
/// Updates needed features for this inset.
virtual void validate(LaTeXFeatures & features) const;
}
-int InsetFloat::docbook(Buffer const * buf, ostream & os) const
+int InsetFloat::docbook(Buffer const * buf, ostream & os, bool mixcont) const
{
os << "<" << floatType_ << ">";
- int const i = inset.docbook(buf, os);
+ int const i = inset.docbook(buf, os, mixcont);
os << "</" << floatType_ << ">";
return i;
///
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
string const editMessage() const;
///
///
int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
///
- int docbook(Buffer const *, std::ostream &) const { return 0; }
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const { return 0; }
///
int ascii(Buffer const *, std::ostream &, int linelen) const;
///
}
-int InsetFoot::docbook(Buffer const * buf, ostream & os) const
+int InsetFoot::docbook(Buffer const * buf, ostream & os, bool mixcont) const
{
os << "<footnote>";
- int const i = inset.docbook(buf, os);
+ int const i = inset.docbook(buf, os, mixcont);
os << "</footnote>";
return i;
///
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
string const editMessage() const;
};
// For explanation on inserting graphics into DocBook checkout:
// http://linuxdoc.org/LDP/LDP-Author-Guide/inserting-pictures.html
// See also the docbook guide at http://www.docbook.org/
-int InsetGraphics::docbook(Buffer const *, ostream & os) const
+int InsetGraphics::docbook(Buffer const *, ostream & os, bool mixcont) const
{
// In DocBook v5.0, the graphic tag will be eliminated from DocBook, will
// need to switch to MediaObject. However, for now this is sufficient and
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
/** Tell LyX what the latex features you need i.e. what latex packages
you need to be included.
}
-int InsetInclude::docbook(Buffer const * buffer, ostream & os) const
+int InsetInclude::docbook(Buffer const * buffer, ostream & os, bool mixcont) const
{
string incfile(params_.cparams.getContents());
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
void validate(LaTeXFeatures &) const;
}
-int InsetIndex::docbook(Buffer const *, ostream & os) const
+int InsetIndex::docbook(Buffer const *, ostream & os, bool) const
{
os << "<indexterm><primary>" << getContents()
<< "</primary></indexterm>";
///
Inset::Code lyxCode() const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
};
}
-int InsetLabel::docbook(Buffer const *, ostream & os) const
+int InsetLabel::docbook(Buffer const *, ostream & os, bool) const
{
os << "<anchor id=\"" << getContents() << "\">";
return 0;
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
};
#endif
}
-int InsetLatexAccent::docbook(Buffer const *, ostream & os) const
+int InsetLatexAccent::docbook(Buffer const *, ostream & os, bool) const
{
os << contents;
return 0;
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
bool deletable() const;
///
int linuxdoc(Buffer const *, std::ostream &) const
{ return 0; }
///
- int docbook(Buffer const *, std::ostream &) const
+ int docbook(Buffer const *, std::ostream &, bool) const
{ return 0; }
///
int ascii(Buffer const *, std::ostream &, int) const
}
-int InsetQuotes::docbook(Buffer const *, ostream & os) const
+int InsetQuotes::docbook(Buffer const *, ostream & os, bool) const
{
if (times_ == DoubleQ) {
if (side_ == LeftQ)
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
void validate(LaTeXFeatures &) const;
///
}
-int InsetRef::docbook(Buffer const *, ostream & os) const
+int InsetRef::docbook(Buffer const *, ostream & os, bool) const
{
if (getOptions().empty()) {
os << "<xref linkend=\"" << getContents() << "\">";
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
void validate(LaTeXFeatures & features) const;
private:
}
-int InsetSpecialChar::docbook(Buffer const *, ostream & os) const
+int InsetSpecialChar::docbook(Buffer const *, ostream & os, bool) const
{
switch (kind_) {
case HYPHENATION:
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
virtual Inset * clone(Buffer const &, bool same_id = false) const;
///
clearSelection();
need_update = INIT;
in_update = false;
- in_reset_pos = false;
+ in_reset_pos = 0;
inset_x = 0;
inset_y = 0;
}
clearSelection();
need_update = INIT;
in_update = false;
- in_reset_pos = false;
+ in_reset_pos = 0;
inset_x = 0;
inset_y = 0;
}
the_locking_inset = 0;
}
hideInsetCursor(bv);
+ actcell = 0;
oldcell = -1;
locked = false;
if (scroll(false) || hasSelection()) {
what = FULL;
if (need_update < what) // only set this if it has greater update
need_update = what;
-#if 0 // maybe this should not be done!
- if ((what == INIT) && hasSelection()) {
- clearSelection();
- }
-#endif
// Dirty Cast! (Lgb)
if (need_update != NONE) {
bv->updateInset(const_cast<InsetTabular *>(this), mark_dirty);
- if (locked) // && (what != NONE))
+ if (locked)
resetPos(bv);
}
}
}
-int InsetTabular::docbook(Buffer const * buf, ostream & os) const
+int InsetTabular::docbook(Buffer const * buf, ostream & os, bool mixcont) const
{
int ret = 0;
Inset * master;
master = master->owner());
if (!master) {
- os << "<informaltable>\n";
+ os << "<informaltable>";
+ if (mixcont)
+ os << endl;
ret++;
}
- ret+= tabular->docBook(buf,os);
+ ret+= tabular->docbook(buf, os, mixcont);
if (!master) {
- os << "</informaltable>\n";
+ os << "</informaltable>";
+ if (mixcont)
+ os << endl;
ret++;
}
return ret;
#warning This should be fixed in the right manner (20011128 Jug)
#endif
// fast hack to fix infinite repaintings!
- if (in_reset_pos)
+ if (in_reset_pos > 10)
return;
int cell = 0;
return;
}
// we need this only from here on!!!
- in_reset_pos = true;
+ ++in_reset_pos;
static int const offset = ADD_TO_TABULAR_WIDTH + 2;
int new_x = getCellXPos(actcell);
int old_x = cursor_.x();
bv->owner()->getDialogs()->updateTabular(inset);
oldcell = actcell;
}
- in_reset_pos = false;
+ in_reset_pos = 0;
}
bool InsetTabular::searchForward(BufferView * bv, string const & str,
bool cs, bool mw)
{
- nodraw(true);
if (the_locking_inset) {
if (the_locking_inset->searchForward(bv, str, cs, mw)) {
- nodraw(false);
updateLocal(bv, CELL, false);
return true;
}
- if (tabular->IsLastCell(actcell)) {
- nodraw(false);
- bv->unlockInset(const_cast<InsetTabular *>(this));
- return false;
+ }
+ do {
+ InsetText * inset = tabular->GetCellInset(actcell);
+ if (inset->searchForward(bv, str, cs, mw)) {
+ updateLocal(bv, FULL, false);
+ return true;
}
++actcell;
- }
- // otherwise we have to lock the next inset and search there
- UpdatableInset * inset =
- static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
- inset->edit(bv);
- bool const ret = searchForward(bv, str, cs, mw);
- nodraw(false);
- updateLocal(bv, CELL, false);
- return ret;
+ } while (!tabular->IsLastCell(actcell));
+ return false;
}
bool InsetTabular::searchBackward(BufferView * bv, string const & str,
bool cs, bool mw)
{
- nodraw(true);
if (the_locking_inset) {
if (the_locking_inset->searchBackward(bv, str, cs, mw)) {
- nodraw(false);
updateLocal(bv, CELL, false);
return true;
}
- if (!actcell) { // we are already in the first cell
- nodraw(false);
- bv->unlockInset(const_cast<InsetTabular *>(this));
- return false;
- }
+ }
+ if (!locked)
+ actcell = tabular->GetNumberOfCells();
+
+ while (actcell) {
--actcell;
+ InsetText * inset = tabular->GetCellInset(actcell);
+ if (inset->searchBackward(bv, str, cs, mw)) {
+ updateLocal(bv, CELL, false);
+ return true;
+ }
}
- // otherwise we have to lock the next inset and search there
- UpdatableInset * inset =
- static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
- inset->edit(bv, false);
- bool const ret = searchBackward(bv, str, cs, mw);
- nodraw(false);
- updateLocal(bv, CELL, false);
- return ret;
+ return false;
}
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
void validate(LaTeXFeatures & features) const;
///
///
bool in_update;
///
- mutable bool in_reset_pos;
+ mutable int in_reset_pos;
};
#endif
}
break;
case FINISHED_DOWN:
- if ((result = moveDown(bv)) >= FINISHED) {
+ {
+ LyXText *lt = getLyXText(bv);
+ if (lt->cursor.irow()->next()) {
+ lt->setCursorFromCoordinates(
+ bv, lt->cursor.ix() + inset_x,
+ lt->cursor.iy() -
+ lt->cursor.irow()->baseline() +
+ lt->cursor.irow()->height() + 1);
+ lt->cursor.x_fix(lt->cursor.x());
updateLocal(bv, CURSOR, false);
+ } else {
bv->unlockInset(this);
}
+ }
break;
default:
result = DISPATCHED;
break;
}
the_locking_inset = 0;
-#ifdef WITH_WARNINGS
-#warning I changed this to always return Dispatched maybe it is wrong (20011001 Jug)
-#endif
updateLocal(bv, CURSOR, false);
return result;
}
}
lt->clearSelection();
for (string::size_type i = 0; i < arg.length(); ++i) {
- bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], lt);
+ bv->owner()->getIntl()->getTransManager().
+ TranslateAndInsert(arg[i], lt);
}
}
lt->selection.cursor = lt->cursor;
}
-int InsetText::docbook(Buffer const * buf, ostream & os) const
+int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
{
Paragraph * p = par;
unsigned int lines = 0;
for (; depth > p->params().depth(); --depth) {
if (environment_inner[depth] != "!-- --") {
item_name = "listitem";
- buf->sgmlCloseTag(os, command_depth + depth,
- item_name);
+ lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry")
- buf->sgmlCloseTag(os, depth+command_depth,
- environment_inner[depth]);
+ lines += buf->sgmlCloseTag(os, depth+command_depth, mixcont, environment_inner[depth]);
}
- buf->sgmlCloseTag(os, depth + command_depth,
- environment_stack[depth]);
+ lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]);
environment_stack[depth].erase();
environment_inner[depth].erase();
}
&& !environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") {
item_name= "listitem";
- buf->sgmlCloseTag(os, command_depth+depth,
- item_name);
+ lines += buf->sgmlCloseTag(os, command_depth+depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry")
- buf->sgmlCloseTag(os,
- depth + command_depth,
- environment_inner[depth]);
+ lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]);
}
- buf->sgmlCloseTag(os, depth + command_depth,
- environment_stack[depth]);
+ lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]);
environment_stack[depth].erase();
environment_inner[depth].erase();
// Write opening SGML tags.
switch (style.latextype) {
case LATEX_PARAGRAPH:
- buf->sgmlOpenTag(os, depth + command_depth,
- style.latexname());
+ lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style.latexname());
break;
case LATEX_COMMAND:
- buf->sgmlError(p, 0,
- _("Error : LatexType Command not allowed here.\n"));
+ buf->sgmlError(p, 0, _("Error : LatexType Command not allowed here.\n"));
return -1;
break;
}
environment_stack[depth] = style.latexname();
environment_inner[depth] = "!-- --";
- buf->sgmlOpenTag(os, depth + command_depth,
- environment_stack[depth]);
+ lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, environment_stack[depth]);
} else {
if (environment_inner[depth] != "!-- --") {
item_name= "listitem";
- buf->sgmlCloseTag(os,
- command_depth + depth,
- item_name);
+ lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry")
- buf->sgmlCloseTag(os,
- depth + command_depth,
- environment_inner[depth]);
+ lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]);
}
}
if (style.latexparam() == "CDATA")
os << "<![CDATA[";
else
- buf->sgmlOpenTag(os, depth + command_depth,
- style.latexparam());
+ lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style.latexparam());
}
break;
}
desc_on = (style.labeltype == LABEL_MANUAL);
- if (desc_on)
- environment_inner[depth]= "varlistentry";
- else
- environment_inner[depth]= "listitem";
+ environment_inner[depth] = desc_on?"varlistentry":"listitem";
+ lines += buf->sgmlOpenTag(os, depth + 1 + command_depth, mixcont, environment_inner[depth]);
- buf->sgmlOpenTag(os, depth + 1 + command_depth,
- environment_inner[depth]);
+ item_name = desc_on?"term":"para";
+ lines += buf->sgmlOpenTag(os, depth + 1 + command_depth, mixcont, item_name);
- if (desc_on) {
- item_name= "term";
- buf->sgmlOpenTag(os, depth + 1 + command_depth,
- item_name);
- } else {
- item_name= "para";
- buf->sgmlOpenTag(os, depth + 1 + command_depth,
- item_name);
- }
break;
default:
- buf->sgmlOpenTag(os, depth + command_depth,
- style.latexname());
+ lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style.latexname());
break;
}
- buf->simpleDocBookOnePar(os, p, desc_on,
- depth + 1 + command_depth);
+ buf->simpleDocBookOnePar(os, p, desc_on, depth + 1 + command_depth);
p = p->next();
string end_tag;
if (style.latexparam() == "CDATA")
os << "]]>";
else
- buf->sgmlCloseTag(os, depth + command_depth,
- style.latexparam());
+ lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style.latexparam());
}
break;
case LATEX_ITEM_ENVIRONMENT:
if (desc_on == 1) break;
end_tag= "para";
- buf->sgmlCloseTag(os, depth + 1 + command_depth, end_tag);
+ lines += buf->sgmlCloseTag(os, depth + 1 + command_depth, mixcont, end_tag);
break;
case LATEX_PARAGRAPH:
- buf->sgmlCloseTag(os, depth + command_depth, style.latexname());
+ lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style.latexname());
break;
default:
- buf->sgmlCloseTag(os, depth + command_depth, style.latexname());
+ lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style.latexname());
break;
}
}
if (!environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") {
item_name = "listitem";
- buf->sgmlCloseTag(os, command_depth + depth,
- item_name);
+ lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry")
- buf->sgmlCloseTag(os, depth + command_depth,
- environment_inner[depth]);
+ lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]);
}
- buf->sgmlCloseTag(os, depth + command_depth,
- environment_stack[depth]);
+ lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]);
}
}
bool InsetText::searchForward(BufferView * bv, string const & str,
bool cs, bool mw)
{
+ bool clear = false;
+ if (!lt) {
+ lt = getLyXText(bv);
+ clear = true;
+ }
if (the_locking_inset) {
if (the_locking_inset->searchForward(bv, str, cs, mw))
return true;
- bool clear = false;
- if (!lt) {
- lt = getLyXText(bv);
- clear = true;
- }
- Paragraph * lpar = lt->cursor.par();
- pos_type pos = lt->cursor.pos();
- if (pos < lpar->size() - 1)
- ++pos;
- else {
- pos = 0;
- lpar = lpar->next();
- }
- if (!lpar) {
- if (clear)
- lt = 0;
- // we have to unlock ourself in this function by default!
- bv->unlockInset(const_cast<InsetText *>(this));
- return false;
- }
- lt->setCursor(bv, lpar, pos);
- if (clear)
- lt = 0;
- }
- if (LyXFind(bv, str, true, true, cs , mw)) {
- return true;
+ lt->cursorRight(bv, true);
+ }
+ lyxfind::SearchResult result =
+ lyxfind::LyXFind(bv, lt, str, true, cs, mw);
+
+ if (result == lyxfind::SR_FOUND) {
+ LyXCursor cur = lt->cursor;
+ bv->unlockInset(bv->theLockingInset());
+ if (bv->lockInset(this))
+ locked = true;
+ lt->cursor = cur;
+ lt->setSelectionOverString(bv, str);
+ updateLocal(bv, SELECTION, false);
}
- // we have to unlock ourself in this function by default!
- bv->unlockInset(const_cast<InsetText *>(this));
- return false;
+ if (clear)
+ lt = 0;
+ return (result != lyxfind::SR_NOT_FOUND);
}
bool InsetText::searchBackward(BufferView * bv, string const & str,
bool cs, bool mw)
{
- if (the_locking_inset)
+ if (the_locking_inset) {
if (the_locking_inset->searchBackward(bv, str, cs, mw))
return true;
- if (LyXFind(bv, str, false, true, cs, mw)) {
- return true;
}
- // we have to unlock ourself in this function by default!
- bv->unlockInset(const_cast<InsetText *>(this));
- return false;
+ bool clear = false;
+ if (!lt) {
+ lt = getLyXText(bv);
+ clear = true;
+ }
+ if (!locked) {
+ Paragraph * p = par;
+ while (p->next())
+ p = p->next();
+ lt->setCursor(bv, p, p->size());
+ }
+ lyxfind::SearchResult result =
+ lyxfind::LyXFind(bv, lt, str, false, cs, mw);
+
+ if (result == lyxfind::SR_FOUND) {
+ LyXCursor cur = lt->cursor;
+ bv->unlockInset(bv->theLockingInset());
+ if (bv->lockInset(this))
+ locked = true;
+ lt->cursor = cur;
+ lt->setSelectionOverString(bv, str);
+ updateLocal(bv, SELECTION, false);
+ }
+ if (clear)
+ lt = 0;
+ return (result != lyxfind::SR_NOT_FOUND);
}
///
int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
///
- int docbook(Buffer const *, std::ostream &) const ;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const ;
///
void validate(LaTeXFeatures & features) const;
///
}
-int InsetTOC::docbook(Buffer const *, ostream & os) const
+int InsetTOC::docbook(Buffer const *, ostream & os, bool) const
{
if (getCmdName() == "tableofcontents")
os << "<toc></toc>";
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
};
#endif
}
-int InsetUrl::docbook(Buffer const *, ostream & os) const
+int InsetUrl::docbook(Buffer const *, ostream & os, bool) const
{
os << "<ulink url=\"" << subst(getContents(),"&","&")
<< "\">" << getOptions() << "</ulink>";
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
};
#endif
void InitKeyMapper(bool on);
// Get the Translation Manager
- TransManager & getTrans();
+ TransManager & getTransManager();
/// using primary or secondary keymap ?
Keymap keymap;
inline
-TransManager & Intl::getTrans()
+TransManager & Intl::getTransManager()
{
return trans;
}
#include "kbsequence.h"
#include "debug.h"
-#include <X11/Xlib.h>
-
using std::endl;
-// The only modifiers that we handle. We want to throw away things
-// like NumLock.
-enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
-
-
-string const kb_keymap::printKeysym(unsigned int key, key_modifier::state mod)
+string const kb_keymap::printKeysym(LyXKeySymPtr key,
+ key_modifier::state mod)
{
string buf;
- char const * const s = XKeysymToString(key);
+ string const s = key->getSymbolName();
if (mod & key_modifier::shift) buf += "S-";
if (mod & key_modifier::ctrl) buf += "C-";
if (mod & key_modifier::alt) buf += "M-";
- if (s) buf += s;
+ buf += s;
return buf;
}
-
-char kb_keymap::getiso(unsigned int c)
-{
- switch (c & 0x0000FF00) {
- // latin 1 byte 3 = 0
- case 0x00000000: break;
- // latin 2 byte 3 = 1
- case 0x00000100:
- // latin 3 byte 3 = 2
- case 0x00000200:
- // latin 4 byte 3 = 3
- case 0x00000300:
- // cyrillic KOI8 & Co
- case 0x00000600:
- // greek
- case 0x00000700:
- // latin 8 byte 3 = 18 (0x12)
- case 0x00001200:
- // latin 9 byte 3 = 19 (0x13)
- case 0x00001300:
- c &= 0x000000FF;
- break;
- default:
- c = 0;
- }
- return c;
-}
-
string const kb_keymap::printKey(kb_key const & key) const
{
return printKeysym(key.code, key.mod.first);
}
-int kb_keymap::lookup(unsigned int key,
+int kb_keymap::lookup(LyXKeySymPtr key,
key_modifier::state mod, kb_sequence * seq) const
{
if (table.empty()) {
key_modifier::state check =
static_cast<key_modifier::state>(mod & ~mask);
- if (cit->code == key && cit->mod.first == check) {
+ if (*(cit->code) == *(key) && cit->mod.first == check) {
// match found
if (cit->table.get()) {
// this is a prefix key - set new map
void kb_keymap::defkey(kb_sequence * seq, int action, unsigned int r)
{
- unsigned int const code = seq->sequence[r];
- if (code == NoSymbol) return;
+ LyXKeySymPtr code = seq->sequence[r];
+ if ( ! code->isOK() ) return;
key_modifier::state const mod1 = seq->modifiers[r].first;
key_modifier::state const mod2 = seq->modifiers[r].second;
// check if key is already there
for (Table::iterator it = table.begin(); it != table.end(); ++it) {
- if (code == it->code && mod1 == it->mod.first && mod2 == it->mod.second) {
+ if (*(code) == *(it->code)
+ && mod1 == it->mod.first
+ && mod2 == it->mod.second) {
// overwrite binding
if (r + 1 == seq->length()) {
lyxerr[Debug::KBMAP]
#include "LString.h"
#include "frontends/key_state.h"
-
-#include <boost/shared_ptr.hpp>
+#include "frontends/LyXKeySym.h"
#include <list>
* Bind a key sequence to an action.
* @return 0 on success, or position in string seq where error
* occurs.
+ * See kb_sequence::parse for the syntax of the seq string
*/
string::size_type bind(string const & seq, int action);
* @param seq the current key sequence so far
* @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION
*/
- int lookup(unsigned int key,
+ int lookup(LyXKeySymPtr key,
key_modifier::state mod, kb_sequence * seq) const;
/// Given an action, find all keybindings.
/**
* Returns a string of the given keysym, with modifiers.
- * @param key the key
+ * @param key the key as a keysym
* @param mod the modifiers
*/
- static string const printKeysym(unsigned int key, key_modifier::state mod);
-
- /// return the ISO value of a keysym
- static char getiso(unsigned int i);
+ static string const printKeysym(LyXKeySymPtr key,
+ key_modifier::state mod);
typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
///
struct kb_key {
/// Keysym
- unsigned int code;
+ LyXKeySymPtr code;
/// Modifier masks
modifier_pair mod;
int action;
};
-
/**
* Define an action for a key sequence.
* @param r internal recursion level
#endif
#include "frontends/mouse_state.h"
+#include "frontends/LyXKeySymFactory.h"
#include "kbsequence.h"
#include "kbmap.h"
#include "commandtags.h"
#include "debug.h"
-#include <X11/Xlib.h>
-
using std::make_pair;
using std::vector;
using std::endl;
using std::dec;
-// The only modifiers that we handle. We want to throw away things
-// like NumLock.
-enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
-
-int kb_sequence::addkey(unsigned int key, key_modifier::state mod, key_modifier::state nmod)
+int kb_sequence::addkey(LyXKeySymPtr key,
+ key_modifier::state mod, key_modifier::state nmod)
{
// adding a key to a deleted sequence
// starts a new sequence
if (deleted_) {
deleted_ = false;
- length_ = 0;
sequence.clear();
modifiers.clear();
}
modifiers.push_back(make_pair(mod, nmod));
sequence.push_back(key);
- ++length_;
if (curmap) {
return curmap->lookup(key, mod, this);
for (; j < s.length() && s[j] != ' '; ++j)
tbuf += s[j]; // (!!!check bounds :-)
- KeySym key = XStringToKeysym(tbuf.c_str());
- if (key == NoSymbol) {
- lyxerr[Debug::KBMAP]
- << "kbmap.C: No such keysym: "
- << tbuf << endl;
+ LyXKeySymPtr key(LyXKeySymFactory::create());
+ key->init(tbuf);
+
+ if ( ! key->isOK() ) {
return j;
}
+
i = j;
addkey(key, mod, nmod);
}
// empty sequence?
- if (!length_)
+ if (sequence.size() == 0)
return 0;
// everything is fine
//if (deleted_)
// return buf;
- for (vector<unsigned int>::size_type i = 0; i < length_; ++i) {
+ KeySequence::size_type i, length = sequence.size();
+
+ for (i = 0; i < length; ++i) {
buf += kb_keymap::printKeysym(sequence[i], modifiers[i].first);
// append a blank
- if (i + 1 < length_) {
+ if (i + 1 < length) {
buf += ' ';
}
}
}
-unsigned int kb_sequence::getsym() const
+LyXKeySymPtr kb_sequence::getsym() const
{
- if (length_ == 0) return NoSymbol;
- return sequence[length_ - 1];
+ if (sequence.size() == 0)
+ return LyXKeySymPtr(LyXKeySymFactory::create());
+ return sequence.back();
}
-char kb_sequence::getiso() const
+char kb_sequence::getLastKeyEncoded() const
{
- unsigned int const c = getsym();
-
- lyxerr[Debug::KBMAP] << "Raw keysym: "
- << hex << c << dec << endl;
- lyxerr[Debug::KBMAP] << "byte 3: "
- << hex << (c & 0xff00) << dec
- << endl;
- return kb_keymap::getiso(c);
+ return getsym()->getISOEncoded();
}
void kb_sequence::clear()
{
- length_ = 0;
+ sequence.clear();
reset();
}
#include <config.h>
#include "frontends/key_state.h"
+#include "frontends/LyXKeySym.h"
#include "LString.h"
-
#include <vector>
class kb_keymap;
/// Holds a key sequence and the current and standard keymaps
class kb_sequence {
public:
+ typedef std::vector<LyXKeySymPtr> KeySequence;
+
friend class kb_keymap;
///
kb_sequence(kb_keymap * std, kb_keymap * cur)
- : stdmap(std), curmap(cur), length_(0), deleted_(false) {}
-
-
+ : stdmap(std), curmap(cur), deleted_(false) {}
/**
* Add a key to the key sequence and look it up in the curmap
* if the latter is defined.
- * @param text the text from the key event
+ * @param keysym the key to add
* @param mod modifier mask
* @param nmod which modifiers to mask out for equality test
* @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
*/
- int addkey(unsigned int text, key_modifier::state mod,
- key_modifier::state nmod = key_modifier::none);
+ int addkey(LyXKeySymPtr keysym, key_modifier::state mod,
+ key_modifier::state nmod = key_modifier::none);
/**
* Add a sequence of keys from a string to the sequence
* @return string::npos if OK, else error position in string
*
* Keys in the string must be separated with whitespace;
- * Use the keysym names used by XStringToKeysym
+ * Use the keysym names used by XStringToKeysym, f.ex.
+ * "Space", "a", "Return", ...
* Prefixes are S-, C-, M- for shift, control, meta
+ * Prefixes can also be ignored by using the Tilde "~"
+ * f.ex.: "~S-Space".
*/
string::size_type parse(string const & s);
/// Mark the sequence as deleted.
void mark_deleted();
- /// Return the ISO value of the last keysym in sequence, or 0
- char getiso() const;
+ /**
+ * Return the value of the last keysym in the sequence
+ * in the local ISO encoding. If it does not encode
+ * in this encoding, return 0.
+ */
+ char getLastKeyEncoded() const;
/// Reset sequence to become "deleted"
void reset();
}
/// length of sequence
- std::vector<unsigned int>::size_type length() const {
- return length_;
+ KeySequence::size_type length() const {
+ return sequence.size();
}
/// Keymap to use if a new sequence is starting
private:
/// get the keysym of last in sequence
- unsigned int getsym() const;
+ LyXKeySymPtr getsym() const;
/**
- * Array holding the current key sequence.
+ * Array holding the current key sequence as KeySyms.
* If sequence[length-1] < 0xff it can be used as ISO8859 char
*/
- std::vector<unsigned int> sequence;
+ KeySequence sequence;
+
+ typedef std::pair<key_modifier::state, key_modifier::state>
+ modifier_pair;
- typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
/// modifiers for keys in the sequence
std::vector<modifier_pair> modifiers;
- /// Current length of key sequence
- std::vector<unsigned int>::size_type length_;
-
/// is keysequence deleted ?
bool deleted_;
};
#include "frontends/Alert.h"
#include "frontends/FileDialog.h"
-#include <X11/Xlib.h>
#include "support/FileInfo.h"
#include "support/filetools.h"
using lyx::pos_type;
-
-///
-// locally used enum
-///
-enum SearchResult {
- //
- SR_NOT_FOUND = 0,
- //
- SR_FOUND,
- //
- SR_FOUND_NOUPDATE
-};
-
+namespace lyxfind {
/// returns true if the specified string is at the specified position
bool IsStringInText(Paragraph * par, pos_type pos,
SearchResult SearchBackward(BufferView *, LyXText * text, string const & str,
bool const & = true, bool const & = false);
-
int LyXReplace(BufferView * bv,
string const & searchstr, string const & replacestr,
bool forward, bool casesens, bool matchwrd, bool replaceall,
return 0;
}
- LyXText * text = bv->getLyXText();
-
// now we can start searching for the first
// start at top if replaceall
+ LyXText * text = bv->getLyXText();
bool fw = forward;
if (replaceall) {
text->clearSelection();
- if (text->inset_owner) {
- bv->unlockInset(bv->theLockingInset());
- text = bv->text;
- }
+ bv->unlockInset(bv->theLockingInset());
+ text = bv->text;
text->cursorTop(bv);
// override search direction because we search top to bottom
fw = true;
str2 = lowercase(text->selectionAsString(bv->buffer(), false));
}
if (str1 != str2) {
- if (!LyXFind(bv, searchstr, fw, false, casesens, matchwrd) ||
+ if (!LyXFind(bv, searchstr, fw, casesens, matchwrd) ||
!replaceall)
{
return 0;
bool found = false;
int replace_count = 0;
do {
+ text = bv->getLyXText();
bv->hideCursor();
- bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
+ bv->update(text, BufferView::SELECT|BufferView::FITCUR);
bv->toggleSelection(false);
- bv->getLyXText()->replaceSelectionWithString(bv, replacestr);
- bv->getLyXText()->setSelectionOverString(bv, replacestr);
- bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ text->replaceSelectionWithString(bv, replacestr);
+ text->setSelectionOverString(bv, replacestr);
+ bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
++replace_count;
if (!once)
- found = LyXFind(bv, searchstr, fw, false, casesens, matchwrd);
+ found = LyXFind(bv, searchstr, fw, casesens, matchwrd);
} while (!once && replaceall && found);
if (bv->focus())
bool LyXFind(BufferView * bv,
string const & searchstr, bool forward,
- bool frominset, bool casesens, bool matchwrd)
+ bool casesens, bool matchwrd)
{
if (!bv->available() || searchstr.empty())
return false;
- LyXText * text = bv->getLyXText();
-
bv->hideCursor();
- bv->update(text, BufferView::SELECT|BufferView::FITCUR);
-
- if (text->selection.set())
- text->cursor = forward ?
- text->selection.end : text->selection.start;
+ bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
- SearchResult result = SR_NOT_FOUND;
-
- if (!frominset && bv->theLockingInset()) {
+ if (bv->theLockingInset()) {
bool found = forward ?
bv->theLockingInset()->searchForward(bv, searchstr, casesens, matchwrd) :
bv->theLockingInset()->searchBackward(bv, searchstr, casesens, matchwrd);
+ // We found the stuff inside the inset so we don't have to
+ // do anything as the inset did all the update for us!
if (found)
- result = SR_FOUND_NOUPDATE;
- else {
- text = bv->getLyXText();
- Paragraph * par = text->cursor.par();
- pos_type pos = text->cursor.pos();
- if (forward) {
- if (pos < par->size() - 1)
- ++pos;
- else {
- pos = 0;
- par = par->next();
- }
- if (par)
- text->setCursor(bv, par, pos);
- }
- if (par) {
- result = forward ?
- SearchForward(bv, text, searchstr, casesens, matchwrd) :
- SearchBackward(bv, text, searchstr, casesens, matchwrd);
- }
+ return true;
+ // We now are in the main text but if we did a forward
+ // search we have to put the cursor behind the inset.
+ if (forward) {
+ bv->text->cursorRight(bv, true);
}
- } else {
- result = forward ?
- SearchForward(bv, text, searchstr, casesens, matchwrd) :
- SearchBackward(bv, text, searchstr, casesens, matchwrd);
}
+ // If we arrive here we are in the main text again so we
+ // just start searching from the root LyXText at the position
+ // we are!
+ LyXText * text = bv->text;
+
+ if (text->selection.set())
+ text->cursor = forward ?
+ text->selection.end : text->selection.start;
+
+ bv->toggleSelection();
+ text->clearSelection();
+
+ SearchResult result = forward ?
+ SearchForward(bv, text, searchstr, casesens, matchwrd) :
+ SearchBackward(bv, text, searchstr, casesens, matchwrd);
bool found = true;
+ // If we found the cursor inside an inset we will get back
+ // SR_FOUND_NOUPDATE and we don't have to do anything as the
+ // inset did it already.
if (result == SR_FOUND) {
- // the actual text pointer could have changed!
- bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
- bv->toggleSelection();
- bv->getLyXText()->clearSelection();
- bv->getLyXText()->setSelectionOverString(bv, searchstr);
+ bv->unlockInset(bv->theLockingInset());
+ bv->update(text, BufferView::SELECT|BufferView::FITCUR);
+ text->setSelectionOverString(bv, searchstr);
bv->toggleSelection(false);
- bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
+ bv->update(text, BufferView::SELECT|BufferView::FITCUR);
} else if (result == SR_NOT_FOUND) {
- bv->toggleSelection();
- bv->getLyXText()->clearSelection();
- bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
+ bv->unlockInset(bv->theLockingInset());
+ bv->update(text, BufferView::SELECT|BufferView::FITCUR);
found = false;
}
- if (bv->focus())
+ if (result != SR_FOUND_NOUPDATE && bv->focus())
bv->showCursor();
return found;
}
+SearchResult LyXFind(BufferView * bv, LyXText * text,
+ string const & searchstr, bool forward,
+ bool casesens, bool matchwrd)
+{
+ if (text->selection.set())
+ text->cursor = forward ?
+ text->selection.end : text->selection.start;
+
+ bv->toggleSelection();
+ text->clearSelection();
+
+ SearchResult result = forward ?
+ SearchForward(bv, text, searchstr, casesens, matchwrd) :
+ SearchBackward(bv, text, searchstr, casesens, matchwrd);
+
+ return result;
+}
+
// returns true if the specified string is at the specified position
bool IsStringInText(Paragraph * par, pos_type pos,
(inset = (UpdatableInset *)par->getInset(pos)) &&
(inset->isTextInset()))
{
+#if 0
// lock the inset!
text->setCursor(bv, par, pos);
inset->edit(bv);
+#endif
if (inset->searchForward(bv, str, cs, mw))
return SR_FOUND_NOUPDATE;
- text = bv->getLyXText();
}
++pos;
(inset = (UpdatableInset *)par->getInset(pos)) &&
(inset->isTextInset()))
{
+#if 0
// lock the inset!
text->setCursor(bv, par, pos);
inset->edit(bv, false);
+#endif
if (inset->searchBackward(bv, str, cs, mw))
return SR_FOUND_NOUPDATE;
- text = bv->getLyXText();
}
} while (par && !IsStringInText(par, pos, str, cs, mw));
return SR_NOT_FOUND;
}
}
+
+} // end lyxfind namespace
class BufferView;
-int LyXReplace(BufferView * bv, string const &, string const &,
+namespace lyxfind {
+
+enum SearchResult {
+ //
+ SR_NOT_FOUND = 0,
+ //
+ SR_FOUND,
+ //
+ SR_FOUND_NOUPDATE
+};
+
+
+int LyXReplace(BufferView * bv,
+ string const &, string const &,
bool, bool = true, bool = false,
bool = false, bool = false);
+/**
+ * This function is called as a general interface to find some
+ * text from the actual cursor position in whatever direction
+ * we want to go. This does also update the screen.
+ */
bool LyXFind(BufferView *,
string const & searchstr, bool forward,
- bool frominset = false, bool casesens = true,
- bool matchwrd = false);
+ bool casesens = true, bool matchwrd = false);
+
+/**
+ * This function does search from the cursor position inside the
+ * passed LyXText parameter and regards this LyXText as the root
+ * LyXText. It will NOT update any screen stuff. It will however
+ * set the cursor to the new position inside LyXText, before
+ * returning to the calling function.
+ */
+
+SearchResult LyXFind(BufferView *, LyXText * text,
+ string const & searchstr, bool forward,
+ bool casesens = true, bool matchwrd = false);
+} // end namespace LyXFind
#endif
void LyXFunc::handleKeyFunc(kb_action action)
{
- char c = keyseq.getiso();
+ char c = keyseq.getLastKeyEncoded();
if (keyseq.length() > 1) {
c = 0;
}
- owner->getIntl()->getTrans()
+ owner->getIntl()->getTransManager()
.deadkey(c, get_accent(action).accent, TEXT(false));
// Need to clear, in case the minibuffer calls these
// actions
}
-void LyXFunc::processKeySym(KeySym keysym, key_modifier::state state)
+void LyXFunc::processKeySym(LyXKeySymPtr keysym,
+ key_modifier::state state)
{
string argument;
if (lyxerr.debugging(Debug::KEY)) {
- char const * tmp = XKeysymToString(keysym);
- string const stm = (tmp ? tmp : "");
lyxerr << "KeySym is "
- << stm
- << "["
- << keysym
+ << keysym->getSymbolName()
<< endl;
}
// Do nothing if we have nothing (JMarc)
- if (keysym == NoSymbol) {
+ if ( ! keysym->isOK() ) {
lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
<< endl;
return;
}
- // Can we be sure that this will work for all X Window
- // implementations? (Lgb)
- // This code snippet makes lyx ignore some keys. Perhaps
- // all of them should be explictly mentioned?
- if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
- || keysym == XK_Mode_switch || keysym == 0x0) {
+ // This code snippet makes lyx ignore modifier keys.
+ if (keysym->isModifier()) {
return;
}
if (action == LFUN_SELFINSERT) {
// This is very X dependent.
- unsigned int c = keysym;
+ char c = keysym->getISOEncoded();
string argument;
- c = kb_keymap::getiso(c);
-
- if (c > 0)
- argument = static_cast<char>(c);
+ if (c != 0)
+ argument = c;
dispatch(LFUN_SELFINSERT, argument);
lyxerr[Debug::KEY] << "SelfInsert arg[`"
#endif
if ((action == LFUN_UNKNOWN_ACTION)
&& argument.empty()) {
- argument = keyseq.getiso();
+ argument = keyseq.getLastKeyEncoded();
}
// Undo/Redo is a bit tricky for insets.
if (action == LFUN_UNDO) {
}
bool fw = (action == LFUN_WORDFINDBACKWARD);
if (!searched_string.empty()) {
- LyXFind(owner->view(), searched_string, fw);
+ lyxfind::LyXFind(owner->view(), searched_string, fw);
}
// owner->view()->showCursor();
}
#include "frontends/mouse_state.h"
#include "frontends/key_state.h"
+#include "frontends/LyXKeySym.h"
#include <boost/signals/trackable.hpp>
-#include <X11/Xlib.h>
-
class LyXView;
class LyXText;
void initMiniBuffer();
///
- void processKeySym(KeySym key, key_modifier::state state);
+ void processKeySym(LyXKeySymPtr key, key_modifier::state state);
/// we need one internal which is called from inside LyXAction and
/// can contain the string argument.
string const getMessage() const { return dispatch_buffer; }
/// Buffer to store result messages
string const getStatusMessage() const { return status_buffer; }
- /// Handle a accented char keysequenze
+ /// Handle a accented char key sequence
void handleKeyFunc(kb_action action);
private:
mutable LyXFont current_font;
/// the current font
mutable LyXFont real_current_font;
- /// first visible pixel-row is set from LScreen!!!
+ /// first visible pixel-row is set from LyXScreen!!!
// unsigned is wrong here for text-insets!
int first_y;
///
+2002-06-16 André Pönitz <poenitz@gmx.net>
+
+ * math_factory.C:
+ * math_support.C: fix font fall-back
+
+ * math_specialcharinset.[Ch]:
+ * math_funcliminset.[Ch]: remove, it's now done by MathSymbolInset
+
+ * math_funcinset.[Ch]: remove, it's not used
+
+2002-06-16 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * math_extern.C: add using std::endl
+
+2002-06-15 LyX Development team <lyx@rilke>
+
+ * formula.[Ch]:
+ * macroformula.[Ch] (docbook): Added argument to care about the
+ pernicious mixed content.
2002-05-30 André Pönitz <poenitz@gmx.net>
math_fracinset.h \
math_fracbase.C \
math_fracbase.h \
- math_funcliminset.C \
- math_funcliminset.h \
math_gridinset.C \
math_gridinset.h \
math_hullinset.C \
math_mathmlstream.h \
math_matrixinset.C \
math_matrixinset.h \
- math_metricsinfo.h \
math_metricsinfo.C \
+ math_metricsinfo.h \
math_nestinset.C \
math_nestinset.h \
math_notinset.C \
math_notinset.h \
+ math_numberinset.C \
+ math_numberinset.h \
math_parser.C \
math_parser.h \
math_pos.C \
math_sizeinset.h \
math_spaceinset.C \
math_spaceinset.h \
- math_specialcharinset.C \
- math_specialcharinset.h \
math_splitinset.C \
math_splitinset.h \
math_sqrtinset.C \
#include "frontends/Alert.h"
#include "support/LOstream.h"
#include "support/LAssert.h"
-#include "support/systemcall.h"
#include "support/filetools.h" // LibFileSearch
#include "frontends/LyXView.h"
#include "frontends/Painter.h"
using std::getline;
-namespace {
-
- string captureOutput(string const & cmd, string const & data)
- {
- string outfile = lyx::tempName(string(), "mathextern");
- string full = "echo '" + data + "' | (" + cmd + ") > " + outfile;
- lyxerr << "calling: " << full << "\n";
- Systemcall dummy;
- dummy.startscript(Systemcall::Wait, full);
- string out = GetFileContents(outfile);
- lyx::unlink(outfile);
- lyxerr << "result: '" << out << "'\n";
- return out;
- }
-
-
- MathArray pipeThroughMaple(string const & extra, MathArray const & ar)
- {
- string header = "readlib(latex):\n";
-
- // remove the \\it for variable names
- //"#`latex/csname_font` := `\\it `:"
- header +=
- "`latex/csname_font` := ``:\n";
-
- // export matrices in (...) instead of [...]
- header +=
- "`latex/latex/matrix` := "
- "subs(`[`=`(`, `]`=`)`,"
- "eval(`latex/latex/matrix`)):\n";
-
- // replace \\cdots with proper '*'
- header +=
- "`latex/latex/*` := "
- "subs(`\\,`=`\\cdot `,"
- "eval(`latex/latex/*`)):\n";
-
- // remove spurious \\noalign{\\medskip} in matrix output
- header +=
- "`latex/latex/matrix`:= "
- "subs(`\\\\\\\\\\\\noalign{\\\\medskip}` = `\\\\\\\\`,"
- "eval(`latex/latex/matrix`)):\n";
-
- //"#`latex/latex/symbol` "
- // " := subs((\\'_\\' = \\'`\\_`\\',eval(`latex/latex/symbol`)): ";
-
- string trailer = "quit;";
- ostringstream os;
- MapleStream ms(os);
- ms << ar;
- string expr = os.str().c_str();
- lyxerr << "ar: '" << ar << "'\n";
-
- for (int i = 0; i < 100; ++i) { // at most 100 attempts
- // try to fix missing '*' the hard way by using mint
- //
- // ... > echo "1A;" | mint -i 1 -S -s -q
- // on line 1: 1A;
- // ^ syntax error -
- // Probably missing an operator such as * p
- //
- lyxerr << "checking expr: '" << expr << "'\n";
- string out = captureOutput("mint -i 1 -S -s -q -q", expr + ";");
- if (out.empty())
- break; // expression syntax is ok
- istringstream is(out.c_str());
- string line;
- getline(is, line);
- if (line.find("on line") != 0)
- break; // error message not identified
- getline(is, line);
- string::size_type pos = line.find('^');
- if (pos == string::npos || pos < 15)
- break; // caret position not found
- pos -= 15; // skip the "on line ..." part
- if (expr[pos] == '*' || (pos > 0 && expr[pos - 1] == '*'))
- break; // two '*' in a row are definitely bad
- expr.insert(pos, "*");
- }
-
- string full = "latex(" + extra + '(' + expr + "));";
- string out = captureOutput("maple -q", header + full + trailer);
-
- // change \_ into _
-
- //
- MathArray res;
- mathed_parse_cell(res, out);
- return res;
- }
-
-
- MathArray pipeThroughOctave(string const &, MathArray const & ar)
- {
- ostringstream os;
- OctaveStream vs(os);
- vs << ar;
- string expr = os.str().c_str();
- string out;
-
- for (int i = 0; i < 100; ++i) { // at most 100 attempts
- //
- // try to fix missing '*' the hard way
- // parse error:
- // >>> ([[1 2 3 ];[2 3 1 ];[3 1 2 ]])([[1 2 3 ];[2 3 1 ];[3 1 2 ]])
- // ^
- //
- lyxerr << "checking expr: '" << expr << "'\n";
- out = captureOutput("octave -q 2>&1", expr);
- lyxerr << "checking out: '" << out << "'\n";
-
- // leave loop if expression syntax is probably ok
- if (out.find("parse error:") == string::npos)
- break;
-
- // search line with single caret
- istringstream is(out.c_str());
- string line;
- while (is) {
- getline(is, line);
- lyxerr << "skipping line: '" << line << "'\n";
- if (line.find(">>> ") != string::npos)
- break;
- }
-
- // found line with error, next line is the one with caret
- getline(is, line);
- string::size_type pos = line.find('^');
- lyxerr << "caret line: '" << line << "'\n";
- lyxerr << "found caret at pos: '" << pos << "'\n";
- if (pos == string::npos || pos < 4)
- break; // caret position not found
- pos -= 4; // skip the ">>> " part
- if (expr[pos] == '*')
- break; // two '*' in a row are definitely bad
- expr.insert(pos, "*");
- }
-
- if (out.size() < 6)
- return MathArray();
-
- // remove 'ans = '
- out = out.substr(6);
-
- // parse output as matrix or single number
- MathAtom at(new MathArrayInset("array", out));
- MathArrayInset const * mat = at.nucleus()->asArrayInset();
- MathArray res;
- if (mat->ncols() == 1 && mat->nrows() == 1)
- res.push_back(mat->cell(0));
- else {
- res.push_back(MathAtom(new MathDelimInset("(", ")")));
- res.back()->cell(0).push_back(at);
- }
- return res;
- }
-
-
- MathArray pipeThroughExtern(string const & lang, string const & extra,
- MathArray const & ar)
- {
- if (lang == "octave")
- return pipeThroughOctave(extra, ar);
-
- if (lang == "maple")
- return pipeThroughMaple(extra, ar);
-
- // create normalized expression
- ostringstream os;
- NormalStream ns(os);
- os << "[" << extra << ' ';
- ns << ar;
- os << "]";
- string data = os.str().c_str();
-
- // search external script
- string file = LibFileSearch("mathed", "extern_" + lang);
- if (file.empty()) {
- lyxerr << "converter to '" << lang << "' not found\n";
- return MathArray();
- }
-
- // run external sript
- string out = captureOutput(file, data);
- MathArray res;
- mathed_parse_cell(res, out);
- return res;
- }
-
-}
-
InsetFormula::InsetFormula()
: par_(MathAtom(new MathHullInset))
int InsetFormula::linuxdoc(Buffer const * buf, ostream & os) const
{
- return docbook(buf, os);
+ return docbook(buf, os, false);
}
-int InsetFormula::docbook(Buffer const * buf, ostream & os) const
+int InsetFormula::docbook(Buffer const * buf, ostream & os, bool) const
{
MathMLStream ms(os);
- ms << MTag("equation") << MTag("alt");
+ ms << MTag("equation");
+ ms << MTag("alt");
+ ms << "<[CDATA[";
int res = ascii(buf, ms.os(), 0);
- ms << ETag("alt") << MTag("math");
- ms << par_.nucleus();
- ms << ETag("math") << ETag("equation");
+ ms << "]]>";
+ ms << ETag("alt");
+ ms << MTag("math");
+ ms << par_.nucleus();
+ ms << ETag("math");
+ ms << ETag("equation");
return ms.line() + res;
}
case LFUN_MATH_EXTERN:
{
bv->lockedInsetStoreUndo(Undo::EDIT);
- handleExtern(arg);
+ if (mathcursor)
+ mathcursor->handleExtern(arg);
// re-compute inset dimension
metrics(bv);
updateLocal(bv, true);
int x = 0;
int y = 0;
mathcursor->getPos(x, y);
- if (hull()->getType() == LM_OT_SIMPLE)
+ if (getType() == LM_OT_SIMPLE)
hull()->mutate(LM_OT_EQUATION);
else
hull()->mutate(LM_OT_SIMPLE);
}
-void InsetFormula::handleExtern(const string & arg)
-{
- // where are we?
- if (!mathcursor)
- return;
-
- string lang;
- string extra;
- istringstream iss(arg.c_str());
- iss >> lang >> extra;
- if (extra.empty())
- extra = "noextra";
-
- bool selected = mathcursor->selection();
-
- MathArray ar;
- if (selected) {
- mathcursor->selGet(ar);
- //lyxerr << "use selection: " << ar << "\n";
- } else {
- mathcursor->last();
- mathcursor->stripFromLastEqualSign();
- ar = mathcursor->cursor().cell();
- mathcursor->insert('=');
- //lyxerr << "use whole cell: " << ar << "\n";
- }
-
- mathcursor->insert(pipeThroughExtern(lang, extra, ar));
-}
-
-
bool InsetFormula::display() const
{
- return hull()->getType() != LM_OT_SIMPLE;
+ return getType() != LM_OT_SIMPLE;
}
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
Inset * clone(Buffer const &, bool same_id = false) const;
string::const_iterator cit = str.begin();
string::const_iterator end = str.end();
for (; cit != end; ++cit)
- view_->owner()->getIntl()->getTrans().TranslateAndInsert(*cit, lt);
+ view_->owner()->getIntl()->getTransManager().TranslateAndInsert(*cit, lt);
// remove ourselves
//view_->owner()->getLyXFunc()->dispatch(LFUN_ESCAPE);
}
-void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
+void InsetFormulaBase::getCursorPos(BufferView * bv, int & x, int & y) const
{
+ metrics(bv);
mathcursor->getPos(x, y);
//x -= xo_;
y -= yo_;
}
+void InsetFormulaBase::fitInsetCursor(BufferView * bv) const
+{
+ if (!mathcursor)
+ return;
+
+ int const asc = font_metrics::maxAscent(font_);
+ int const desc = font_metrics::maxDescent(font_);
+ int x, y;
+
+ getCursorPos(bv, x, y);
+ bv->fitLockedInsetCursor(x, y, asc, desc);
+}
+
+
void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
{
if (mathcursor)
void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
{
metrics(bv);
+ if (mathcursor)
+ bv->fitCursor();
bv->updateInset(this, dirty);
}
for (MathIterator it = current; it != iend(par().nucleus()); ++it) {
if (it.cell().matchpart(ar, it.position().pos_)) {
+ bv->unlockInset(bv->theLockingInset());
+ if (!bv->lockInset(this)) {
+ lyxerr << "Cannot lock inset" << endl;
+ return false;
+ }
+ delete mathcursor;
+ mathcursor = new MathCursor(this, true);
+ metrics(bv);
mathcursor->setSelection(it.cursor(), ar.size());
current = it;
it.jump(ar.size());
- // I guess some of the following can go
- bv->toggleSelection(true);
- hideInsetCursor(bv);
- updateLocal(bv, true);
- showInsetCursor(bv);
- metrics(bv);
+ updateLocal(bv, false);
return true;
}
}
//lyxerr << "not found!\n";
lastformula = 0;
- // we have to unlock ourself in this function by default!
- // don't ask me why...
- bv->unlockInset(this);
return false;
}
void mathDispatch(BufferView *, kb_action, string const &)
{}
+
+
+void mathDispatch(BufferView *, string const &)
+{}
///
virtual void hideInsetCursor(BufferView *);
///
+ virtual void fitInsetCursor(BufferView *) const;
+ ///
virtual void getCursorPos(BufferView *, int &, int &) const;
///
virtual void toggleInsetSelection(BufferView * bv);
void mathDispatchMathImportSelection(BufferView *, string const &);
//
void mathDispatch(BufferView *, kb_action, string const &);
+//
+void mathDispatch(BufferView *, string const &);
#endif
}
-int InsetFormulaMacro::docbook(Buffer const * buf, ostream & os) const
+int InsetFormulaMacro::docbook(Buffer const * buf, ostream & os, bool) const
{
return ascii(buf, os, 0);
}
///
int linuxdoc(Buffer const *, std::ostream & os) const;
///
- int docbook(Buffer const *, std::ostream &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
Inset * clone(Buffer const &, bool same_id = false) const;
is >> s1 >> s2 >> s3;
if (!is)
return false;
+ if (s2.size() != 1)
+ return false;
MathArray ar1, ar3;
mathed_parse_cell(ar1, s1);
mathed_parse_cell(ar3, s3);
- if (ar1.size() != 1 || s2.size() != 1 || ar3.size() !=1)
+ if (ar1.size() != 1 || ar3.size() != 1)
return false;
from1_ = ar1.front();
from2_ = s2[0];
}
+void MathCharInset::octavize(OctaveStream & os) const
+{
+ os << char_;
+}
+
+
bool MathCharInset::isRelOp() const
{
return char_ == '=' || char_ == '<' || char_ == '>';
///
void write(WriteStream & os) const;
///
- void normalize(NormalStream &) const;
+ void normalize(NormalStream & ns) const;
+ ///
+ void octavize(OctaveStream & os) const;
/// identifies Charinsets
MathCharInset const * asCharInset() const { return this; }
///
#include "math_casesinset.h"
#include "math_charinset.h"
#include "math_deliminset.h"
+#include "math_extern.h"
#include "math_factory.h"
#include "math_hullinset.h"
#include "math_iterator.h"
#include "math_replace.h"
#include "math_scriptinset.h"
#include "math_spaceinset.h"
-#include "math_specialcharinset.h"
#include "math_support.h"
#include "math_unknowninset.h"
using std::isalpha;
-namespace {
-
-struct Selection
-{
- typedef MathInset::col_type col_type;
- typedef MathInset::row_type row_type;
- typedef MathInset::idx_type idx_type;
-
- Selection()
- : data_(1, 1)
- {}
-
- void region(MathCursorPos const & i1, MathCursorPos const & i2,
- row_type & r1, row_type & r2, col_type & c1, col_type & c2)
- {
- MathInset * p = i1.par_;
- c1 = p->col(i1.idx_);
- c2 = p->col(i2.idx_);
- if (c1 > c2)
- swap(c1, c2);
- r1 = p->row(i1.idx_);
- r2 = p->row(i2.idx_);
- if (r1 > r2)
- swap(r1, r2);
- }
-
- void grab(MathCursor const & cursor)
- {
- MathCursorPos i1;
- MathCursorPos i2;
- cursor.getSelection(i1, i2);
- // shouldn'tt we assert on i1.par_ == i2.par_?
- if (i1.idx_ == i2.idx_) {
- data_ = MathGridInset(1, 1);
- data_.cell(0) = MathArray(i1.cell(), i1.pos_, i2.pos_);
- } else {
- row_type r1, r2;
- col_type c1, c2;
- region(i1, i2, r1, r2, c1, c2);
- data_ = MathGridInset(c2 - c1 + 1, r2 - r1 + 1);
- for (row_type row = 0; row < data_.nrows(); ++row)
- for (col_type col = 0; col < data_.ncols(); ++col) {
- idx_type i = i1.par_->index(row + r1, col + c1);
- data_.cell(data_.index(row, col)) = i1.par_->cell(i);
- }
- }
- }
-
- void erase(MathCursor & cursor)
- {
- MathCursorPos i1;
- MathCursorPos i2;
- cursor.getSelection(i1, i2);
- if (i1.idx_ == i2.idx_)
- i1.cell().erase(i1.pos_, i2.pos_);
- else {
- MathInset * p = i1.par_;
- row_type r1, r2;
- col_type c1, c2;
- region(i1, i2, r1, r2, c1, c2);
- for (row_type row = r1; row <= r2; ++row)
- for (col_type col = c1; col <= c2; ++col)
- p->cell(p->index(row, col)).erase();
- }
- cursor.cursor() = i1;
- }
-
- void paste(MathCursor & cursor) const
- {
- if (data_.nargs() == 1) {
- // single cell/part of cell
- cursor.paste(data_.cell(0));
- } else {
- // mulitple cells
- idx_type idx; // index of upper left cell
- MathGridInset * p = cursor.enclosingGrid(idx);
- col_type const numcols = min(data_.ncols(), p->ncols() - p->col(idx));
- row_type const numrows = min(data_.nrows(), p->nrows() - p->row(idx));
- for (row_type row = 0; row < numrows; ++row) {
- for (col_type col = 0; col < numcols; ++col) {
- idx_type i = p->index(row + p->row(idx), col + p->col(idx));
- p->cell(i).push_back(data_.cell(data_.index(row, col)));
- }
- // append the left over horizontal cells to the last column
- idx_type i = p->index(row + p->row(idx), p->ncols() - 1);
- for (col_type col = numcols; col < data_.ncols(); ++col)
- p->cell(i).push_back(data_.cell(data_.index(row, col)));
- }
- // append the left over vertical cells to the last _cell_
- idx_type i = p->nargs() - 1;
- for (row_type row = numrows; row < data_.nrows(); ++row)
- for (col_type col = 0; col < data_.ncols(); ++col)
- p->cell(i).push_back(data_.cell(data_.index(row, col)));
- }
- }
-
- // glues selection to one cell
- MathArray glue() const
- {
- MathArray ar;
- for (unsigned i = 0; i < data_.nargs(); ++i)
- ar.push_back(data_.cell(i));
- return ar;
- }
-
- void clear()
- {
- data_ = MathGridInset(1, 1);
- }
-
- MathGridInset data_;
-};
-
-
-Selection theSelection;
-
-
-
-}
+// matheds own cut buffer
+MathGridInset theCutBuffer = MathGridInset(1, 1);
MathCursor::MathCursor(InsetFormulaBase * formula, bool front)
: formula_(formula), autocorrect_(false), selection_(false)
{
front ? first() : last();
+ Anchor_ = Cursor_;
}
bool MathCursor::popLeft()
{
//cerr << "Leaving atom to the left\n";
- if (Cursor_.size() <= 1)
+ if (depth() <= 1)
return false;
Cursor_.pop_back();
return true;
bool MathCursor::popRight()
{
//cerr << "Leaving atom "; par()->write(cerr, false); cerr << " right\n";
- if (Cursor_.size() <= 1)
+ if (depth() <= 1)
return false;
Cursor_.pop_back();
posRight();
void MathCursor::dump(char const * what) const
{
lyxerr << "MC: " << what << "\n";
- lyxerr << " Cursor: " << Cursor_.size() << "\n";
- for (unsigned i = 0; i < Cursor_.size(); ++i)
+ lyxerr << " Cursor: " << depth() << "\n";
+ for (unsigned i = 0; i < depth(); ++i)
lyxerr << " i: " << i << " " << Cursor_[i] << "\n";
lyxerr << " Anchor: " << Anchor_.size() << "\n";
for (unsigned i = 0; i < Anchor_.size(); ++i)
bool MathCursor::isInside(MathInset const * p) const
{
- for (unsigned i = 0; i < Cursor_.size(); ++i)
+ for (unsigned i = 0; i < depth(); ++i)
if (Cursor_[i].par_ == p)
return true;
return false;
if (sel) {
// we can't move into anything new during selection
- if (Cursor_.size() == Anchor_.size())
+ if (depth() == Anchor_.size())
return false;
- if (t.nucleus() != Anchor_[Cursor_.size()].par_)
+ if (t.nucleus() != Anchor_[depth()].par_)
return false;
}
return true;
void MathCursor::insert(MathAtom const & t)
{
macroModeClose();
-
- if (selection_) {
- if (t->nargs())
- selCut();
- else
- selClearOrDel();
- }
-
+ selClearOrDel();
plainInsert(t);
}
void MathCursor::niceInsert(MathAtom const & t)
{
- selCut();
- insert(t); // inserting invalidates the pointer!
- MathAtom & p = prevAtom();
+ macroModeClose();
+ MathGridInset safe = grabAndEraseSelection();
+ plainInsert(t);
// enter the new inset and move the contents of the selection if possible
- if (p->isActive()) {
- push(p);
- par()->idxLast(idx(), pos());
- selPaste();
+ if (t->isActive()) {
+ posLeft();
+ pushLeft(nextAtom());
+ paste(safe);
}
}
{
macroModeClose();
if (selection_)
- selCut();
+ eraseSelection();
array().insert(pos(), ar);
pos() += ar.size();
}
+void MathCursor::paste(MathGridInset const & data)
+{
+ if (data.nargs() == 1) {
+ // single cell/part of cell
+ paste(data.cell(0));
+ } else {
+ // mulitple cells
+ idx_type idx; // index of upper left cell
+ MathGridInset * p = enclosingGrid(idx);
+ col_type const numcols = min(data.ncols(), p->ncols() - p->col(idx));
+ row_type const numrows = min(data.nrows(), p->nrows() - p->row(idx));
+ for (row_type row = 0; row < numrows; ++row) {
+ for (col_type col = 0; col < numcols; ++col) {
+ idx_type i = p->index(row + p->row(idx), col + p->col(idx));
+ p->cell(i).push_back(data.cell(data.index(row, col)));
+ }
+ // append the left over horizontal cells to the last column
+ idx_type i = p->index(row + p->row(idx), p->ncols() - 1);
+ for (MathInset::col_type col = numcols; col < data.ncols(); ++col)
+ p->cell(i).push_back(data.cell(data.index(row, col)));
+ }
+ // append the left over vertical cells to the last _cell_
+ idx_type i = p->nargs() - 1;
+ for (row_type row = numrows; row < data.nrows(); ++row)
+ for (col_type col = 0; col < data.ncols(); ++col)
+ p->cell(i).push_back(data.cell(data.index(row, col)));
+ }
+}
+
void MathCursor::backspace()
{
autocorrect_ = false;
string MathCursor::macroName() const
{
- return inMacroMode() ? inMacroMode()->name() : "";
+ return inMacroMode() ? inMacroMode()->name() : string();
+}
+
+
+void MathCursor::selClear()
+{
+ selection_ = false;
}
{
dump("selCopy");
if (selection_) {
- theSelection.grab(*this);
- //selClear();
+ theCutBuffer = grabSelection();
+ selection_ = false;
+ } else {
+ theCutBuffer = MathGridInset(1, 1);
}
}
void MathCursor::selCut()
{
dump("selCut");
- if (selection_) {
- theSelection.grab(*this);
- theSelection.erase(*this);
- selClear();
- } else {
- theSelection.clear();
- }
+ theCutBuffer = grabAndEraseSelection();
}
{
dump("selDel");
if (selection_) {
- theSelection.erase(*this);
- if (pos() > size())
- pos() = size();
- selClear();
+ eraseSelection();
+ selection_ = false;
}
}
{
dump("selPaste");
selClearOrDel();
- theSelection.paste(*this);
- //theSelection.grab(*this);
- selClear();
+ paste(theCutBuffer);
+ //grabSelection();
+ selection_ = false;
}
{
if (sel == selection_)
return;
- //theSelection.clear();
- Anchor_ = Cursor_;
+ //clear();
+ Anchor_ = Cursor_;
selection_ = sel;
}
void MathCursor::selStart()
{
dump("selStart 1");
- //theSelection.clear();
+ //clear();
Anchor_ = Cursor_;
selection_ = true;
dump("selStart 2");
}
-void MathCursor::selClear()
-{
- dump("selClear 1");
- selection_ = false;
- dump("selClear 2");
-}
-
-
void MathCursor::selClearOrDel()
{
if (lyxrc.auto_region_delete)
selDel();
else
- selClear();
+ selection_ = false;
}
void MathCursor::selGet(MathArray & ar)
{
dump("selGet");
- if (!selection_)
- return;
-
- theSelection.grab(*this);
- ar = theSelection.glue();
+ if (selection_)
+ ar = grabSelection().glue();
}
void MathCursor::handleNest(MathInset * p)
{
- if (selection_) {
- selCut();
- p->cell(0) = theSelection.glue();
- }
+ p->cell(0) = grabAndEraseSelection().glue();
insert(MathAtom(p)); // this invalidates p!
pushRight(prevAtom());
}
MathGridInset * MathCursor::enclosingGrid(MathCursor::idx_type & idx) const
{
- for (MathInset::difference_type i = Cursor_.size() - 1; i >= 0; --i) {
+ for (MathInset::difference_type i = depth() - 1; i >= 0; --i) {
MathGridInset * p = Cursor_[i].par_->asGridInset();
if (p) {
idx = Cursor_[i].idx_;
return p;
- lyxerr << "found grid and idx: " << idx << "\n";
+ }
+ }
+ return 0;
+}
+
+
+MathHullInset * MathCursor::enclosingHull(MathCursor::idx_type & idx) const
+{
+ for (MathInset::difference_type i = depth() - 1; i >= 0; --i) {
+ MathHullInset * p = Cursor_[i].par_->asHullInset();
+ if (p) {
+ idx = Cursor_[i].idx_;
+ return p;
}
}
return 0;
void MathCursor::popToEnclosingGrid()
{
- while (Cursor_.size() && !Cursor_.back().par_->asGridInset())
+ while (depth() && !Cursor_.back().par_->asGridInset())
+ Cursor_.pop_back();
+}
+
+
+void MathCursor::popToEnclosingHull()
+{
+ while (depth() && !Cursor_.back().par_->asHullInset())
Cursor_.pop_back();
}
// remove empty scripts if possible
if (1) {
for (pos_type i = 0; i < size(); ++i) {
- MathScriptInset * p = array().at(i)->asScriptInset();
+ MathScriptInset * p = array()[i]->asScriptInset();
if (p) {
p->removeEmptyScripts();
//if (p->empty())
MathCursor::col_type MathCursor::hullCol() const
{
- return Cursor_[0].par_->asGridInset()->col(Cursor_[0].idx_);
+ idx_type idx = 0;
+ MathHullInset * p = enclosingHull(idx);
+ return p->col(idx);
}
MathCursor::row_type MathCursor::hullRow() const
{
- return Cursor_[0].par_->asGridInset()->row(Cursor_[0].idx_);
+ idx_type idx = 0;
+ MathHullInset * p = enclosingHull(idx);
+ return p->row(idx);
}
MathAtom const & MathCursor::prevAtom() const
{
lyx::Assert(pos() > 0);
- return array().at(pos() - 1);
+ return array()[pos() - 1];
}
MathAtom & MathCursor::prevAtom()
{
lyx::Assert(pos() > 0);
- return array().at(pos() - 1);
+ return array()[pos() - 1];
}
MathAtom const & MathCursor::nextAtom() const
{
lyx::Assert(pos() < size());
- return array().at(pos());
+ return array()[pos()];
}
MathAtom & MathCursor::nextAtom()
{
lyx::Assert(pos() < size());
- return array().at(pos());
+ return array()[pos()];
}
return dummy;
}
- if (Cursor_.size() == 0) {
- lyxerr << "############ Cursor_.size() == 0 not valid\n";
+ if (depth() == 0) {
+ lyxerr << "############ depth() == 0 not valid\n";
return dummy;
}
{
static MathXArray dummy;
- if (Cursor_.size() == 0) {
- lyxerr << "############ Cursor_.size() == 0 not valid\n";
+ if (depth() == 0) {
+ lyxerr << "############ depth() == 0 not valid\n";
return dummy;
}
while (popRight())
;
- MathHullInset * p = formula()->par()->asHullInset();
+ idx_type dummy;
+ MathHullInset * p = enclosingHull(dummy);
if (!p)
return;
if (p->getType() == LM_OT_SIMPLE || p->getType() == LM_OT_EQUATION) {
p->mutate(LM_OT_EQNARRAY);
- idx() = 0;
- pos() = size();
+ idx() = 1;
+ pos() = 0;
} else {
p->addRow(hullRow());
MathCursorPos & MathCursor::cursor()
{
- lyx::Assert(Cursor_.size());
+ lyx::Assert(depth());
return Cursor_.back();
}
MathCursorPos const & MathCursor::cursor() const
{
- lyx::Assert(Cursor_.size());
+ lyx::Assert(depth());
return Cursor_.back();
}
}
+bool MathCursor::idxLineFirst()
+{
+ idx() -= idx() % par()->ncols();
+ pos() = 0;
+ return true;
+}
+
+
+bool MathCursor::idxLineLast()
+{
+ idx() -= idx() % par()->ncols();
+ idx() += par()->ncols() - 1;
+ pos() = size();
+ return true;
+}
+
bool MathCursor::idxLeft()
{
return par()->idxLeft(idx(), pos());
return true;
//lyxerr << "char: '" << s[0] << "' int: " << int(s[0]) << endl;
- //owner_->getIntl()->getTrans().TranslateAndInsert(s[0], lt);
+ //owner_->getIntl()->getTransManager().TranslateAndInsert(s[0], lt);
//lyxerr << "trans: '" << s[0] << "' int: " << int(s[0]) << endl;
if (s.size() >= 5 && s.substr(0, 5) == "cases") {
}
macroModeClose();
- selCut();
+ MathGridInset safe = grabAndEraseSelection();
if (hasPrevAtom() && prevAtom()->asScriptInset()) {
prevAtom()->asScriptInset()->ensure(up);
pushRight(prevAtom());
idx() = up;
pos() = 0;
}
- selPaste();
+ paste(safe);
dump("1");
return true;
}
if (p && 1 <= n && n <= p->numargs())
insert(MathAtom(new MathMacroArgument(c - '0')));
else {
- insert(MathAtom(new MathSpecialCharInset('#')));
+ insert(createMathInset("#"));
interpret(c); // try again
}
return true;
// just clear selection on pressing the space par
if (selection_ && c == ' ') {
- selClear();
+ selection_ = false;
return true;
}
return true;
}
- if (c == '$' || c == '%') {
- insert(MathAtom(new MathSpecialCharInset(c)));
+ if (c == '$') {
+ insert(createMathInset("$"));
+ return true;
+ }
+
+ if (c == '%') {
+ insert(createMathInset("%"));
return true;
}
}
-
-MathCursorPos MathCursor::normalAnchor() const
-{
- if (Anchor_.size() < Cursor_.size()) {
- Anchor_ = Cursor_;
- lyxerr << "unusual Anchor size\n";
- dump("1");
- }
- //lyx::Assert(Anchor_.size() >= Cursor_.size());
- // use Anchor on the same level as Cursor
- MathCursorPos normal = Anchor_[Cursor_.size() - 1];
- if (Cursor_.size() < Anchor_.size() && !(normal < cursor())) {
- // anchor is behind cursor -> move anchor behind the inset
- ++normal.pos_;
- }
- return normal;
-}
-
-
-void MathCursor::stripFromLastEqualSign()
-{
- // find position of last '=' in the array
- MathArray & ar = cursor().cell();
- MathArray::const_iterator et = ar.end();
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
- if ((*it)->getChar() == '=')
- et = it;
-
- // delete everything behind this position
- ar.erase(et - ar.begin(), ar.size());
- pos() = ar.size();
-}
-
-
void MathCursor::setSelection(cursor_type const & where, size_type n)
{
selection_ = true;
{
ostringstream os;
os << "Math editor mode ";
- for (int i = 0, n = Cursor_.size(); i < n; ++i) {
+ for (int i = 0, n = depth(); i < n; ++i) {
Cursor_[i].par_->infoize(os);
os << " ";
}
os << " ";
return os.str().c_str(); // .c_str() needed for lyxstring
}
+
+
+unsigned MathCursor::depth() const
+{
+ return Cursor_.size();
+}
+
+
+
+
+namespace {
+
+void region(MathCursorPos const & i1, MathCursorPos const & i2,
+ MathInset::row_type & r1, MathInset::row_type & r2,
+ MathInset::col_type & c1, MathInset::col_type & c2)
+{
+ MathInset * p = i1.par_;
+ c1 = p->col(i1.idx_);
+ c2 = p->col(i2.idx_);
+ if (c1 > c2)
+ swap(c1, c2);
+ r1 = p->row(i1.idx_);
+ r2 = p->row(i2.idx_);
+ if (r1 > r2)
+ swap(r1, r2);
+}
+
+}
+
+
+MathGridInset MathCursor::grabSelection() const
+{
+ if (!selection_)
+ return MathGridInset();
+ MathCursorPos i1;
+ MathCursorPos i2;
+ getSelection(i1, i2);
+ // shouldn't we assert on i1.par_ == i2.par_?
+ if (i1.idx_ == i2.idx_) {
+ MathGridInset data(1, 1);
+ data.cell(0) = MathArray(i1.cell(), i1.pos_, i2.pos_);
+ return data;
+ }
+ row_type r1, r2;
+ col_type c1, c2;
+ region(i1, i2, r1, r2, c1, c2);
+ MathGridInset data(c2 - c1 + 1, r2 - r1 + 1);
+ for (row_type row = 0; row < data.nrows(); ++row)
+ for (col_type col = 0; col < data.ncols(); ++col) {
+ idx_type i = i1.par_->index(row + r1, col + c1);
+ data.cell(data.index(row, col)) = i1.par_->cell(i);
+ }
+ return data;
+}
+
+
+void MathCursor::eraseSelection()
+{
+ MathCursorPos i1;
+ MathCursorPos i2;
+ getSelection(i1, i2);
+ if (i1.idx_ == i2.idx_)
+ i1.cell().erase(i1.pos_, i2.pos_);
+ else {
+ MathInset * p = i1.par_;
+ row_type r1, r2;
+ col_type c1, c2;
+ region(i1, i2, r1, r2, c1, c2);
+ for (row_type row = r1; row <= r2; ++row)
+ for (col_type col = c1; col <= c2; ++col)
+ p->cell(p->index(row, col)).erase();
+ }
+ cursor() = i1;
+}
+
+
+MathGridInset MathCursor::grabAndEraseSelection()
+{
+ if (!selection_)
+ return MathGridInset();
+ MathGridInset res = grabSelection();
+ eraseSelection();
+ selection_ = false;
+ return res;
+}
+
+
+MathCursorPos MathCursor::normalAnchor() const
+{
+ if (Anchor_.size() < depth()) {
+ Anchor_ = Cursor_;
+ lyxerr << "unusual Anchor size\n";
+ }
+ //lyx::Assert(Anchor_.size() >= cursor.depth());
+ // use Anchor on the same level as Cursor
+ MathCursorPos normal = Anchor_[depth() - 1];
+ if (depth() < Anchor_.size() && !(normal < cursor())) {
+ // anchor is behind cursor -> move anchor behind the inset
+ ++normal.pos_;
+ }
+ return normal;
+}
+
+
+
+void MathCursor::handleExtern(const string & arg)
+{
+ string lang;
+ string extra;
+ istringstream iss(arg.c_str());
+ iss >> lang >> extra;
+ if (extra.empty())
+ extra = "noextra";
+
+
+ if (selection()) {
+ MathArray ar;
+ selGet(ar);
+ lyxerr << "use selection: " << ar << "\n";
+ insert(pipeThroughExtern(lang, extra, ar));
+ return;
+ }
+
+ MathArray eq;
+ eq.push_back(MathAtom(new MathCharInset('=')));
+
+ popToEnclosingHull();
+
+ idx_type idx = 0;
+ MathHullInset * hull = enclosingHull(idx);
+ lyx::Assert(hull);
+ idxLineFirst();
+
+ if (hull->getType() == LM_OT_SIMPLE) {
+ MathArray::size_type pos = cursor().cell().find_last(eq);
+ MathArray ar;
+ if (pos == size()) {
+ ar = array();
+ lyxerr << "use whole cell: " << ar << "\n";
+ } else {
+ ar = MathArray(array(), pos + 1, size());
+ lyxerr << "use partial cell form pos: " << pos << "\n";
+ }
+ end();
+ insert(eq);
+ insert(pipeThroughExtern(lang, extra, ar));
+ return;
+ }
+
+ if (hull->getType() == LM_OT_EQUATION) {
+ lyxerr << "use equation inset\n";
+ hull->mutate(LM_OT_EQNARRAY);
+ MathArray & ar = cursor().cell();
+ lyxerr << "use cell: " << ar << "\n";
+ idxRight();
+ cursor().cell() = eq;
+ idxRight();
+ cursor().cell() = pipeThroughExtern(lang, extra, ar);
+ idxLineLast();
+ return;
+ }
+
+ {
+ lyxerr << "use eqnarray\n";
+ idxLineLast();
+ MathArray ar = cursor().cell();
+ lyxerr << "use cell: " << ar << "\n";
+ breakLine();
+ idxRight();
+ cursor().cell() = eq;
+ idxRight();
+ cursor().cell() = pipeThroughExtern(lang, extra, ar);
+ idxLineLast();
+ }
+
+}
///
void paste(MathArray const &);
///
+ void paste(MathGridInset const & data);
+ ///
void erase();
///
void backspace();
/// current inset
MathInset * par() const;
/// return the next enclosing grid inset and the cursor's index in it
- MathGridInset * enclosingGrid(idx_type &) const;
- /// return the next enclosing grid inset and the cursor's index in it
+ MathGridInset * enclosingGrid(idx_type & idx) const;
+ /// return the next enclosing hull inset and the cursor's index in it
+ MathHullInset * enclosingHull(idx_type & idx) const;
+ /// go up to enclosing grid
void popToEnclosingGrid();
+ /// go up to the hull inset
+ void popToEnclosingHull();
///
InsetFormulaBase * formula();
/// current offset in the current cell
MathCursorPos & cursor();
/// reference to the last item of the path, i.e. "The Cursor"
MathCursorPos const & cursor() const;
+ /// how deep are we nested?
+ unsigned depth() const;
/// describe the situation
string info() const;
void seldump(char const * str) const;
/// dump selection information for debugging
void dump(char const * str) const;
- ///
- void stripFromLastEqualSign();
/// moves on
void setSelection(cursor_type const & where, size_type n);
///
/// hack for reveal codes
void markInsert();
void markErase();
+ void handleExtern(string const & arg);
///
friend class Selection;
+
private:
- /// moves cursor position one cell to the left
- bool posLeft();
- /// moves cursor position one cell to the right
- bool posRight();
/// moves cursor index one cell to the left
bool idxLeft();
/// moves cursor index one cell to the right
bool idxRight();
+ /// moves cursor to beginning first cell of current line
+ bool idxLineFirst();
+ /// moves cursor to end of last cell of current line
+ bool idxLineLast();
+ /// moves cursor position one cell to the left
+ bool posLeft();
+ /// moves cursor position one cell to the right
+ bool posRight();
/// moves position somehow up or down
bool goUpDown(bool up);
/// moves position into box
bool bruteFind(int xo, int yo, int xlow, int xhigh, int ylow, int yhigh);
+
+ /// grab grid marked by anchor and current cursor
+ MathGridInset grabSelection() const;
+ /// erase the selected part and re-sets the cursor
+ void eraseSelection();
+ /// guess what
+ MathGridInset grabAndEraseSelection();
+
///
string macroName() const;
///
/// write access to cursor cell index
idx_type & idx();
- /// path of positions the cursor had to go if it were leving each inset
+ /// path of positions the cursor had to go if it were leaving each inset
cursor_type Cursor_;
- /// path of positions the anchor had to go if it were leving each inset
+ /// path of positions the anchor had to go if it were leaving each inset
mutable cursor_type Anchor_;
/// pointer to enclsing LyX inset
InsetFormulaBase * formula_;
void MathArray::replace(ReplaceData & rep)
{
for (size_type i = 0; i < size(); ++i) {
- iterator it = begin() + i;
- const_iterator rt = rep.from.begin();
- const_iterator et = rep.from.end();
- for (const_iterator jt = it; jt != end() && rt != et; ++jt, ++rt)
- if (!jt->nucleus()->match(rt->nucleus()))
- break;
- if (rt == et) {
+ if (find1(rep.from, i)) {
// match found
lyxerr << "match found!\n";
- erase(it, it + rep.from.size());
+ erase(i, i + rep.from.size());
insert(i, rep.to);
}
}
}
-bool MathArray::contains(MathArray const & ar) const
+bool MathArray::find1(MathArray const & ar, size_type pos) const
{
- for (size_type i = 0; i + ar.size() <= size(); ++i) {
- const_iterator it = begin() + i;
- const_iterator rt = ar.begin();
- const_iterator et = ar.end();
- for (const_iterator jt = it; rt != et; ++jt, ++rt)
- if (!jt->nucleus()->match(rt->nucleus()))
- break;
- if (rt == et)
- return true;
- }
+ //lyxerr << "finding '" << ar << "' in '" << *this << "'\n";
+ for (size_type i = 0, n = ar.size(); i < n; ++i)
+ if (!at(pos + i)->match(ar[i].nucleus()))
+ return false;
+ return true;
+}
+
+
+MathArray::size_type MathArray::find(MathArray const & ar) const
+{
+ for (int i = 0, last = size() - ar.size(); i < last; ++i)
+ if (find1(ar, i))
+ return i;
+ return size();
+}
+
+
+MathArray::size_type MathArray::find_last(MathArray const & ar) const
+{
+ for (int i = size() - ar.size(); i >= 0; --i)
+ if (find1(ar, i))
+ return i;
+ return size();
+}
+
+bool MathArray::contains(MathArray const & ar) const
+{
+ if (find(ar) != size())
+ return true;
for (const_iterator it = begin(); it != end(); ++it)
if (it->nucleus()->contains(ar))
return true;
-
return false;
}
///
MathArray();
///
- MathArray(MathArray const &, size_type from, size_type to);
+ MathArray(MathArray const & ar, size_type from, size_type to);
///
MathArray(iterator from, iterator to);
///
void swap(MathArray &);
- ///
- void insert(size_type pos, MathAtom const &);
- ///
- void insert(size_type pos, MathArray const &);
+ /// inserts single atom at position pos
+ void insert(size_type pos, MathAtom const & at);
+ /// inserts multiple atoms at position pos
+ void insert(size_type pos, MathArray const & ar);
- ///
+ /// erase range from pos1 to pos2
void erase(iterator pos1, iterator pos2);
- ///
+ /// erase single atom
void erase(iterator pos);
- ///
+ /// erase range from pos1 to pos2
void erase(size_type pos1, size_type pos2);
- ///
+ /// erase single atom
void erase(size_type pos);
- ///
+ /// erase everythng
void erase();
///
- void push_back(MathAtom const &);
+ void push_back(MathAtom const & at);
///
- void push_back(MathArray const &);
+ void push_back(MathArray const & ar);
///
void pop_back();
///
///
void dump2() const;
///
- void substitute(MathMacro const &);
- /// looks for exact match
- bool match(MathArray const &) const;
- /// looks for inclusion match starting at pos
- bool matchpart(MathArray const &, pos_type pos) const;
- /// looks for containment
- bool contains(MathArray const &) const;
+ void substitute(MathMacro const & macro);
///
void replace(ReplaceData &);
+ /// looks for exact match
+ bool match(MathArray const & ar) const;
+ /// looks for inclusion match starting at pos
+ bool matchpart(MathArray const & ar, pos_type pos) const;
+ /// looks for containment, return == size mean not found
+ size_type find(MathArray const & ar) const;
+ /// looks for containment, return == size mean not found
+ size_type find_last(MathArray const & ar) const;
///
- MathAtom & at(size_type pos);
- ///
- MathAtom const & at(size_type pos) const;
- ///
- void validate(LaTeXFeatures &) const;
+ bool contains(MathArray const & ar) const;
+
+ /// write acccess to single atom
+ MathAtom & operator[](size_type pos) { return at(pos); }
+ /// read access o single atom
+ MathAtom const & operator[](size_type pos) const { return at(pos); }
///
const_iterator begin() const;
///
///
iterator end();
+ ///
+ void validate(LaTeXFeatures &) const;
+
private:
+ /// is this an exact match at this position?
+ bool find1(MathArray const & ar, size_type pos) const;
+ /// write acccess to single atom
+ MathAtom & at(size_type pos);
+ /// read access o single atom
+ MathAtom const & at(size_type pos) const;
+
/// Buffer
buffer_type bf_;
};
// information" from the unstructered layout-oriented stuff in an
// MathArray.
-#include <algorithm>
+#include <config.h>
#include "math_amsarrayinset.h"
+#include "math_arrayinset.h"
#include "math_charinset.h"
#include "math_deliminset.h"
#include "math_diffinset.h"
#include "math_fracinset.h"
#include "math_matrixinset.h"
#include "math_mathmlstream.h"
+#include "math_numberinset.h"
#include "math_scriptinset.h"
#include "math_stringinset.h"
#include "math_symbolinset.h"
#include "math_unknowninset.h"
+#include "math_parser.h"
#include "Lsstream.h"
#include "debug.h"
+#include "support/lyxlib.h"
+#include "support/systemcall.h"
+#include "support/filetools.h"
+#include <algorithm>
using std::ostream;
using std::istringstream;
using std::find_if;
+using std::endl;
ostream & operator<<(ostream & os, MathArray const & ar)
// returns sequence of char with same code starting at it up to end
// it might be less, though...
-MathArray::const_iterator charSequence(MathArray::const_iterator it,
- MathArray::const_iterator end, string & s)
+string charSequence
+ (MathArray::const_iterator it, MathArray::const_iterator end)
{
+ string s;
for (; it != end && (*it)->asCharInset(); ++it)
s += (*it)->getChar();
- return it;
+ return s;
}
{
//lyxerr << "\nStrings from: " << ar << "\n";
for (MathArray::size_type i = 0; i < ar.size(); ++i) {
- MathArray::iterator it = ar.begin() + i;
- if (!(*it)->asCharInset())
+ if (!ar[i]->asCharInset())
continue;
-
- // create proper string inset
- MathStringInset * p = new MathStringInset;
- MathArray::const_iterator
- jt = charSequence(it, ar.end(), p->str_);
-
- // clean up
- (*it).reset(p);
- ar.erase(i + 1, jt - ar.begin());
+ string s = charSequence(ar.begin() + i, ar.end());
+ ar[i].reset(new MathStringInset(s));
+ ar.erase(i + 1, i + s.size());
}
//lyxerr << "\nStrings to: " << ar << "\n";
}
// convert this inset somehow to a number
bool extractNumber(MathArray const & ar, int & i)
{
- string s;
- charSequence(ar.begin(), ar.end(), s);
- istringstream is(s.c_str());
+ istringstream is(charSequence(ar.begin(), ar.end()).c_str());
is >> i;
return is;
}
-bool extractNumber(MathArray const & ar, double & i)
+bool extractNumber(MathArray const & ar, double & d)
{
- string s;
- charSequence(ar.begin(), ar.end(), s);
- istringstream is(s.c_str());
- is >> i;
+ istringstream is(charSequence(ar.begin(), ar.end()).c_str());
+ is >> d;
return is;
}
}
+//
+// search numbers
+//
+
+bool isDigitOrSimilar(char c)
+{
+ return ('0' <= c && c <= '9') || c == '.';
+}
+
+
+// returns sequence of digits
+string digitSequence
+ (MathArray::const_iterator it, MathArray::const_iterator end)
+{
+ string s;
+ for (; it != end && (*it)->asCharInset(); ++it) {
+ if (!isDigitOrSimilar((*it)->getChar()))
+ break;
+ s += (*it)->getChar();
+ }
+ return s;
+}
+
+
+void extractNumbers(MathArray & ar)
+{
+ //lyxerr << "\nNumbers from: " << ar << "\n";
+ for (MathArray::size_type i = 0; i < ar.size(); ++i) {
+ if (!ar[i]->asCharInset())
+ continue;
+ if (!isDigitOrSimilar(ar[i]->asCharInset()->getChar()))
+ continue;
+
+ string s = digitSequence(ar.begin() + i, ar.end());
+
+ ar[i].reset(new MathNumberInset(s));
+ ar.erase(i + 1, i + s.size());
+ }
+ //lyxerr << "\nNumbers to: " << ar << "\n";
+}
+
+
+
//
// search deliminiters
//
MathArray::iterator jt = it + 1;
//int n = 1;
MathArray & numer = f->cell(0);
- if (numer.size() > 1 && numer.at(1)->asScriptInset()) {
+ if (numer.size() > 1 && numer[1]->asScriptInset()) {
// this is something like d^n f(x) / d... or d^n / d...
// FIXME
//n = 1;
void extractStructure(MathArray & ar)
{
splitScripts(ar);
+ extractNumbers(ar);
extractMatrices(ar);
extractDelims(ar);
extractFunctions(ar);
os << ETag("mrow");
}
}
+
+
+
+
+namespace {
+
+ string captureOutput(string const & cmd, string const & data)
+ {
+ string outfile = lyx::tempName(string(), "mathextern");
+ string full = "echo '" + data + "' | (" + cmd + ") > " + outfile;
+ lyxerr << "calling: " << full << endl;
+ Systemcall dummy;
+ dummy.startscript(Systemcall::Wait, full);
+ string out = GetFileContents(outfile);
+ lyx::unlink(outfile);
+ lyxerr << "result: '" << out << "'" << endl;
+ return out;
+ }
+
+
+ MathArray pipeThroughMaple(string const & extra, MathArray const & ar)
+ {
+ string header = "readlib(latex):\n";
+
+ // remove the \\it for variable names
+ //"#`latex/csname_font` := `\\it `:"
+ header +=
+ "`latex/csname_font` := ``:\n";
+
+ // export matrices in (...) instead of [...]
+ header +=
+ "`latex/latex/matrix` := "
+ "subs(`[`=`(`, `]`=`)`,"
+ "eval(`latex/latex/matrix`)):\n";
+
+ // replace \\cdots with proper '*'
+ header +=
+ "`latex/latex/*` := "
+ "subs(`\\,`=`\\cdot `,"
+ "eval(`latex/latex/*`)):\n";
+
+ // remove spurious \\noalign{\\medskip} in matrix output
+ header +=
+ "`latex/latex/matrix`:= "
+ "subs(`\\\\\\\\\\\\noalign{\\\\medskip}` = `\\\\\\\\`,"
+ "eval(`latex/latex/matrix`)):\n";
+
+ //"#`latex/latex/symbol` "
+ // " := subs((\\'_\\' = \\'`\\_`\\',eval(`latex/latex/symbol`)): ";
+
+ string trailer = "quit;";
+ ostringstream os;
+ MapleStream ms(os);
+ ms << ar;
+ string expr = os.str().c_str();
+ lyxerr << "ar: '" << ar << "'\n";
+
+ for (int i = 0; i < 100; ++i) { // at most 100 attempts
+ // try to fix missing '*' the hard way by using mint
+ //
+ // ... > echo "1A;" | mint -i 1 -S -s -q
+ // on line 1: 1A;
+ // ^ syntax error -
+ // Probably missing an operator such as * p
+ //
+ lyxerr << "checking expr: '" << expr << "'\n";
+ string out = captureOutput("mint -i 1 -S -s -q -q", expr + ";");
+ if (out.empty())
+ break; // expression syntax is ok
+ istringstream is(out.c_str());
+ string line;
+ getline(is, line);
+ if (line.find("on line") != 0)
+ break; // error message not identified
+ getline(is, line);
+ string::size_type pos = line.find('^');
+ if (pos == string::npos || pos < 15)
+ break; // caret position not found
+ pos -= 15; // skip the "on line ..." part
+ if (expr[pos] == '*' || (pos > 0 && expr[pos - 1] == '*'))
+ break; // two '*' in a row are definitely bad
+ expr.insert(pos, "*");
+ }
+
+ string full = "latex(" + extra + '(' + expr + "));";
+ string out = captureOutput("maple -q", header + full + trailer);
+
+ // change \_ into _
+
+ //
+ MathArray res;
+ mathed_parse_cell(res, out);
+ return res;
+ }
+
+
+ MathArray pipeThroughOctave(string const &, MathArray const & ar)
+ {
+ ostringstream os;
+ OctaveStream vs(os);
+ vs << ar;
+ string expr = os.str().c_str();
+ string out;
+
+ lyxerr << "pipe: ar: '" << ar << "'\n";
+ lyxerr << "pipe: expr: '" << expr << "'\n";
+
+ for (int i = 0; i < 100; ++i) { // at most 100 attempts
+ //
+ // try to fix missing '*' the hard way
+ // parse error:
+ // >>> ([[1 2 3 ];[2 3 1 ];[3 1 2 ]])([[1 2 3 ];[2 3 1 ];[3 1 2 ]])
+ // ^
+ //
+ lyxerr << "checking expr: '" << expr << "'\n";
+ out = captureOutput("octave -q 2>&1", expr);
+ lyxerr << "checking out: '" << out << "'\n";
+
+ // leave loop if expression syntax is probably ok
+ if (out.find("parse error:") == string::npos)
+ break;
+
+ // search line with single caret
+ istringstream is(out.c_str());
+ string line;
+ while (is) {
+ getline(is, line);
+ lyxerr << "skipping line: '" << line << "'\n";
+ if (line.find(">>> ") != string::npos)
+ break;
+ }
+
+ // found line with error, next line is the one with caret
+ getline(is, line);
+ string::size_type pos = line.find('^');
+ lyxerr << "caret line: '" << line << "'\n";
+ lyxerr << "found caret at pos: '" << pos << "'\n";
+ if (pos == string::npos || pos < 4)
+ break; // caret position not found
+ pos -= 4; // skip the ">>> " part
+ if (expr[pos] == '*')
+ break; // two '*' in a row are definitely bad
+ expr.insert(pos, "*");
+ }
+
+ if (out.size() < 6)
+ return MathArray();
+
+ // remove 'ans = '
+ out = out.substr(6);
+
+ // parse output as matrix or single number
+ MathAtom at(new MathArrayInset("array", out));
+ MathArrayInset const * mat = at.nucleus()->asArrayInset();
+ MathArray res;
+ if (mat->ncols() == 1 && mat->nrows() == 1)
+ res.push_back(mat->cell(0));
+ else {
+ res.push_back(MathAtom(new MathDelimInset("(", ")")));
+ res.back()->cell(0).push_back(at);
+ }
+ return res;
+ }
+
+}
+
+
+MathArray pipeThroughExtern(string const & lang, string const & extra,
+ MathArray const & ar)
+{
+ if (lang == "octave")
+ return pipeThroughOctave(extra, ar);
+
+ if (lang == "maple")
+ return pipeThroughMaple(extra, ar);
+
+ // create normalized expression
+ ostringstream os;
+ NormalStream ns(os);
+ os << "[" << extra << ' ';
+ ns << ar;
+ os << "]";
+ string data = os.str().c_str();
+
+ // search external script
+ string file = LibFileSearch("mathed", "extern_" + lang);
+ if (file.empty()) {
+ lyxerr << "converter to '" << lang << "' not found\n";
+ return MathArray();
+ }
+
+ // run external sript
+ string out = captureOutput(file, data);
+ MathArray res;
+ mathed_parse_cell(res, out);
+ return res;
+}
#ifndef MATH_EXTERN_H
#define MATH_EXTERN_H
+#include "LString.h"
+
class NormalStream;
class MapleStream;
class MathMLStream;
bool extractNumber(MathArray const & ar, int & i);
bool extractNumber(MathArray const & ar, double & i);
+MathArray pipeThroughExtern(string const & lang, string const & extra,
+ MathArray const & ar);
+
#endif
#include "math_decorationinset.h"
#include "math_dotsinset.h"
#include "math_fontinset.h"
-#include "math_funcliminset.h"
#include "math_fracinset.h"
#include "math_kerninset.h"
#include "math_lefteqninset.h"
#include "math_sizeinset.h"
#include "math_spaceinset.h"
#include "math_splitinset.h"
-#include "math_specialcharinset.h"
#include "math_sqrtinset.h"
#include "math_stackrelinset.h"
#include "math_substackinset.h"
#include "math_xymatrixinset.h"
#include "math_xyarrowinset.h"
-
#include "math_metricsinfo.h"
#include "debug.h"
#include "math_support.h"
#include "Lsstream.h"
#include "support/filetools.h" // LibFileSearch
+#include "frontends/font_loader.h"
#include <map>
#include <fstream>
struct key_type {
///
- char const * name;
+ string name;
///
- char const * inset;
+ string inset;
///
int id;
};
key_type wordlist_array[] =
{
{"!", "space", 0},
- {"#", "special", 0},
- {"$", "special", 0},
- {"%", "special", 0},
- {"&", "special", 0},
{"(", "begin", LM_OT_SIMPLE},
{")", "end", LM_OT_SIMPLE},
{",", "space", 1},
- {".", "special", 0},
{":", "space", 2},
{";", "space", 3},
- {"Pr", "funclim", 0},
{"[", "begin", LM_OT_EQUATION},
{"]", "end", LM_OT_EQUATION},
- {"_", "special", '_'},
{"acute", "decoration", 0},
- {"arccos", "func", 0},
- {"arcsin", "func", 0},
- {"arctan", "func", 0},
- {"arg", "func", 0},
{"bar", "decoration", 0},
{"begin", "begin", 0},
{"bf", "oldfont", 0},
- {"bmod", "func", 0},
{"breve", "decoration", 0},
{"cal", "oldfont", 0},
{"cdots", "dots", 0},
{"check", "decoration", 0},
- {"cos", "func", 0},
- {"cosh", "func", 0},
- {"cot", "func", 0},
- {"coth", "func", 0},
- {"csc", "func", 0},
{"ddot", "decoration", 0},
{"dddot", "decoration", 0},
{"ddots", "dots", 0},
- {"deg", "func", 0},
- {"det", "funclim", 0},
- {"dim", "func", 0},
{"displaystyle", "style", LM_ST_DISPLAY},
{"dot", "decoration", 0},
{"dotsb", "dots", 0},
{"dotsm", "dots", 0},
{"dotso", "dots", 0},
{"end", "end", 0},
- {"exp", "func", 0},
{"frak", "font", 0},
- {"gcd", "funclim", 0},
{"grave", "decoration", 0},
{"hat", "decoration", 0},
- {"hom", "func", 0},
- {"inf", "funclim", 0},
{"it", "oldfont", 0},
- {"ker", "func", 0},
{"label", "label", 0},
{"ldots", "dots", 0},
{"left", "left", 0},
- {"lg", "func", 0},
- {"lim", "funclim", 0},
- {"liminf", "funclim", 0},
{"limits", "limit", 1 },
- {"limsup", "funclim", 0},
- {"ln", "func", 0},
- {"log", "func", 0},
{"lyxbox", "box", 0},
{"lyxnegspace", "space", 6},
{"mathbb", "font", 0},
{"mathrm", "font", 0},
{"mathsf", "font", 0},
{"mathtt", "font", 0},
- {"max", "funclim", 0},
{"mbox", "box", 0},
- {"min", "funclim", 0},
{"newcommand", "newcommand", 0 },
{"nolimits", "limit", -1},
{"nonumber", "nonum", 0},
{"rm", "oldfont", 0},
{"scriptscriptstyle", "style", LM_ST_SCRIPTSCRIPT},
{"scriptstyle", "style", LM_ST_SCRIPT},
- {"sec", "func", 0},
- {"sin", "func", 0},
- {"sinh", "func", 0},
- {"sup", "funclim", 0},
- {"tan", "func", 0},
- {"tanh", "func", 0},
{"textbf", "font", 1},
{"textit", "font", 1},
{"textmd", "font", 1},
{"vdots", "dots", 0},
{"vec", "decoration", 0},
{"widehat", "decoration", 0},
- {"widetilde", "decoration", 0},
- {"{", "special", '{'},
- {"}", "special", '}'}
+ {"widetilde", "decoration", 0}
};
+bool math_font_available(string & name)
+{
+ LyXFont f;
+ augmentFont(f, name);
+
+ // Do we have the font proper?
+ if (fontloader.available(f))
+ return true;
+
+ // can we fake it?
+ if (name == "eufrak") {
+ name = "lyxfakefrak";
+ return true;
+ }
+
+ lyxerr << "font " << name << " not available and I can't fake it\n";
+ return false;
+}
+
void readSymbols(string const & filename)
{
continue;
// tmp.inset _is_ the fontname here.
- if (math_font_available(tmp.inset)) {
+ // create fallbacks if necessary
+ if (tmp.extra == "func" || tmp.extra == "funclim" || tmp.extra=="special") {
+ lyxerr[Debug::MATHED] << "symbol abuse for " << tmp.name << "\n";
+ tmp.draw = tmp.name;
+ } else if (math_font_available(tmp.inset)) {
+ lyxerr[Debug::MATHED] << "symbol available for " << tmp.name << "\n";
tmp.draw += char(charid);
- } else {
+ } else if (fallbackid) {
if (tmp.inset == "cmex")
- tmp.inset = "lyxsymb";
+ tmp.inset = "lyxsymbol";
else
- tmp.inset = "lyxboldsymb";
+ tmp.inset = "lyxboldsymbol";
+ lyxerr[Debug::MATHED] << "symbol fallback for " << tmp.name << "\n";
tmp.draw += char(fallbackid);
+ } else {
+ lyxerr[Debug::MATHED] << "faking " << tmp.name << "\n";
+ tmp.draw = tmp.name;
+ tmp.inset = "lyxredtext";
}
if (theWordList.find(tmp.name) != theWordList.end())
latexkeys const * l = in_word_set(s);
if (l) {
string const & inset = l->inset;
- lyxerr[Debug::MATHED] << " fount inset: '" << inset << "'\n";
- if (inset == "funclim")
- return MathAtom(new MathFuncLimInset(s));
- if (inset == "special")
- return MathAtom(new MathSpecialCharInset(s[0]));
- if (inset == "lyxsym" ||
- inset == "cmr" ||
- inset == "cmsy" ||
- inset == "cmm" ||
- inset == "cmex" ||
- inset == "msa" ||
- inset == "msb")
- return MathAtom(new MathSymbolInset(l));
+ lyxerr[Debug::MATHED] << " found inset: '" << inset << "'\n";
if (inset == "underset")
return MathAtom(new MathUndersetInset);
if (inset == "decoration")
return MathAtom(new MathFontInset(l->name));
if (inset == "oldfont")
return MathAtom(new MathFontInset(l->name));
- if (inset == "func")
- return MathAtom(new MathUnknownInset(l->name, true, true));
-
- return MathAtom(new MathUnknownInset(l->name));
+ return MathAtom(new MathSymbolInset(l));
}
if (MathMacroTable::has(s))
{
MathFontSetChanger dummy(mi.base, name_.c_str());
xcell(0).metrics(mi);
- width_ = xcell(0).width() + 6;
ascent_ = xcell(0).ascent();
- descent_ = xcell(0).descent() + 3;
+ descent_ = xcell(0).descent() + 2;
+ width_ = xcell(0).width() + 2;
}
void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
{
//lyxerr << "MathFontInset::draw\n";
- MathNestInset::draw(pi, x, y);
+ //MathNestInset::draw(pi, x, y);
MathFontSetChanger dummy(pi.base, name_.c_str());
- xcell(0).draw(pi, x + 3, y);
- int b = x + 1;
- int t = x + width() - 1;
- int d = y + descent();
- pi.pain.line(b, d - 3, b, d, LColor::mathframe);
- pi.pain.line(t, d - 3, t, d, LColor::mathframe);
- pi.pain.line(b, d, b + 3, d, LColor::mathframe);
- pi.pain.line(t - 2, d, t, d, LColor::mathframe);
+ xcell(0).draw(pi, x + 1, y);
+ if (editing()) {
+ int t = x + width() - 1;
+ int d = y + descent();
+ pi.pain.line(x, d - 3, x, d, LColor::mathframe);
+ pi.pain.line(t, d - 3, t, d, LColor::mathframe);
+ pi.pain.line(x, d, x + 3, d, LColor::mathframe);
+ pi.pain.line(t - 2, d, t, d, LColor::mathframe);
+ }
}
}
+//////////////////////////////////////////////////////////////
+
+
+MathGridInset::CellInfo::CellInfo()
+ : dummy_(false)
+{}
+
+
+
//////////////////////////////////////////////////////////////
MathGridInset::MathGridInset(char v, string const & h)
- : MathNestInset(guessColumns(h)), rowinfo_(2), colinfo_(guessColumns(h) + 1)
+ : MathNestInset(guessColumns(h)),
+ rowinfo_(2),
+ colinfo_(guessColumns(h) + 1),
+ cellinfo_(1 * guessColumns(h))
{
setDefaults();
valign(v);
}
+MathGridInset::MathGridInset()
+ : MathNestInset(1),
+ rowinfo_(1 + 1),
+ colinfo_(1 + 1),
+ cellinfo_(1),
+ v_align_('c')
+{
+ setDefaults();
+}
+
+
MathGridInset::MathGridInset(col_type m, row_type n)
- : MathNestInset(m * n), rowinfo_(n + 1), colinfo_(m + 1), v_align_('c')
+ : MathNestInset(m * n),
+ rowinfo_(n + 1),
+ colinfo_(m + 1),
+ cellinfo_(m * n),
+ v_align_('c')
{
setDefaults();
}
MathGridInset::MathGridInset(col_type m, row_type n, char v, string const & h)
- : MathNestInset(m * n), rowinfo_(n + 1), colinfo_(m + 1), v_align_(v)
+ : MathNestInset(m * n),
+ rowinfo_(n + 1),
+ colinfo_(m + 1),
+ cellinfo_(m * n),
+ v_align_(v)
{
setDefaults();
valign(v);
}
-void MathGridInset::draw(MathPainterInfo & pain, int x, int y) const
+void MathGridInset::draw(MathPainterInfo & pi, int x, int y) const
{
for (idx_type idx = 0; idx < nargs(); ++idx)
- xcell(idx).draw(pain, x + cellXOffset(idx), y + cellYOffset(idx));
+ xcell(idx).draw(pi, x + cellXOffset(idx), y + cellYOffset(idx));
for (row_type row = 0; row <= nrows(); ++row)
for (int i = 0; i < rowinfo_[row].lines_; ++i) {
int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
- i * hlinesep() - hlinesep()/2 - rowsep()/2;
- pain.pain.line(x + 1, yy, x + width_ - 1, yy);
+ pi.pain.line(x + 1, yy, x + width_ - 1, yy);
}
for (col_type col = 0; col <= ncols(); ++col)
for (int i = 0; i < colinfo_[col].lines_; ++i) {
int xx = x + colinfo_[col].offset_
- i * vlinesep() - vlinesep()/2 - colsep()/2;
- pain.pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1);
+ pi.pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1);
}
}
void MathGridInset::addRow(row_type row)
{
rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
- cells_.insert(cells_.begin() + (row + 1) * ncols(), ncols(), MathXArray());
+ cells_.insert
+ (cells_.begin() + (row + 1) * ncols(), ncols(), MathXArray());
+ cellinfo_.insert
+ (cellinfo_.begin() + (row + 1) * ncols(), ncols(), CellInfo());
}
{
rowinfo_.push_back(RowInfo());
//cells_.insert(cells_.end(), ncols(), MathXArray());
- for (col_type col = 0; col < ncols(); ++col)
+ for (col_type col = 0; col < ncols(); ++col) {
cells_.push_back(cells_type::value_type());
+ cellinfo_.push_back(CellInfo());
+ }
}
cells_type::iterator it = cells_.begin() + row * ncols();
cells_.erase(it, it + ncols());
+ vector<CellInfo>::iterator jt = cellinfo_.begin() + row * ncols();
+ cellinfo_.erase(jt, jt + ncols());
+
rowinfo_.erase(rowinfo_.begin() + row);
}
const col_type nc = ncols();
const row_type nr = nrows();
cells_type new_cells((nc + 1) * nr);
+ vector<CellInfo> new_cellinfo((nc + 1) * nr);
for (row_type row = 0; row < nr; ++row)
- for (col_type col = 0; col < nc; ++col)
+ for (col_type col = 0; col < nc; ++col) {
new_cells[row * (nc + 1) + col + (col > newcol)]
= cells_[row * nc + col];
+ new_cellinfo[row * (nc + 1) + col + (col > newcol)]
+ = cellinfo_[row * nc + col];
+ }
swap(cells_, new_cells);
+ swap(cellinfo_, new_cellinfo);
ColInfo inf;
inf.skip_ = defaultColSpace(newcol);
return;
cells_type tmpcells;
+ vector<CellInfo> tmpcellinfo;
for (col_type i = 0; i < nargs(); ++i)
- if (i % ncols() != col)
+ if (i % ncols() != col) {
tmpcells.push_back(cells_[i]);
+ tmpcellinfo.push_back(cellinfo_[i]);
+ }
swap(cells_, tmpcells);
+ swap(cellinfo_, tmpcellinfo);
colinfo_.erase(colinfo_.begin() + col);
}
os << eolString(row);
}
string const s = verboseHLine(rowinfo_[nrows()].lines_);
- if (!s.empty() && s != " ")
+ if (!s.empty() && s != " ") {
+ if (os.fragile())
+ os << "\\protect";
os << "\\\\" << s;
+ }
}
{
return 1;
}
+
class MathGridInset : public MathNestInset {
+ /// additional per-cell information
+ struct CellInfo {
+ ///
+ CellInfo();
+ /// a dummy cell before a multicolumn cell
+ int dummy_;
+ /// special multi colums alignment
+ string align_;
+ };
+
/// additional per-row information
struct RowInfo {
///
};
public:
+ /// sets nrows and ncols to 1
+ MathGridInset();
/// constructor from columns description, creates one row
MathGridInset(char valign, string const & halign);
/// Note: columns first!
const RowInfo & rowinfo(row_type row) const;
/// returns topmost row if passed (-1)
RowInfo & rowinfo(row_type row);
+ ///
+ const CellInfo & cellinfo(idx_type idx) const { return cellinfo_[idx]; }
+ ///
+ CellInfo & cellinfo(idx_type idx) { return cellinfo_[idx]; }
/// identifies GridInset
virtual MathGridInset * asGridInset() { return this; }
std::vector<RowInfo> rowinfo_;
/// column info
std::vector<ColInfo> colinfo_;
+ /// cell info
+ std::vector<CellInfo> cellinfo_;
///
char v_align_; // add approp. type
};
}
+bool MathHullInset::idxFirst(idx_type & idx, pos_type & pos) const
+{
+ idx = 0;
+ pos = 0;
+ return true;
+}
+
+
+bool MathHullInset::idxLast(idx_type & idx, pos_type & pos) const
+{
+ idx = nargs() - 1;
+ pos = cell(idx).size();
+ return true;
+}
+
+
char MathHullInset::defaultColAlign(col_type col)
{
switch (getType()) {
int defaultColSpace(col_type col);
///
char defaultColAlign(col_type col);
+ ///
+ bool idxFirst(idx_type &, pos_type &) const;
+ ///
+ bool idxLast(idx_type &, pos_type &) const;
///
MathInsetTypes getType() const;
class MathCharInset;
class MathDelimInset;
class MathFontInset;
-class MathFuncInset;
class MathGridInset;
class MathFracInset;
class MathHullInset;
virtual MathDelimInset * asDelimInset() { return 0; }
virtual MathDelimInset const * asDelimInset() const { return 0; }
virtual MathFontInset const * asFontInset() const { return 0; }
- virtual MathFuncInset * asFuncInset() { return 0; }
virtual MathFracInset * asFracInset() { return 0; }
virtual MathGridInset * asGridInset() { return 0; }
virtual MathHullInset * asHullInset() { return 0; }
}
-void MathNestInset::draw(MathPainterInfo & pi, int x, int y) const
+//void MathNestInset::draw(MathPainterInfo & pi, int x, int y) const
+void MathNestInset::draw(MathPainterInfo &, int, int) const
{
+#if 0
if (lock_)
pi.pain.fillRectangle(x, y - ascent(), width(), height(),
LColor::mathlockbg);
+#endif
}
{
return nargs() > 0;
}
+
+
+MathArray MathNestInset::glue() const
+{
+ MathArray ar;
+ for (unsigned i = 0; i < nargs(); ++i)
+ ar.push_back(cell(i));
+ return ar;
+}
void replace(ReplaceData &);
/// do we contain a given pattern?
bool contains(MathArray const &);
+ /// glue everything to a single cell
+ MathArray glue() const;
/// debug helper
void dump() const;
void MathNotInset::metrics(MathMetricsInfo & mi) const
{
font_ = mi.base.font;
- if (math_font_available("cmsy")) {
- augmentFont(font_, "cmsy");
- char_ = 54;
- } else {
+// if (math_font_available("cmsy")) {
+// augmentFont(font_, "cmsy");
+// char_ = 54;
+// } else {
augmentFont(font_, "mathnormal");
char_ = '/';
- }
+// }
mathed_char_dim(font_, char_, ascent_, descent_, width_);
width_ = 0;
}
--- /dev/null
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_numberinset.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "math_support.h"
+#include "debug.h"
+
+
+MathNumberInset::MathNumberInset(string const & s)
+ : str_(s)
+{}
+
+
+MathInset * MathNumberInset::clone() const
+{
+ return new MathNumberInset(*this);
+}
+
+
+void MathNumberInset::metrics(MathMetricsInfo & mi) const
+{
+ mathed_string_dim(mi.base.font, str_, ascent_, descent_, width_);
+}
+
+
+void MathNumberInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+ //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
+ drawStr(pi, pi.base.font, x, y, str_);
+}
+
+
+void MathNumberInset::normalize(NormalStream & os) const
+{
+ os << "[number " << str_ << "]";
+}
+
+
+void MathNumberInset::maplize(MapleStream & os) const
+{
+ os << str_;
+}
+
+
+void MathNumberInset::octavize(OctaveStream & os) const
+{
+ os << str_;
+}
+
+
+void MathNumberInset::mathmlize(MathMLStream & os) const
+{
+ os << "<mi> " << str_ << " </mi>";
+}
+
+
+void MathNumberInset::write(WriteStream & os) const
+{
+ os << str_;
+}
--- /dev/null
+// -*- C++ -*-
+#ifndef MATH_NUMBERINSET_H
+#define MATH_NUMBERINSET_H
+
+#include "math_diminset.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Some inset that "is" a number
+ * maily for math-extern
+ * \author André Pönitz
+ */
+
+class MathNumberInset : public MathDimInset {
+public:
+ ///
+ explicit MathNumberInset(string const & s);
+ ///
+ MathInset * clone() const;
+ ///
+ void metrics(MathMetricsInfo & st) const;
+ ///
+ void draw(MathPainterInfo &, int x, int y) const;
+ ///
+ string str() const { return str_; }
+ ///
+ MathNumberInset * asNumberInset() { return this; }
+
+ ///
+ void normalize(NormalStream &) const;
+ ///
+ void octavize(OctaveStream &) const;
+ ///
+ void maplize(MapleStream &) const;
+ ///
+ void mathmlize(MathMLStream &) const;
+ ///
+ void write(WriteStream & os) const;
+
+private:
+ /// the number as string
+ string str_;
+};
+#endif
/*
-If someone desperately needs partial "structures" (such as a few cells of
-an array inset or similar) (s)he could uses the following hack as starting
-point to write some macros:
+If someone desperately needs partial "structures" (such as a few
+cells of an array inset or similar) (s)he could uses the
+following hack as starting point to write some macros:
\newif\ifcomment
\commentfalse
#include "math_boxinset.h"
#include "math_charinset.h"
#include "math_deliminset.h"
+#include "math_extern.h"
#include "math_factory.h"
#include "math_kerninset.h"
#include "math_macro.h"
#include "math_sizeinset.h"
#include "math_sqrtinset.h"
#include "math_scriptinset.h"
-#include "math_specialcharinset.h"
#include "math_sqrtinset.h"
#include "math_support.h"
#include "math_xyarrowinset.h"
using std::vector;
using std::atoi;
+
//#define FILEDEBUG
enum {
- FLAG_BRACE_LAST = 1 << 1, // last closing brace ends the parsing process
+ FLAG_BRACE_LAST = 1 << 1, // last closing brace ends the parsing
FLAG_RIGHT = 1 << 2, // next \\right ends the parsing process
FLAG_END = 1 << 3, // next \\end ends the parsing process
- FLAG_BRACK_END = 1 << 4, // next closing bracket ends the parsing process
- FLAG_TEXTMODE = 1 << 5, // we are in a box
+ FLAG_BRACK_END = 1 << 4, // next closing bracket ends the parsing
+ FLAG_TEXTMODE = 1 << 5, // we are in a box
FLAG_ITEM = 1 << 6, // read a (possibly braced token)
- FLAG_BLOCK = 1 << 7, // next block ends the parsing process
- FLAG_BLOCK2 = 1 << 8, // next block2 ends the parsing process
- FLAG_LEAVE = 1 << 9, // leave the loop at the end
- FLAG_SIMPLE = 1 << 10, // next $ leaves the loop
- FLAG_EQUATION = 1 << 11, // next \] leaves the loop
- FLAG_SIMPLE2 = 1 << 12 // next \) leaves the loop
+ FLAG_LEAVE = 1 << 7, // leave the loop at the end
+ FLAG_SIMPLE = 1 << 8, // next $ leaves the loop
+ FLAG_EQUATION = 1 << 9, // next \] leaves the loop
+ FLAG_SIMPLE2 = 1 << 10 // next \) leaves the loop
};
void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
{
- bool panic = false;
int limits = 0;
MathGridInset::row_type cellrow = 0;
MathGridInset::col_type cellcol = 0;
flags |= FLAG_LEAVE;
}
- if (flags & FLAG_BLOCK) {
- if (t.cat() == catAlign || t.isCR() || t.cs() == "end") {
- putback();
- return;
- }
- }
-
- if (flags & FLAG_BLOCK2) {
- if (t.cat() == catAlign || t.isCR() || t.cs() == "end"
- || t.cat() == catEnd) {
- putback();
- return;
- }
- }
-
//
// cat codes
//
// ignore \\protect, will be re-added during output
;
- else if (t.cs() == "end")
- break;
+ else if (t.cs() == "end") {
+ if (flags & FLAG_END) {
+ // eat environment name
+ //string const name =
+ getArg('{', '}');
+ // FIXME: check that we ended the correct environment
+ return;
+ }
+ lyxerr << "found 'end' unexpectedly, cell: '" << cell << "'\n";
+ dump();
+ }
else if (t.cs() == ")")
break;
cell = &grid.cell(grid.index(cellrow, cellcol));
}
+#if 1
+ else if (t.cs() == "multicolumn") {
+ // extract column count and insert dummy cells
+ MathArray count;
+ parse_into(count, FLAG_ITEM);
+ int cols = 1;
+ if (!extractNumber(count, cols)) {
+ lyxerr << " can't extract number of cells from " << count << "\n";
+ }
+ // resize the table if necessary
+ for (int i = 0; i < cols; ++i) {
+ ++cellcol;
+ if (cellcol == grid.ncols()) {
+ lyxerr << "adding column " << cellcol << "\n";
+ grid.addCol(cellcol - 1);
+ }
+ cell = &grid.cell(grid.index(cellrow, cellcol));
+ // mark this as dummy
+ grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = true;
+ }
+ // the last cell is the real thng, not a dummy
+ grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = false;
+
+ // read special alignment
+ MathArray align;
+ parse_into(align, FLAG_ITEM);
+ //grid.cellinfo(grid.index(cellrow, cellcol)).align_ = extractString(align);
+
+ // parse the remaining contents into the "real" cell
+ parse_into(*cell, FLAG_ITEM);
+ }
+#endif
+
else if (t.cs() == "limits")
limits = 1;
break;
}
}
-
- if (panic) {
- lyxerr << " Math Panic, expect problems!\n";
- // Search for the end command.
- Token t;
- do {
- t = getToken();
- } while (good() && t.cs() != "end");
- }
}
void MathScriptInset::metrics(MathInset const * nuc, MathMetricsInfo & mi) const
{
- MathScriptChanger dummy(mi.base);
- MathNestInset::metrics(mi);
if (nuc)
nuc->metrics(mi);
+ MathNestInset::metrics(mi);
+ MathScriptChanger dummy(mi.base);
ascent_ = ascent2(nuc);
descent_ = descent2(nuc);
width_ = width2(nuc);
void MathScriptInset::draw(MathPainterInfo & pi, int x, int y) const
{
//lyxerr << "unexpected call to MathScriptInset::draw()\n";
- MathScriptChanger dummy(pi.base);
draw(0, pi, x, y);
}
+void MathScriptInset::draw(MathInset const * nuc, MathPainterInfo & pi,
+ int x, int y) const
+{
+ if (nuc)
+ nuc->draw(pi, x + dxx(nuc), y);
+ else if (editing())
+ drawStr(pi, font_, x + dxx(nuc), y, ".");
+
+ MathScriptChanger dummy(pi.base);
+ if (hasUp())
+ up().draw(pi, x + dx1(nuc), y - dy1(nuc));
+ if (hasDown())
+ down().draw(pi, x + dx0(nuc), y + dy0(nuc));
+}
+
+
void MathScriptInset::metricsT(TextMetricsInfo const & mi) const
{
metricsT(0, mi);
}
-void MathScriptInset::draw(MathInset const * nuc, MathPainterInfo & pi,
- int x, int y) const
-{
- MathScriptChanger dummy(pi.base);
- if (nuc)
- nuc->draw(pi, x + dxx(nuc), y);
- else if (editing())
- drawStr(pi, font_, x + dxx(nuc), y, ".");
-
- if (hasUp())
- up().draw(pi, x + dx1(nuc), y - dy1(nuc));
- if (hasDown())
- down().draw(pi, x + dx0(nuc), y + dy0(nuc));
-}
-
-
void MathScriptInset::drawT(TextPainter & pain, int x, int y) const
{
//lyxerr << "unexpected call to MathScriptInset::draw()\n";
#include "debug.h"
-MathStringInset::MathStringInset()
- : str_()
-{}
-
MathStringInset::MathStringInset(string const & s)
: str_(s)
{}
#pragma interface
#endif
-/** Some cllection of chars with similar properties
- \author André Pönitz
+/** Some collection of chars with similar properties
+ * maily for math-extern
+ * \author André Pönitz
*/
class MathStringInset : public MathDimInset {
public:
- ///
- MathStringInset();
///
explicit MathStringInset(string const & s);
///
///
void write(WriteStream & os) const;
-public:
+private:
/// the string
string str_;
};
#include "math_support.h"
#include "lyxfont.h"
-#include "frontends/font_loader.h"
-#include "frontends/font_metrics.h"
#include "math_cursor.h"
#include "math_defs.h"
#include "math_inset.h"
#include "math_parser.h"
#include "frontends/Painter.h"
+#include "frontends/font_metrics.h"
+#include "frontends/font_loader.h"
#include "debug.h"
#include "commandtags.h"
/*
* Internal struct of a drawing: code n x1 y1 ... xn yn, where code is:
- * 0 = end, 1 = line, 2 = polyline, 3 = square line, 4= square polyline
+ * 0 = end, 1 = line, 2 = polyline, 3 = square line, 4 = square polyline
*/
{"eufrak", LyXFont::EUFRAK_FAMILY, def_series, def_shape, LColor::math},
{"mathbf", def_family, LyXFont::BOLD_SERIES, def_shape, LColor::math},
{"mathcal",LyXFont::CMSY_FAMILY, def_series, def_shape, LColor::math},
+ {"mathfrak", LyXFont::EUFRAK_FAMILY, def_series, def_shape, LColor::math},
{"mathnormal", def_family,def_series, LyXFont::UP_SHAPE, LColor::math},
{"mathrm", LyXFont::ROMAN_FAMILY, def_series, def_shape, LColor::math},
{"mathsf", LyXFont::SANS_FAMILY, def_series, def_shape, LColor::math},
{"lyxtex", def_family, def_series, def_shape, LColor::latex},
{"lyxsymbol", LyXFont::SYMBOL_FAMILY, def_series, def_shape, LColor::math},
- {"lyxitsymbol", LyXFont::SYMBOL_FAMILY, def_series, LyXFont::ITALIC_SHAPE, LColor::math},
+ {"lyxboldsymbol",
+ LyXFont::SYMBOL_FAMILY, LyXFont::BOLD_SERIES, def_shape, LColor::math},
+ {"lyxitsymbol", LyXFont::SYMBOL_FAMILY,
+ def_series, LyXFont::ITALIC_SHAPE, LColor::math},
+ {"lyxredtext", LyXFont::ROMAN_FAMILY,
+ LyXFont::MEDIUM_SERIES, LyXFont::UP_SHAPE, LColor::red},
+ {"lyxblacktext", LyXFont::ROMAN_FAMILY,
+ LyXFont::MEDIUM_SERIES, LyXFont::UP_SHAPE, LColor::black},
+
+ {"lyxfakebb", LyXFont::TYPEWRITER_FAMILY, LyXFont::BOLD_SERIES,
+ LyXFont::UP_SHAPE, LColor::math},
+ {"lyxfakecal", LyXFont::SANS_FAMILY, LyXFont::MEDIUM_SERIES,
+ LyXFont::ITALIC_SHAPE, LColor::math},
+ {"lyxfakefrak", LyXFont::ROMAN_FAMILY, LyXFont::BOLD_SERIES,
+ LyXFont::ITALIC_SHAPE, LColor::math}
};
}
+LyXFont getFont(string const & name)
+{
+ LyXFont font;
+ augmentFont(font, name);
+ return font;
+}
+
+
+void fakeFont(string const & orig, string const & fake)
+{
+ fontinfo * forig = searchFont(orig);
+ fontinfo * ffake = searchFont(fake);
+ if (forig && ffake) {
+ forig->family_ = ffake->family_;
+ forig->series_ = ffake->series_;
+ forig->shape_ = ffake->shape_;
+ forig->color_ = ffake->color_;
+ } else {
+ lyxerr << "Can't fake font '" << orig << "' with '" << fake << "'\n";
+ }
+}
+
void augmentFont(LyXFont & font, string const & name)
{
static bool initialized = false;
-
if (!initialized) {
initialized = true;
- LyXFont f1;
- augmentFont(f1, "msb");
- if (!fontloader.available(f1)) {
- lyxerr << "faking msb\n";
- fontinfo * info = searchFont("msb");
- info->family_ = LyXFont::TYPEWRITER_FAMILY;
- info->series_ = LyXFont::BOLD_SERIES;
- }
-
- LyXFont f2;
- augmentFont(f2, "msex");
- if (!fontloader.available(f2)) {
- lyxerr << "faking msex\n";
- fontinfo * info = searchFont("msex");
- info->family_ = LyXFont::SANS_FAMILY;
- info->series_ = LyXFont::BOLD_SERIES;
- info->shape_ = LyXFont::ITALIC_SHAPE;
- }
-
- //{"fakebb", LyXFont::TYPEWRITER_FAMILY, LyXFont::BOLD_SERIES,
- // LyXFont::UP_SHAPE, LColor::math},
- //{"fakecal", LyXFont::SANS_FAMILY, LyXFont::MEDIUM_SERIES,
- // LyXFont::ITALIC_SHAPE, LColor::math},
- //{"fakefrak", LyXFont::SANS_FAMILY, LyXFont::BOLD_SERIES,
- // LyXFont::ITALIC_SHAPE, LColor::math}
-
+ // fake fonts if necessary
+ if (!fontloader.available(getFont("mathfrak")))
+ fakeFont("mathfrak", "lyxfakefrak");
+ if (!fontloader.available(getFont("mathcal")))
+ fakeFont("mathcal", "lyxfakecal");
}
-
-
fontinfo * info = searchFont(name);
if (info->family_ != def_family)
font.setFamily(info->family_);
-
if (info->series_ != def_series)
font.setSeries(info->series_);
-
if (info->shape_ != def_shape)
font.setShape(info->shape_);
-
if (info->color_ != LColor::none)
font.setColor(info->color_);
}
-
-
-bool math_font_available(string const & /*name*/)
-{
- return true;
-}
void math_font_max_dim(LyXFont const &, int & asc, int & desc);
-bool math_font_available(string const & name);
-
string convertDelimToLatexName(string const & name);
void augmentFont(LyXFont & f, string const & cmd);
// << "'\n";
MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
mathed_string_dim(mi.base.font, sym_->draw, ascent_, descent_, width_);
+ // correct height for broken cmex font
if (sym_->inset == "cmex") {
h_ = 4 * descent_ / 5;
ascent_ += h_;
}
if (isRelOp())
width_ += 6;
- scriptable_ = (mi.base.style == LM_ST_DISPLAY && sym_->inset == "cmex");
+
+ scriptable_ = false;
+ if (mi.base.style == LM_ST_DISPLAY)
+ if (sym_->inset == "cmex" || sym_->extra == "funclim")
+ scriptable_ = true;
}
bool MathSymbolInset::takesLimits() const
{
- return sym_->inset == "cmex" || sym_->inset == "lyxboldsymb";
+ return
+ sym_->inset == "cmex" ||
+ sym_->inset == "lyxboldsymb" ||
+ sym_->extra == "funclim";
}
}
os << ">";
- ret += GetCellInset(cell)->docbook(buf, os);
+ ret += GetCellInset(cell)->docbook(buf, os, true);
os << "</entry>\n";
++cell;
}
}
-int LyXTabular::docBook(Buffer const * buf, ostream & os) const
+int LyXTabular::docbook(Buffer const * buf, ostream & os, bool mixcont) const
{
int ret = 0;
///
int latex(Buffer const *, std::ostream &, bool, bool) const;
///
- int docBook(Buffer const * buf, std::ostream & os) const;
+ int docbook(Buffer const * buf, std::ostream & os, bool mixcont) const;
///
int ascii(Buffer const *, std::ostream &, int const depth,
bool onlydata, unsigned char delim) const;