use more std::functors add some of my own, some change to fl_display etc. read the change log...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1102 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-10-11 21:06:43 +00:00
parent 0e65803860
commit e7401bd8f2
73 changed files with 4331 additions and 4467 deletions

134
ChangeLog
View File

@ -1,3 +1,137 @@
2000-10-11 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/support/translator.h: move helper template clsses to
lyxfunctional.h, inlcude 2support/lyxfunctional.h"
* src/support/lyxmanip.h: add delaration of fmt
* src/support/lyxfunctional.h: new file
(class_fun_t): new template class
(class_fun): helper template function
(back_insert_fun_iterator): new template class
(back_inserter_fun): helper template function
(compare_memfun_t): new template class
(compare_memfun): helper template function
(equal_1st_in_pair): moved here from translator
(equal_2nd_in_pair): moved here from translatro
* src/support/fmt.C: new file
(fmt): new func, can be used for a printf substute when still
using iostreams ex. lyxerr << fmg("Hello %s", "Jürgen") << endl;
* src/support/StrPool.C: add some comment
* src/support/Makefile.am (libsupport_la_SOURCES): add fmt.C and
lyxfunctional.h
* src/insets/figinset.C (addpidwait): use std::copy with
ostream_iterator to fill the pidwaitlist
* src/graphics/XPM_Renderer.C (renderImage): use ScreenOfDisplay
* src/frontends/xforms/Toolbar_pimpl.C (updateLayoutList): remove
c_str()
* src/frontends/xforms/Menubar_pimpl.C: make several file scope
variables static
* src/frontends/xforms/FormParagraph.C (input): use lyx::atoi
* src/frontends/xforms/FormDocument.C (build): remove c_str()
(class_update): ditto
(BulletPanel): ditto
(CheckChoiceClass): move initialization of tc and tct
* src/tabular.C: remove current_view
(OldFormatRead): similar to right below [istream::ignore]
* src/lyxlex_pimpl.C (next): add code for faster skipping of
chars, unfortunately this is buggy on gcc 2.95.2, so currently
unused [istream::ignore]
* src/lyxfunc.C: include "support/lyxfunctional.h"
(getInsetByCode): use std::find_if and compare_memfun
* src/lyxfont.C (stateText): remove c_str()
* src/lyx_main.C (setDebuggingLevel): make static
(commandLineHelp): make static
* src/lyx_gui_misc.C (getScreenDPI): use ScreenOfDisplay to get
Screen* together with fl_get_display() and fl_screen
* src/lyx_gui.C (LyXGUI): use ScreenOfDisplay to get Screen*
togheter with fl_get_display() and fl_screen
(create_forms): remove c_str()
* src/layout.C: include "support/lyxfunctional.h"
(hasLayout): use std::find_if and compare_memfun
(GetLayout): use std::find_if and comapre_memfun
(delete_layout): use std::remove_if and compare_memfun
(NumberOfClass): use std:.find_if and compare_memfun
* src/gettext.h: change for the new functions
* src/gettext.C: new file, make _(char const * str) and _(string
const & str) real functions.
* src/font.C (width): rewrite slightly to avoid one extra variable
* src/debug.C: initialize Debug::ANY here
* src/commandtags.h: update number comments
* src/combox.h (get): make const func
(empty): make const
(getline): make const
* src/combox.C (input_cb): handle case where fl_get_input can
return NULL
* src/bufferlist.C: add <functional>, "support/lyxmanip.h",
"support/lyxfunctional.h", remove currentview variable.
(resize): use std::for_each with std::mem_fun
(getFileNames): use std::copy with back_inserter_fun
(getBuffer): change arg type to unsigned int
(emergencyWriteAll): call emergencyWrite with std::for_each and
class_fun.
(emergencyWrite): new method, the for loop in emergencyWriteAll
has been unrolled.
(exists): use std::find_if with compare_memfun
(getBuffer): use std::find_if and compare_memfun
* src/buffer.h: add typedefs for iterator_category, value_type
difference_type, pointer and reference for inset_iterator
add postfix ++ for inset_iterator
make isnet_iterator::getPos() const
* src/buffer.C: added support/lyxmanip.h
(readFile): use lyxerr << fmt instead of printf
(makeLaTeXFile): use std::copy to write out encodings
* src/Painter.C (text): rewrite slightly to avoid extra font variable
* src/MenuBackend.C (read): remove c_str(), as well as strdup and
free and the char * temp.
(hasMenu): use std::find_if and compare_memfun
(getMenu): ditto
* src/Makefile.am (lyx_SOURCES): added gettext.C
* src/LyXAction.C (retrieveActionArg): clear the arg, use
string::insert small change to avoid temporary
* src/LColor.C (getGUIName): remove c_str()
* several files: change all occurances of fl_display to
fl_get_display()
* config/lyxinclude.m4 (LYX_PROG_CXX): add a 2.97 clause so
that -pedantid is not used for gcc 2.97 (cvs gcc)
* boost/Makefile.am: begin slowly to prepare for a real boost lib
2000-10-11 Allan Rae <rae@lyx.org>
* src/frontends/xforms/FormPreferences.C (input): template path must be

View File

@ -1,5 +1,7 @@
AUTOMAKE_OPTIONS = foreign
DISTCLEANFILES= *.orig *.rej *~ *.bak core
MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
# SUBDIRS = libs boost
ETAGS_ARGS = --lang=c++
EXTRA_DIST = boost libs

View File

@ -205,6 +205,7 @@ dnl Check the version of g++
case $gxx_version in
2.95.*) ;;
2.96*) ;;
2.97*) ;;
*2.91*) ;;
*) CXXFLAGS="$CXXFLAGS -pedantic";;
esac

View File

@ -1,3 +1,7 @@
2000-10-11 Lars Gullik Bjønnes <larsbj@lyx.org>
* no.po: update a bit for 1.1.6cvs
2000-10-10 Allan Rae <rae@lyx.org>
* Makefile.in.in (POTFILES.in): one little tweak to ensure POTFILES.in

7362
po/no.po

File diff suppressed because it is too large Load Diff

View File

@ -61,12 +61,12 @@ void SetXtermCursor(Window win)
static Cursor cursor;
static bool cursor_undefined = true;
if (cursor_undefined){
cursor = XCreateFontCursor(fl_display, XC_xterm);
XFlush(fl_display);
cursor = XCreateFontCursor(fl_get_display(), XC_xterm);
XFlush(fl_get_display());
cursor_undefined = false;
}
XDefineCursor(fl_display, win, cursor);
XFlush(fl_display);
XDefineCursor(fl_get_display(), win, cursor);
XFlush(fl_get_display());
}
@ -704,7 +704,7 @@ void BufferView::Pimpl::enterView()
void BufferView::Pimpl::leaveView()
{
if (using_xterm_cursor) {
XUndefineCursor(fl_display, workarea_->getWin());
XUndefineCursor(fl_get_display(), workarea_->getWin());
using_xterm_cursor = false;
}
}

View File

@ -26,7 +26,7 @@ using std::endl;
LyXColorHandler::LyXColorHandler()
{
display = fl_display;
display = fl_get_display();
drawable = XCreatePixmap(display, fl_root, 10, 10,
fl_get_visual_depth());

View File

@ -116,7 +116,7 @@ void FontInfo::query()
char ** list = 0;
if (lyxrc.use_gui)
list = XListFonts(fl_display, pattern.c_str(), 100, &matches);
list = XListFonts(fl_get_display(), pattern.c_str(), 100, &matches);
if (list == 0) {
// No fonts matched

View File

@ -81,7 +81,7 @@ void FontLoader::unload()
}
for (int i4 = 0; i4<10; i4++) {
if (fontstruct[i1][i2][i3][i4]) {
XFreeFont(fl_display, fontstruct[i1][i2][i3][i4]);
XFreeFont(fl_get_display(), fontstruct[i1][i2][i3][i4]);
fontstruct[i1][i2][i3][i4] = 0;
}
}
@ -244,14 +244,14 @@ XFontStruct * FontLoader::doLoad(LyXFont::FONT_FAMILY family,
current_view->owner()->getMiniBuffer()->Store();
current_view->owner()->getMiniBuffer()->Set(_("Loading font into X-Server..."));
fs = XLoadQueryFont(fl_display, font.c_str());
fs = XLoadQueryFont(fl_get_display(), font.c_str());
if (fs == 0) {
if (font == "fixed") {
lyxerr << "We're doomed. Can't get 'fixed' font." << endl;
} else {
lyxerr << "Could not get font. Using 'fixed'." << endl;
fs = XLoadQueryFont(fl_display, "fixed");
fs = XLoadQueryFont(fl_get_display(), "fixed");
}
} else if (lyxerr.debugging(Debug::FONT)) {
// Tell user the font matching

View File

@ -123,7 +123,7 @@ string const LColor::getGUIName(LColor::color c) const
{
InfoTab::const_iterator ici = infotab.find(c);
if (ici != infotab.end())
return _((*ici).second.guiname.c_str());
return _((*ici).second.guiname);
return "none";
}

View File

@ -342,7 +342,8 @@ string const LaTeXFeatures::getIncludedFiles()
{
string sgmlpreamble;
FileMap::const_iterator end = IncludedFiles.end();
for(FileMap::const_iterator fi=IncludedFiles.begin(); fi != end; ++fi)
for (FileMap::const_iterator fi = IncludedFiles.begin();
fi != end; ++fi)
sgmlpreamble += "\n<!entity " + fi->first
+ " system \"" + fi->second + "\">";

View File

@ -514,6 +514,8 @@ int LyXAction::getPseudoAction(kb_action action, string const & arg) const
// perhaps a pair<kb_action, string> should be returned?
kb_action LyXAction::retrieveActionArg(int pseudo, string & arg) const
{
arg.erase(); // clear it to be sure.
pseudo_map::const_iterator pit = lyx_pseudo_map.find(pseudo);
if (pit != lyx_pseudo_map.end()) {
@ -601,16 +603,17 @@ string const LyXAction::getActionName(int action) const
string arg;
if (isPseudoAction(action)) {
ac = retrieveActionArg(action, arg);
arg = " " +arg;
}
else
arg.insert(0, " ");
} else
ac = static_cast<kb_action>(action);
info_map::const_iterator iit = lyx_info_map.find(ac);
if (iit != lyx_info_map.end())
return (*iit).second.name + arg;
else
if (iit != lyx_info_map.end()) {
string ret((*iit).second.name);
ret += arg;
return ret;
} else
return string();
}

View File

@ -210,7 +210,7 @@ void LyXView::show(int place, int border, string const & title)
{
fl_show_form(form_, place, border, title.c_str());
minibuffer->Init();
InitLyXLookup(fl_display, form_->window);
InitLyXLookup(fl_get_display(), form_->window);
}

View File

@ -125,6 +125,7 @@ lyx_SOURCES = \
font.h \
form1.C \
form1.h \
gettext.C \
gettext.h \
include_form.h \
intl.C \

View File

@ -25,6 +25,7 @@
#include "bufferlist.h"
#include "exporter.h"
#include "support/filetools.h"
#include "support/lyxfunctional.h"
extern LyXAction lyxaction;
extern LastFiles * lastfiles;
@ -95,7 +96,7 @@ Menu & Menu::read(LyXLex & lex)
md_last
};
struct keyword_item menutags[md_last-1] = {
struct keyword_item menutags[md_last - 1] = {
{ "documents", md_documents },
{ "end", md_endmenu },
{ "exportformats", md_exportformats },
@ -124,11 +125,9 @@ Menu & Menu::read(LyXLex & lex)
// fallback to md_item
case md_item: {
lex.next();
char * tmp = ::strdup(lex.GetString().c_str());
string name = _(tmp);
free(tmp);
string name = _(lex.GetString());
lex.next();
string command = lex.GetString();
string const command = lex.GetString();
add(MenuItem(MenuItem::Command, name,
command, optional));
optional = false;
@ -169,9 +168,7 @@ Menu & Menu::read(LyXLex & lex)
case md_submenu: {
lex.next();
char * tmp = ::strdup(lex.GetString().c_str());
string mlabel = _(tmp);
free(tmp);
string mlabel = _(lex.GetString());
lex.next();
string mname = lex.GetString();
add(MenuItem(MenuItem::Submenu, mlabel, mname));
@ -192,7 +189,8 @@ Menu & Menu::read(LyXLex & lex)
return *this;
}
void Menu::expand(Menu & tomenu, Buffer *buf) const
void Menu::expand(Menu & tomenu, Buffer * buf) const
{
for (const_iterator cit = begin();
cit != end() ; ++cit) {
@ -270,6 +268,7 @@ void Menu::expand(Menu & tomenu, Buffer *buf) const
}
}
void MenuBackend::read(LyXLex & lex)
{
enum Menutags {
@ -400,36 +399,24 @@ void MenuBackend::add(Menu const & menu)
bool MenuBackend::hasMenu(string const & name) const
{
const_iterator mend = end();
for (const_iterator cit = begin(); cit != mend; ++cit) {
if ((*cit).name() == name)
return true;
}
return false;
return find_if(begin(), end(),
compare_memfun(&Menu::name, name)) != end();
}
Menu const & MenuBackend::getMenu(string const & name) const
{
const_iterator mend = end();
for (const_iterator cit = begin(); cit != mend; ++cit) {
if ((*cit).name() == name)
return (*cit);
}
Assert(false); // we actually require the name to exist.
return menulist_.front();
const_iterator cit = find_if(begin(), end(),
compare_memfun(&Menu::name, name));
Assert(cit != end());
return (*cit);
}
Menu & MenuBackend::getMenu(string const & name)
{
MenuList::iterator end = menulist_.end();
for (MenuList::iterator cit = menulist_.begin();
cit != end; ++cit) {
if ((*cit).name() == name)
return (*cit);
}
Assert(false); // we actually require the name to exist.
return menulist_.front();
MenuList::iterator it = find_if(menulist_.begin(), menulist_.end(),
compare_memfun(&Menu::name, name));
Assert(it != menulist_.end());
return (*it);
}

View File

@ -39,7 +39,7 @@ using std::max;
Painter::Painter(WorkArea & wa)
: PainterBase(wa)
{
display = fl_display;
display = fl_get_display();
}
@ -275,13 +275,14 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) {
XChar2b * xs = new XChar2b[ls];
Encoding const * encoding = f.language()->encoding();
LyXFont const * font = &f;
//LyXFont const * font = &f;
LyXFont font(f);
if (f.family() == LyXFont::SYMBOL_FAMILY) {
#ifdef USE_UNICODE_FOR_SYMBOLS
LyXFont font2 = f;
font2.setFamily(LyXFont::ROMAN_FAMILY);
font2.setShape(LyXFont::UP_SHAPE);
font = &font2;
//LyXFont font2 = f;
font.setFamily(LyXFont::ROMAN_FAMILY);
font.setShape(LyXFont::UP_SHAPE);
//font = &font2;
#endif
encoding = encodings.symbol_encoding();
}
@ -290,7 +291,7 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
xs[i].byte1 = c >> 8;
xs[i].byte2 = c & 0xff;
}
text(x , y, xs, ls, *font);
text(x , y, xs, ls, font);
delete[] xs;
return *this;
}

View File

@ -140,7 +140,7 @@ WorkArea::WorkArea(BufferView * o, int xpos, int ypos, int width, int height)
WorkArea::~WorkArea()
{
if (workareapixmap)
XFreePixmap(fl_display, workareapixmap);
XFreePixmap(fl_get_display(), workareapixmap);
}
@ -205,14 +205,14 @@ void WorkArea::createPixmap(int width, int height)
cur_height = height;
if (workareapixmap)
XFreePixmap(fl_display, workareapixmap);
XFreePixmap(fl_get_display(), workareapixmap);
if (lyxerr.debugging(Debug::GUI))
lyxerr << "Creating pixmap ("
<< width << 'x' << height << ")" << endl;
workareapixmap = XCreatePixmap(fl_display,
RootWindow(fl_display, 0),
workareapixmap = XCreatePixmap(fl_get_display(),
RootWindow(fl_get_display(), 0),
width,
height,
fl_get_visual_depth());

View File

@ -98,12 +98,12 @@ void draw_bitmaptable(FL_OBJECT *ob)
/* draw the background bitmap */
if (sp->bdata) {
if (!sp->pix) {
sp->pix = XCreatePixmapFromBitmapData(fl_display, fl_winget(),
sp->pix = XCreatePixmapFromBitmapData(fl_get_display(), fl_winget(),
(char*)sp->bdata,
sp->bw, sp->bh,
fl_get_flcolor(ob->lcol), fl_get_flcolor(ob->col1),
/*DefaultDepth(fl_display, DefaultScreen(fl_display))*/ fl_state[fl_get_vclass()].depth);
XFlush(fl_display);
/*DefaultDepth(fl_get_display(), DefaultScreen(fl_get_display()))*/ fl_state[fl_get_vclass()].depth);
XFlush(fl_get_display());
}
}
if (sp->pix) {
@ -129,12 +129,12 @@ void draw_bitmaptable(FL_OBJECT *ob)
i = FL_abs(ob->bw);
j = hh - ((lx) ? sp->dy+2*i: 0);
XCopyArea(fl_display, sp->pix, fl_winget(), gc, xx, yy, ww, j, mx, my);
XFlush(fl_display);
XCopyArea(fl_get_display(), sp->pix, fl_winget(), gc, xx, yy, ww, j, mx, my);
XFlush(fl_get_display());
if (lx) {
XCopyArea(fl_display, sp->pix, fl_winget(), gc, xx,
XCopyArea(fl_get_display(), sp->pix, fl_winget(), gc, xx,
yy+j, lx*sp->dx-2*i, hh-j, mx, my+j);
XFlush(fl_display);
XFlush(fl_get_display());
}
}
@ -216,8 +216,8 @@ int handle_bitmaptable(FL_OBJECT * ob, int event, FL_Coord mx,
return 1;
case FL_FREEMEM:
if (sp->pix) {
XFreePixmap(fl_display, sp->pix);
XFlush(fl_display);
XFreePixmap(fl_get_display(), sp->pix);
XFlush(fl_get_display());
}
fl_free(((BMTABLE_SPEC*)ob->spec));
break;
@ -273,14 +273,14 @@ void fl_set_bmtable_pixmap_data(FL_OBJECT * ob, int nx, int ny,
dumb_attributes.colormap = fl_state[fl_get_vclass()].colormap;
dumb_attributes.closeness = 30000;
dumb_attributes.valuemask = XpmColormap | XpmCloseness;
if (XCreatePixmapFromData(fl_display, fl_winget(), pdata,
if (XCreatePixmapFromData(fl_get_display(), fl_winget(), pdata,
&(sp->pix), &dummy_shapemask,
&dumb_attributes) == XpmSuccess) {
sp->bw = dumb_attributes.width;
sp->bh = dumb_attributes.height;
XpmFreeAttributes(&dumb_attributes);
if (dummy_shapemask) {
XFreePixmap(fl_display, dummy_shapemask);
XFreePixmap(fl_get_display(), dummy_shapemask);
}
}
}
@ -301,7 +301,7 @@ void fl_set_bmtable_file(FL_OBJECT * ob, int nx, int ny, char const * filename)
if(XReadBitmapFileData(filename, &bw, &bh,
&bdata, &xh, &yh) == BitmapSuccess)
fl_set_bmtable_data(ob, nx, ny, bw, bh, bdata);
XFlush(fl_display);
XFlush(fl_get_display());
}
#else
@ -337,17 +337,17 @@ void fl_set_bmtable_pixmap_file(FL_OBJECT *ob, int nx, int ny, char const *filen
dumb_attributes.closeness = 30000;
dumb_attributes.valuemask = XpmColormap | XpmCloseness;
if (XReadPixmapFile(fl_display, fl_winget(), (char *)filename,
if (XReadPixmapFile(fl_get_display(), fl_winget(), (char *)filename,
&(sp->pix), &dummy_shapemask,
&dumb_attributes) == XpmSuccess) {
sp->bw = dumb_attributes.width;
sp->bh = dumb_attributes.height;
XpmFreeAttributes(&dumb_attributes);
if (dummy_shapemask) {
XFreePixmap(fl_display, dummy_shapemask);
XFreePixmap(fl_get_display(), dummy_shapemask);
}
}
/* XFlush(fl_display); */
/* XFlush(fl_get_display()); */
}
}
@ -445,8 +445,8 @@ void fl_draw_bmtable_item(FL_OBJECT * ob, int i, Drawable d, int xx, int yy)
y = (i/sp->nx)*sp->dy + FL_abs(ob->bw);
w = sp->dx-2*FL_abs(ob->bw);
h = sp->dy-2*FL_abs(ob->bw);
XCopyArea(fl_display, sp->pix, d, gc, x, y, w, h, xx, yy);
XFlush(fl_display);
XCopyArea(fl_get_display(), sp->pix, d, gc, x, y, w, h, xx, yy);
XFlush(fl_get_display());
}
}
@ -457,8 +457,8 @@ void fl_free_bmtable_bitmap(FL_OBJECT * ob)
/* dump the temporary pixmap */
if (sp && sp->pix) {
XFreePixmap(fl_display, sp->pix);
XFlush(fl_display);
XFreePixmap(fl_get_display(), sp->pix);
XFlush(fl_get_display());
sp->pix = 0;
}
@ -477,8 +477,8 @@ void fl_free_bmtable_pixmap(FL_OBJECT *ob)
/* dump the temporary pixmap */
if (sp && sp->pix) {
XFreePixmap(fl_display, sp->pix);
XFlush(fl_display);
XFreePixmap(fl_get_display(), sp->pix);
XFlush(fl_get_display());
sp->pix = 0;
}
}

View File

@ -84,6 +84,7 @@
#include "support/syscall.h"
#include "support/lyxlib.h"
#include "support/FileInfo.h"
#include "support/lyxmanip.h"
#include "lyxtext.h"
#include "gettext.h"
#include "language.h"
@ -1047,13 +1048,12 @@ bool Buffer::readFile(LyXLex & lex, LyXParagraph * par)
format = lex.GetFloat();
if (format > 1) {
if (LYX_FORMAT - format > 0.05) {
printf(_("Warning: need lyxformat %.2f but found %.2f\n"),
LYX_FORMAT, format);
lyxerr << fmt(_("Warning: need lyxformat %.2f but found %.2f"),
LYX_FORMAT, format) << endl;
}
if (format - LYX_FORMAT > 0.05) {
printf(_("ERROR: need lyxformat %.2f but found %.2f\n"),
LYX_FORMAT, format);
lyxerr << fmt(_("ERROR: need lyxformat %.2f but found %.2f"),
LYX_FORMAT, format) << endl;
}
bool the_end = readLyXformat2(lex, par);
// Formats >= 2.13 support "\the_end" marker
@ -1889,9 +1889,8 @@ void Buffer::makeLaTeXFile(string const & fname,
encodings.insert((*it)->encoding()->LatexName());
ofs << "\\usepackage[";
for (set<string>::const_iterator it = encodings.begin();
it != encodings.end(); ++it)
ofs << *it << ",";
copy(encodings.begin(), encodings.end(),
ostream_iterator<string>(ofs, ","));
ofs << doc_encoding << "]{inputenc}\n";
texrow.newline();
} else if (params.inputenc != "default") {
@ -2669,7 +2668,9 @@ void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
void Buffer::push_tag(ostream & os, string const & tag,
int & pos, char stack[5][3])
{
#ifdef WITH_WARNINGS
#warning Use a real stack! (Lgb)
#endif
// pop all previous tags
for (int j = pos; j >= 0; --j)
os << "</" << stack[j] << ">";

View File

@ -413,6 +413,13 @@ public:
///
class inset_iterator {
public:
typedef input_iterator_tag iterator_category;
typedef Inset value_type;
typedef ptrdiff_t difference_type;
typedef Inset * pointer;
typedef Inset & reference;
///
inset_iterator() : par(0) /*, it(0)*/ {}
//
@ -423,7 +430,7 @@ public:
inset_iterator(LyXParagraph * paragraph,
LyXParagraph::size_type pos);
///
inset_iterator & operator++() {
inset_iterator & operator++() { // prefix ++
if (par) {
++it;
if (it == par->inset_iterator_end()) {
@ -434,11 +441,24 @@ public:
return *this;
}
///
Inset * operator*() {return *it; }
inset_iterator operator++(int) { // postfix ++
inset_iterator tmp(par, it.getPos());
if (par) {
++it;
if (it == par->inset_iterator_end()) {
par = par->next;
SetParagraph();
}
}
return tmp;
}
///
Inset * operator*() { return *it; }
///
LyXParagraph * getPar() { return par; }
///
LyXParagraph::size_type getPos() {return it.getPos(); }
LyXParagraph::size_type getPos() const { return it.getPos(); }
///
friend
bool operator==(inset_iterator const & iter1,

View File

@ -19,12 +19,15 @@
#include <config.h>
#include <algorithm>
#include <functional>
#include "bufferlist.h"
#include "lyx_main.h"
#include "minibuffer.h"
#include "support/FileInfo.h"
#include "support/filetools.h"
#include "support/lyxmanip.h"
#include "support/lyxfunctional.h"
#include "lyx_gui_misc.h"
#include "lastfiles.h"
#include "debug.h"
@ -37,8 +40,6 @@
#include "vc-backend.h"
#include "TextCache.h"
extern BufferView * current_view; // called too many times in this file...
using std::vector;
using std::find;
using std::endl;
@ -95,7 +96,7 @@ bool BufferList::QwriteAll()
{
bool askMoreConfirmation = false;
string unsaved;
for(BufferStorage::iterator it = bstore.begin();
for (BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
if (!(*it)->isLyxClean()) {
string fname;
@ -160,10 +161,7 @@ void BufferList::closeAll()
void BufferList::resize()
{
for(BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
(*it)->resize();
}
for_each(bstore.begin(), bstore.end(), mem_fun(&Buffer::resize));
}
@ -223,10 +221,8 @@ bool BufferList::close(Buffer * buf)
vector<string> const BufferList::getFileNames() const
{
vector<string> nvec;
for(BufferStorage::const_iterator cit = bstore.begin();
cit != bstore.end(); ++cit) {
nvec.push_back((*cit)->fileName());
}
std::copy(bstore.begin(), bstore.end(),
back_inserter_fun(nvec, &Buffer::fileName));
return nvec;
}
@ -238,7 +234,7 @@ Buffer * BufferList::first()
}
Buffer * BufferList::getBuffer(int choice)
Buffer * BufferList::getBuffer(unsigned int choice)
{
if (choice >= bstore.size()) return 0;
return bstore[choice];
@ -248,8 +244,8 @@ Buffer * BufferList::getBuffer(int choice)
int BufferList::unlockInset(UpdatableInset * inset)
{
if (!inset) return 1;
for(BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
for (BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
if ((*it)->getUser()
&& (*it)->getUser()->theLockingInset() == inset) {
(*it)->getUser()->insetUnlock();
@ -262,8 +258,8 @@ int BufferList::unlockInset(UpdatableInset * inset)
void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
{
for(BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
for (BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
if (!(*it)->isDepClean(mastertmpdir)) {
string writefile = mastertmpdir;
writefile += '/';
@ -278,62 +274,109 @@ void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
void BufferList::emergencyWriteAll()
{
for (BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
if (!(*it)->isLyxClean()) {
bool madeit = false;
lyxerr <<_("lyx: Attempting to save"
" document ");
if ((*it)->isUnnamed())
lyxerr << OnlyFilename((*it)->fileName());
else
lyxerr << (*it)->fileName();
lyxerr << _(" as...") << endl;
for (int i = 0; i < 3 && !madeit; ++i) {
string s;
// We try to save three places:
// 1) Same place as document.
// 2) In HOME directory.
// 3) In "/tmp" directory.
if (i == 0) {
if ((*it)->isUnnamed())
continue;
s = (*it)->fileName();
} else if (i == 1) {
s = AddName(GetEnvPath("HOME"),
(*it)->fileName());
} else {
// MakeAbsPath to prepend the current
// drive letter on OS/2
s = AddName(MakeAbsPath("/tmp/"),
(*it)->fileName());
}
s += ".emergency";
lyxerr << " " << i + 1 << ") " << s << endl;
if ((*it)->writeFile(s, true)) {
(*it)->markLyxClean();
lyxerr << _(" Save seems successful. "
"Phew.") << endl;
madeit = true;
} else if (i != 2) {
lyxerr << _(" Save failed! Trying...")
<< endl;
} else {
lyxerr << _(" Save failed! Bummer. "
"Document is lost.")
<< endl;
}
}
for_each(bstore.begin(), bstore.end(),
class_fun(*this, &BufferList::emergencyWrite));
}
void BufferList::emergencyWrite(Buffer * buf)
{
// No need to save if the buffer has not changed.
if (buf->isLyxClean()) return;
lyxerr << fmt(_("lyx: Attempting to save document %s as..."),
buf->isUnnamed() ? OnlyFilename(buf->fileName()).c_str()
: buf->fileName().c_str()) << endl;
//if (buf->isUnnamed())
// lyxerr << OnlyFilename(buf->fileName());
//else
// lyxerr << buf->fileName();
//lyxerr << _(" as...") << endl;
// Let's unroll this loop (Lgb)
#if 0
bool madeit = false;
for (int i = 0; i < 3 && !madeit; ++i) {
string s;
// We try to save three places:
// 1) Same place as document.
// 2) In HOME directory.
// 3) In "/tmp" directory.
if (i == 0) {
if (buf->isUnnamed())
continue;
s = buf->fileName();
} else if (i == 1) {
s = AddName(GetEnvPath("HOME"), buf->fileName());
} else {
// MakeAbsPath to prepend the current
// drive letter on OS/2
s = AddName(MakeAbsPath("/tmp/"), buf->fileName());
}
s += ".emergency";
lyxerr << " " << i + 1 << ") " << s << endl;
if (buf->writeFile(s, true)) {
buf->markLyxClean();
lyxerr << _(" Save seems successful. Phew.") << endl;
madeit = true;
} else if (i != 2) {
lyxerr << _(" Save failed! Trying...") << endl;
} else {
lyxerr << _(" Save failed! Bummer. Document is lost.")
<< endl;
}
}
#else
// We try to save three places:
// 1) Same place as document. Unless it is an unnamed doc.
if (!buf->isUnnamed()) {
string s = buf->fileName();
s += ".emergency";
lyxerr << " " << s << endl;
if (buf->writeFile(s, true)) {
buf->markLyxClean();
lyxerr << _(" Save seems successful. Phew.") << endl;
return;
} else {
lyxerr << _(" Save failed! Trying...") << endl;
}
}
// 2) In HOME directory.
string s = AddName(GetEnvPath("HOME"), buf->fileName());
s += ".emergency";
lyxerr << " " << s << endl;
if (buf->writeFile(s, true)) {
buf->markLyxClean();
lyxerr << _(" Save seems successful. Phew.") << endl;
return;
}
lyxerr << _(" Save failed! Trying...") << endl;
// 3) In "/tmp" directory.
// MakeAbsPath to prepend the current
// drive letter on OS/2
s = AddName(MakeAbsPath("/tmp/"), buf->fileName());
s += ".emergency";
lyxerr << " " << s << endl;
if (buf->writeFile(s, true)) {
buf->markLyxClean();
lyxerr << _(" Save seems successful. Phew.") << endl;
return;
}
lyxerr << _(" Save failed! Bummer. Document is lost.") << endl;
#endif
}
Buffer * BufferList::readFile(string const & s, bool ronly)
{
Buffer * b = bstore.newBuffer(s, ronly);
@ -405,12 +448,8 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
bool BufferList::exists(string const & s) const
{
for (BufferStorage::const_iterator cit = bstore.begin();
cit != bstore.end(); ++cit) {
if ((*cit)->fileName() == s)
return true;
}
return false;
return find_if(bstore.begin(), bstore.end(),
compare_memfun(&Buffer::fileName, s)) != bstore.end();
}
@ -424,12 +463,10 @@ bool BufferList::isLoaded(Buffer const * b) const
Buffer * BufferList::getBuffer(string const & s)
{
for(BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
if ((*it)->fileName() == s)
return (*it);
}
return 0;
BufferStorage::iterator it =
find_if(bstore.begin(), bstore.end(),
compare_memfun(&Buffer::fileName, s));
return it != bstore.end() ? (*it) : 0;
}

View File

@ -120,7 +120,7 @@ public:
///
void emergencyWriteAll();
/** Close buffer.
@param buf the buffer that should be closed
@return #false# if operation was canceled
@ -139,7 +139,7 @@ public:
/// returns a pointer to the buffer with the given name.
Buffer * getBuffer(string const &);
/// returns a pointer to the buffer with the given number.
Buffer * getBuffer(int);
Buffer * getBuffer(unsigned int);
private:
///
@ -147,6 +147,8 @@ private:
///
list_state state_;
///
void emergencyWrite(Buffer * buf);
};
#endif

View File

@ -165,21 +165,21 @@ void ProhibitInput(BufferView * bv)
static bool cursor_undefined = true;
if (cursor_undefined){
cursor = XCreateFontCursor(fl_display, XC_watch);
XFlush(fl_display);
cursor = XCreateFontCursor(fl_get_display(), XC_watch);
XFlush(fl_get_display());
cursor_undefined = false;
}
/* set the cursor to the watch for all forms and the canvas */
XDefineCursor(fl_display, bv->owner()->getForm()->window,
XDefineCursor(fl_get_display(), bv->owner()->getForm()->window,
cursor);
if (fd_form_character->form_character->visible)
XDefineCursor(fl_display,
XDefineCursor(fl_get_display(),
fd_form_character->form_character->window,
cursor);
XFlush(fl_display);
XFlush(fl_get_display());
fl_deactivate_all_forms();
}
@ -188,13 +188,13 @@ void AllowInput(BufferView * bv)
{
/* reset the cursor from the watch for all forms and the canvas */
XUndefineCursor(fl_display, bv->owner()->getForm()->window);
XUndefineCursor(fl_get_display(), bv->owner()->getForm()->window);
if (fd_form_character->form_character->visible)
XUndefineCursor(fl_display,
XUndefineCursor(fl_get_display(),
fd_form_character->form_character->window);
XFlush(fl_display);
XFlush(fl_get_display());
fl_activate_all_forms();
}

View File

@ -48,7 +48,8 @@ extern "C" void C_Combox_input_cb(FL_OBJECT *ob, long);
extern "C" void C_Combox_combo_cb(FL_OBJECT *ob, long data) ;
extern "C" int C_Combox_peek_event(FL_FORM * form, void *xev);
Combox::Combox(combox_type t): type(t)
Combox::Combox(combox_type t)
: type(t)
{
browser = button = 0;
callback = 0;
@ -246,8 +247,8 @@ void Combox::Show()
if (_pre) _pre();
int tmp;
XGetInputFocus(fl_display, &save_window, &tmp); //BUG-Fix Dietmar
XFlush(fl_display);
XGetInputFocus(fl_get_display(), &save_window, &tmp); //BUG-Fix Dietmar
XFlush(fl_get_display());
if (button && type != FL_COMBOX_NORMAL) {
fl_set_object_label(button, "@2<-");
fl_redraw_object(button);
@ -259,11 +260,11 @@ void Combox::Show()
fl_set_browser_topline(browser, sel);
fl_select_browser_line(browser, sel);
}
XGrabPointer(fl_display, form->window, false,
XGrabPointer(fl_get_display(), form->window, false,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync,
0, 0, 0);
XFlush(fl_display);
XFlush(fl_get_display());
}
void Combox::Hide(int who)
@ -278,15 +279,15 @@ void Combox::Hide(int who)
fl_get_browser_line(browser, sel));
// if (callback) callback(sel, cb_arg);
}
XUngrabPointer(fl_display, 0);
XFlush(fl_display);
XUngrabPointer(fl_get_display(), 0);
XFlush(fl_get_display());
if (!who && browser && label && callback)
callback(sel, cb_arg, this);
if (form) {
fl_hide_form(form);
XSetInputFocus(fl_display, save_window,
XSetInputFocus(fl_get_display(), save_window,
RevertToParent, CurrentTime); // BUG-FIX-Dietmar
XFlush(fl_display);
XFlush(fl_get_display());
}
if (button) {
if (type != FL_COMBOX_NORMAL){
@ -313,16 +314,18 @@ void Combox::deactivate()
if (label) fl_deactivate_object(label);
}
void Combox::input_cb(FL_OBJECT * ob, long)
{
Combox * combo = static_cast<Combox*>(ob->u_vdata);
char const * text = fl_get_input(ob);
combo->addto(text);
combo->addto(text ? text : string());
combo->is_empty = false;
}
extern "C" void C_Combox_input_cb(FL_OBJECT * ob, long data)
{
Combox::input_cb(ob, data);
@ -335,11 +338,11 @@ void Combox::combo_cb(FL_OBJECT * ob, long data)
switch (data) {
case 0:
{
int i = combo->get();
int const i = combo->get();
switch (fl_get_button_numb(ob)) {
case 2:
{
combo->select(--i);
combo->select(i - 1);
if (combo->callback)
combo->callback(combo->sel,
combo->cb_arg, combo);
@ -347,7 +350,7 @@ void Combox::combo_cb(FL_OBJECT * ob, long data)
}
case 3:
{
combo->select(++i);
combo->select(i + 1);
if (combo->callback)
combo->callback(combo->sel,
combo->cb_arg, combo);
@ -392,7 +395,7 @@ int Combox::peek_event(FL_FORM * form, void * xev)
KeySym keysym_return;
num_bytes = XLookupString(&static_cast<XEvent*>(xev)->xkey, s_r, 10,
&keysym_return, 0);
XFlush(fl_display);
XFlush(fl_get_display());
switch (keysym_return) {
case XK_Down:
if (fl_get_browser(combo->browser) <

View File

@ -69,10 +69,10 @@ public:
void addto(string const &);
/// Returns the selected item
int get();
int get() const;
/// Returns a pointer to the selected line of text
string const getline();
string const getline() const;
/// Select an arbitrary item
void select(int);
@ -83,7 +83,7 @@ public:
void clear();
/// Is the combox cleared (empty)
bool empty() { return is_empty; }
bool empty() const { return is_empty; }
/// Remove the objects from the form they are in.
void remove();
@ -209,14 +209,14 @@ void Combox::setpost(FL_COMBO_PRE_POST cb)
inline
int Combox::get()
int Combox::get() const
{
return sel;
}
inline
string const Combox::getline()
string const Combox::getline() const
{
if (type == FL_COMBOX_INPUT)
return fl_get_input(label);

View File

@ -27,8 +27,8 @@ enum kb_action {
LFUN_MENUWRITEAS,
LFUN_MENUPRINT,
LFUN_MENUSENDTO,
LFUN_BUILDPROG, // 10
LFUN_TOCVIEW,
LFUN_BUILDPROG,
LFUN_TOCVIEW, // 10
LFUN_PREVIEW,
LFUN_CLOSEBUFFER,
LFUN_BUFFER_PRINT, // ARRae 20000313
@ -36,9 +36,9 @@ enum kb_action {
LFUN_QUIT,
LFUN_AUTOSAVE,
LFUN_UNDO,
LFUN_REDO, // 20
LFUN_REDO,
LFUN_MENUSEARCH,
LFUN_PASTE,
LFUN_PASTE, // 20
LFUN_PASTESELECTION,
LFUN_CUT,
LFUN_COPY,
@ -46,9 +46,9 @@ enum kb_action {
LFUN_GOTONOTE,
LFUN_OPENSTUFF,
LFUN_HYPHENATION,
LFUN_HFILL, // 30
LFUN_HFILL,
LFUN_DEPTH,
LFUN_FREE,
LFUN_FREE, // 30
LFUN_TEX,
LFUN_FOOTMELT, // schedule for deletion
LFUN_MARGINMELT, // schedule for deletion
@ -56,9 +56,9 @@ enum kb_action {
LFUN_BOLD,
LFUN_ROMAN,
LFUN_NOUN,
LFUN_RIGHT, // 40
LFUN_RIGHT,
LFUN_LEFT,
LFUN_UP,
LFUN_UP, // 40
LFUN_DOWN,
LFUN_PRIOR,
LFUN_NEXT,
@ -66,9 +66,9 @@ enum kb_action {
LFUN_END,
LFUN_TAB,
LFUN_SHIFT_TAB, // Jug 20000522
LFUN_WORDRIGHT, // 50
LFUN_WORDRIGHT,
LFUN_WORDLEFT,
LFUN_BEGINNINGBUF,
LFUN_BEGINNINGBUF, // 50
LFUN_ENDBUF,
LFUN_RIGHTSEL,
LFUN_LEFTSEL,
@ -76,9 +76,9 @@ enum kb_action {
LFUN_DOWNSEL,
LFUN_PRIORSEL,
LFUN_NEXTSEL,
LFUN_HOMESEL, // 60
LFUN_HOMESEL,
LFUN_ENDSEL,
LFUN_WORDRIGHTSEL,
LFUN_WORDRIGHTSEL, // 60
LFUN_WORDLEFTSEL,
LFUN_BEGINNINGBUFSEL,
LFUN_ENDBUFSEL,
@ -86,9 +86,9 @@ enum kb_action {
LFUN_SETMARK,
LFUN_DELETE,
LFUN_BACKSPACE,
LFUN_BREAKLINE, // 70
LFUN_BREAKLINE,
LFUN_BREAKPARAGRAPH,
LFUN_BREAKPARAGRAPHKEEPLAYOUT,
LFUN_BREAKPARAGRAPHKEEPLAYOUT, // 70
LFUN_QUOTE,
LFUN_CIRCUMFLEX,
LFUN_GRAVE,
@ -96,9 +96,9 @@ enum kb_action {
LFUN_TILDE,
LFUN_CEDILLA,
LFUN_MACRON,
LFUN_UNDERBAR, // 80
LFUN_UNDERBAR,
LFUN_UNDERDOT,
LFUN_CIRCLE,
LFUN_CIRCLE, // 80
LFUN_TIE,
LFUN_BREVE,
LFUN_CARON,
@ -106,9 +106,9 @@ enum kb_action {
LFUN_HUNG_UMLAUT,
LFUN_UMLAUT,
LFUN_DOT,
LFUN_OGONEK, // 90
LFUN_OGONEK,
LFUN_VECTOR, // Alejandro 040696
LFUN_SELFINSERT,
LFUN_SELFINSERT, // 90
LFUN_GETBUFNAME,
LFUN_GETXY,
LFUN_SETXY,
@ -116,9 +116,9 @@ enum kb_action {
LFUN_LINEATCURSOR,
LFUN_GETLAYOUT,
LFUN_GETFONT,
LFUN_GETLATEX, // 100
LFUN_GETLATEX,
LFUN_GETNAME,
LFUN_NOTIFY,
LFUN_NOTIFY, // 100
LFUN_GOTOFILEROW, // Edmar 12/23/98
LFUN_INSERT_NOTE,
LFUN_KMAP_OFF,
@ -126,9 +126,9 @@ enum kb_action {
LFUN_KMAP_SEC,
LFUN_KMAP_TOGGLE,
LFUN_INSERT_MATH,
LFUN_INSERT_MATRIX, // 110
LFUN_INSERT_MATRIX,
LFUN_GREEK,
LFUN_MATH_LIMITS,
LFUN_MATH_LIMITS, // 110
LFUN_GREEK_TOGGLE,
LFUN_MATH_DELIM, // Alejandro 180696
LFUN_MATH_DISPLAY, // was INSERT_EQUATION Alejandro 180696
@ -136,9 +136,9 @@ enum kb_action {
LFUN_MATH_NUMBER, // Alejandro 040696
LFUN_MATH_NONUMBER, // Alejandro 180696
LFUN_MATH_SIZE, // Alejandro 150896
LFUN_MATH_MACRO, // 120 // ale970510
LFUN_MATH_MACRO, // ale970510
LFUN_MATH_MACROARG, // ale970510
LFUN_MATH_PANEL,
LFUN_MATH_PANEL, // 120
LFUN_FIGURE,
LFUN_MELT,
LFUN_DELETE_WORD_FORWARD,
@ -146,91 +146,91 @@ enum kb_action {
LFUN_DELETE_LINE_FORWARD,
LFUN_MARK_OFF,
LFUN_MARK_ON,
LFUN_LAYOUT, // 130
LFUN_LAYOUT,
LFUN_LAYOUTNO, // Lgb 97-06-10
LFUN_LAYOUT_CHARACTER,
LFUN_LAYOUT_CHARACTER, // 130
LFUN_LAYOUT_PARAGRAPH,
LFUN_LAYOUT_DOCUMENT,
LFUN_LAYOUT_PREAMBLE,
LFUN_LAYOUT_SAVE_DEFAULT,
LFUN_DROP_LAYOUTS_CHOICE, // 140
LFUN_DROP_LAYOUTS_CHOICE,
LFUN_CODE,
LFUN_SANS,
LFUN_DEFAULT,
LFUN_UNDERLINE,
LFUN_FONT_SIZE,
LFUN_FONT_SIZE, // 140
LFUN_FONT_STATE,
LFUN_UPCASE_WORD,
LFUN_LOWCASE_WORD,
LFUN_CAPITALIZE_WORD,
LFUN_INSERT_LABEL, // 150
LFUN_INSERT_LABEL,
LFUN_REF_INSERT,
LFUN_PUSH_TOOLBAR,
LFUN_ADD_TO_TOOLBAR,
LFUN_DEPTH_MIN, // RVDK_PATCH_5
LFUN_DEPTH_PLUS, // RVDK_PATCH_5
LFUN_DEPTH_PLUS, // 150 // RVDK_PATCH_5
LFUN_MENU_OPEN_BY_NAME, // RVDK_PATCH_5
LFUN_SPELLCHECK, // RVDK_PATCH_5
LFUN_CANCEL, // RVDK_PATCH_5
LFUN_META_FAKE, // RVDK_PATCH_5
LFUN_EXEC_COMMAND, // 160
LFUN_EXEC_COMMAND,
LFUN_FILE_INSERT,
LFUN_FILE_INSERT_ASCII, // CFO-G 1997-11-19
LFUN_FILE_NEW,
LFUN_FILE_OPEN,
LFUN_UP_PARAGRAPH, // Asger 1996-10-01
LFUN_UP_PARAGRAPH, // 160 // Asger 1996-10-01
LFUN_UP_PARAGRAPHSEL, // Asger 1996-10-01
LFUN_DOWN_PARAGRAPH, // Asger 1996-10-01
LFUN_DOWN_PARAGRAPHSEL, // Asger 1996-10-01
LFUN_BREAKPARAGRAPH_SKIP,
LFUN_BACKSPACE_SKIP, // 170
LFUN_BACKSPACE_SKIP,
LFUN_DELETE_SKIP,
LFUN_MENUNEWTMPLT, // Asger 1997-02-02
LFUN_MENURELOAD, // Asger 1997-02-02
LFUN_FAX, // Asger 1997-02-10
LFUN_RECONFIGURE, // Asger 1997-02-14
LFUN_RECONFIGURE, // 170 // Asger 1997-02-14
LFUN_CITATION_INSERT, // AAS 97-02-23
LFUN_INSERT_BIBTEX, // AAS 97-02-23
LFUN_INDEX_CREATE, // Lgb 97-02-27
LFUN_INDEX_INSERT_LAST, // 180 // Reh 98-09-17
LFUN_INDEX_INSERT_LAST, // Reh 98-09-17
LFUN_INDEX_PRINT, // Lgb 97-02-27
LFUN_APROPOS, // Asger 1997-02-27
LFUN_LATEX_LOG, // Lgb 97-04-05
LFUN_LAYOUT_COPY, // Asger 1997-05-04
LFUN_LAYOUT_PASTE, // Asger 1997-05-04
LFUN_TABINSERT, // Ale 970515
LFUN_TABINSERT, // 180 // Ale 970515
LFUN_CHILDINSERT, // Ale 970521
LFUN_CHILDOPEN, // Ale 970528
LFUN_TOC_INSERT, // Lgb 97-05-27
LFUN_LOA_INSERT, // 190 // Bernhard 97-08-07
LFUN_LOA_INSERT, // Bernhard 97-08-07
LFUN_LOF_INSERT, // Lgb 97-05-27
LFUN_LOT_INSERT, // Lgb 97-05-27
LFUN_READ_ONLY_TOGGLE, // Lgb 97-05-27
LFUN_BIBDB_ADD, // Ale 970530
LFUN_BIBDB_DEL, // Ale 970530
LFUN_BIBTEX_STYLE, // Ale 970530
LFUN_BIBTEX_STYLE, // 190 // Ale 970530
LFUN_GETTIP, // Ale 970603
LFUN_VC_REGISTER, // Lgb 97-07-01
LFUN_VC_CHECKIN, // Lgb 97-07-01
LFUN_VC_CHECKOUT, // 200 // Lgb 97-07-01
LFUN_VC_CHECKOUT, // Lgb 97-07-01
LFUN_VC_REVERT, // Lgb 97-07-01
LFUN_VC_UNDO, // Lgb 97-07-01
LFUN_VC_HISTORY, // Lgb 97-07-01
LFUN_EXPORT, // Lgb 97-07-29
LFUN_INSERTFOOTNOTE, // Bernhard 97-08-07
LFUN_REF_GOTO, // Ale 970806
LFUN_REF_GOTO, // 200 // Ale 970806
LFUN_REF_BACK, // Ale 970806
LFUN_PARENTINSERT, // Ale 970813
LFUN_REMOVEERRORS, // 210 // Asger 970906
LFUN_REMOVEERRORS, // Asger 970906
LFUN_LDOTS, // Asger 970929
LFUN_END_OF_SENTENCE, // Asger 970929
LFUN_RUNCHKTEX, // Asger 971030
LFUN_TOGGLECURSORFOLLOW, // ARRae 971202
LFUN_HTMLURL, // CFO-G 971121
LFUN_URL, // CFO-G 971121
LFUN_WORDFINDFORWARD, // Etienne 980216
LFUN_WORDFINDFORWARD, // 210 // Etienne 980216
LFUN_WORDFINDBACKWARD, // Etienne 980220
LFUN_APPENDIX, // 220 // ettrich 980505
LFUN_APPENDIX, // ettrich 980505
LFUN_IMPORT, // Asger 980724
LFUN_MENU_SEPARATOR, // Asger 990220
LFUN_SEQUENCE, // Andre' 991111
@ -238,27 +238,27 @@ enum kb_action {
LFUN_SAVEPREFERENCES, // Lgb 991127
LFUN_HELP_COPYRIGHT, // ARRae 20000129
LFUN_HELP_CREDITS, // ARRae 981017
LFUN_HELP_OPEN, // Jug 990627
LFUN_HELP_OPEN, // 220 // Jug 990627
LFUN_HELP_VERSION, // Jug 990627
LFUN_DATE_INSERT, // jdblair 20000131
LFUN_LANGUAGE, // Dekel 20000203
LFUN_INSET_TEXT, // Jug 20000214
LFUN_INSET_ERT, // Jug 20000218
LFUN_INSET_GRAPHICS, // 230 // Lgb 20000226
LFUN_INSET_GRAPHICS, // Lgb 20000226
LFUN_INSET_FOOTNOTE, // Jug 20000307
LFUN_PARAGRAPH_SPACING, // Lgb 20000411
LFUN_INSET_TABULAR, // Jug 20000412
LFUN_LOFVIEW, // Dekel 20000519
LFUN_LOFVIEW, // 230 // Dekel 20000519
LFUN_LOTVIEW, // Dekel 20000519
LFUN_LOAVIEW, // Dekel 20000519
LFUN_SET_COLOR, // SLior 20000611
LFUN_INSET_EXTERNAL, // Alstrup 20000609
LFUN_INSET_MARGINAL, // Lgb 20000626
LFUN_INSET_MINIPAGE, // 240 // Lgb 20000627
LFUN_INSET_MINIPAGE, // Lgb 20000627
LFUN_INSET_FLOAT, // Lgb 20000627
LFUN_INSET_LIST, // Lgb 20000627
LFUN_INSET_THEOREM, // Lgb 20000630
LFUN_CITATION_CREATE, // Angus 20000705
LFUN_CITATION_CREATE, // 240 // Angus 20000705
LFUN_INSET_CAPTION, // Lgb 20000718
LFUN_SWITCHBUFFER, // and where is this comming from?
LFUN_INSERT_URL, // Angus 20000726
@ -268,7 +268,7 @@ enum kb_action {
LFUN_UPDATE, // Dekel 20000805
LFUN_INDEX_INSERT, // Angus 20000803
LFUN_SCREEN_FONT_UPDATE, // ARRae 20000813
LFUN_DIALOG_TABULAR_INSERT, // Jug 20000825 (old table-insert)
LFUN_DIALOG_TABULAR_INSERT, // 250 // Jug 20000825 (old table-insert)
LFUN_GOTO_PARAGRAPH, // Dekel 20000826
LFUN_LASTACTION /* this marks the end of the table */
};

View File

@ -52,6 +52,14 @@ static error_item errorTags[] = {
static const int numErrorTags = sizeof(errorTags)/sizeof(error_item);
Debug::type const Debug::ANY = Debug::type(
Debug::INFO | Debug::INIT | Debug::KEY | Debug::GUI |
Debug::PARSER | Debug::LYXRC | Debug::KBMAP | Debug::LATEX |
Debug::MATHED | Debug::FONT | Debug::TCLASS | Debug::LYXVC |
Debug::LYXSERVER | Debug::ROFF | Debug::ACTION | Debug::LYXLEX |
Debug::DEPEND | Debug::INSETS);
Debug::type Debug::value(string const & val)
{

View File

@ -68,13 +68,16 @@ struct Debug {
INSETS = (1 << 17)
};
///
static const type ANY = type(INFO | INIT | KEY | GUI |
PARSER | LYXRC | KBMAP | LATEX |
MATHED | FONT | TCLASS | LYXVC |
LYXSERVER | ROFF | ACTION | LYXLEX |
DEPEND | INSETS);
// static const type ANY = type(INFO | INIT | KEY | GUI |
// PARSER | LYXRC | KBMAP | LATEX |
// MATHED | FONT | TCLASS | LYXVC |
// LYXSERVER | ROFF | ACTION | LYXLEX |
// DEPEND | INSETS);
///
friend inline void operator|=(Debug::type & d1, Debug::type d2);
static type const ANY;
///
// friend inline void operator|=(Debug::type & d1, Debug::type d2);
/** A function to convert symbolic string names on debug levels
to their numerical value.
@ -94,7 +97,7 @@ struct Debug {
inline
void operator|= (Debug::type & d1, Debug::type d2)
void operator|=(Debug::type & d1, Debug::type d2)
{
d1 = static_cast<Debug::type>(d1 | d2);
}

View File

@ -84,7 +84,7 @@ bool Exporter::Preview(Buffer * buffer, string const & format0)
bool Exporter::IsExportable(Buffer const * buffer, string const & format)
{
#warning This is not efficient (Dekel)
// This is not efficient (Dekel)
vector<pair<string, string> > const v = GetExportableFormats(buffer);
for (vector<pair<string, string> >::const_iterator it = v.begin();
it != v.end(); ++it) {
@ -96,6 +96,7 @@ bool Exporter::IsExportable(Buffer const * buffer, string const & format)
return false;
}
vector<pair<string, string> > const
Exporter::GetExportableFormats(Buffer const * buffer)
{

View File

@ -109,13 +109,14 @@ int lyxfont::width(char const * s, size_t n, LyXFont const & f)
if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) {
XChar2b * xs = new XChar2b[n];
Encoding const * encoding = f.language()->encoding();
LyXFont const * font = &f;
//LyXFont const * font = &f;
LyXFont font(f);
if (f.family() == LyXFont::SYMBOL_FAMILY) {
#ifdef USE_UNICODE_FOR_SYMBOLS
LyXFont font2 = f;
font2.setFamily(LyXFont::ROMAN_FAMILY);
font2.setShape(LyXFont::UP_SHAPE);
font = &font2;
//LyXFont font2 = f;
font.setFamily(LyXFont::ROMAN_FAMILY);
font.setShape(LyXFont::UP_SHAPE);
//font = &font2;
#endif
encoding = encodings.symbol_encoding();
}
@ -124,7 +125,7 @@ int lyxfont::width(char const * s, size_t n, LyXFont const & f)
xs[i].byte1 = c >> 8;
xs[i].byte2 = c & 0xff;
}
int result = width(xs, n, *font);
int result = width(xs, n, font);
delete[] xs;
return result;
}

View File

@ -115,7 +115,7 @@ void FormCitation::update()
bool bibPresent = ( bibkeys.size() > 0 );
setSize( size, bibPresent );
fl_set_input( dialog_->textAftr, params.getOptions().c_str() );
fl_set_input( dialog_->textAftr, params.getOptions().c_str());
}
@ -125,7 +125,7 @@ void FormCitation::updateBrowser( FL_OBJECT * browser,
fl_clear_browser( browser );
for( unsigned int i = 0; i < keys.size(); ++i )
fl_add_browser_line( browser, keys[i].c_str() );
fl_add_browser_line( browser, keys[i].c_str());
}
@ -305,7 +305,7 @@ bool FormCitation::input( FL_OBJECT *, long data )
// the selected bibBrsr key
fl_clear_browser( dialog_->infoBrsr );
fl_add_browser_line( dialog_->infoBrsr,
bibkeysInfo[sel-1].c_str() );
bibkeysInfo[sel - 1].c_str() );
// Highlight the selected bibBrsr key in citeBrsr if present
vector<string>::iterator it =

View File

@ -146,7 +146,7 @@ void FormDocument::build()
for (LyXTextClassList::const_iterator cit = textclasslist.begin();
cit != textclasslist.end(); ++cit)
{
combo_doc_class->addto((*cit).description().c_str());
combo_doc_class->addto((*cit).description());
}
#else
fl_clear_choice(class_->choice_doc_class);
@ -207,7 +207,7 @@ void FormDocument::build()
#endif
for(Languages::const_iterator cit = languages.begin();
cit != languages.end(); ++cit) {
combo_language->addto((*cit).second.lang().c_str());
combo_language->addto((*cit).second.lang());
}
fl_addto_choice(language_->choice_quotes_language,
@ -391,9 +391,9 @@ bool FormDocument::class_apply()
params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
#ifdef USE_CLASS_COMBO
unsigned int new_class = combo_doc_class->get() - 1;
unsigned int const new_class = combo_doc_class->get() - 1;
#else
unsigned int new_class = fl_get_choice(class_->choice_doc_class) - 1;
unsigned int const new_class = fl_get_choice(class_->choice_doc_class) - 1;
#endif
if (params.textclass != new_class) {
// try to load new_class
@ -621,7 +621,7 @@ void FormDocument::class_update(BufferParams const & params)
#ifdef USE_CLASS_COMBO
combo_doc_class->select_text(
textclasslist.DescOfClass(params.textclass).c_str());
textclasslist.DescOfClass(params.textclass));
#else
fl_set_choice_text(class_->choice_doc_class,
textclasslist.DescOfClass(params.textclass).c_str());
@ -712,7 +712,7 @@ void FormDocument::language_update(BufferParams const & params)
if (!language_)
return;
combo_language->select_text(params.language->lang().c_str());
combo_language->select_text(params.language->lang());
fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
fl_set_button(language_->radio_single, 0);
@ -1024,7 +1024,7 @@ void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb)
}
new_panel += ".xpm";
fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
LibFileSearch("images", new_panel.c_str()).c_str());
LibFileSearch("images", new_panel).c_str());
fl_redraw_object(bullets_->bmtable_bullet_panel);
fl_unfreeze_form(bullets_->form);
}
@ -1055,15 +1055,13 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
ob = class_->choice_doc_class;
ProhibitInput(lv_->view());
int tc;
string tct;
#ifdef USE_CLASS_COMBO
tc = combo_doc_class->get() - 1;
tct = combo_doc_class->getline();
int tc = combo_doc_class->get() - 1;
string tct = combo_doc_class->getline();
#else
tc = fl_get_choice(ob) - 1;
tct = fl_get_choice_text(ob);
int tc = fl_get_choice(ob) - 1;
string tct = fl_get_choice_text(ob);
#endif
if (textclasslist.Load(tc)) {
if (AskQuestion(_("Should I set some parameters to"), tct,

View File

@ -424,10 +424,10 @@ string FormGraphics::browseFile(string const & filename)
void FormGraphics::browse()
{
// Get the filename from the dialog
string filename = fl_get_input(dialog_->input_filename);
string const filename = fl_get_input(dialog_->input_filename);
// Show the file browser dialog
string new_filename = browseFile(filename);
string const new_filename = browseFile(filename);
// Save the filename to the dialog
if (new_filename != filename && ! new_filename.empty()) {

View File

@ -364,12 +364,12 @@ void FormParagraph::general_update()
case VSpace::LENGTH:
fl_set_choice (general_->choice_space_above, 7);
#ifndef NEW_INSETS
fl_set_input (general_->input_space_above,
text->cursor.par()->FirstPhysicalPar()->
added_space_top.length().asString().c_str());
fl_set_input(general_->input_space_above,
text->cursor.par()->FirstPhysicalPar()->
added_space_top.length().asString().c_str());
#else
fl_set_input (general_->input_space_above, text->cursor.par()->
added_space_top.length().asString().c_str());
fl_set_input(general_->input_space_above, text->cursor.par()->
added_space_top.length().asString().c_str());
#endif
break;
}
@ -407,9 +407,9 @@ void FormParagraph::general_update()
case VSpace::LENGTH:
fl_set_choice (general_->choice_space_below, 7);
#ifndef NEW_INSETS
fl_set_input (general_->input_space_below,
text->cursor.par()->FirstPhysicalPar()->
added_space_bottom.length().asString().c_str());
fl_set_input(general_->input_space_below,
text->cursor.par()->FirstPhysicalPar()->
added_space_bottom.length().asString().c_str());
break;
}
fl_set_button(general_->check_space_below,
@ -703,7 +703,7 @@ bool FormParagraph::input(FL_OBJECT * ob, long)
fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
fl_activate_object(extra_->input_pextra_widthp);
fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
if ((atoi(s2.c_str()) < 0 ) || (atoi(s2.c_str()) > 100)) {
if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) {
ret = false;
fl_set_object_label(dialog_->text_warning,
_("Warning: Invalid percent value (0-100)"));

View File

@ -14,7 +14,6 @@
#include <config.h>
#include <algorithm>
//#include <cctype>
#include "support/lstrings.h"
#include "support/LAssert.h"
#include "debug.h"
@ -37,16 +36,16 @@ extern kb_keymap * toplevel_keymap;
extern LyXAction lyxaction;
// Some constants
const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
const int mheight = 30;
const int mbheight= 22;
static const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
static const int mheight = 30;
static const int mbheight= 22;
// where to place the menubar?
const int yloc = (mheight - mbheight)/2; //air + bw;
const int mbadd = 20; // menu button add (to width)
static const int yloc = (mheight - mbheight)/2; //air + bw;
static const int mbadd = 20; // menu button add (to width)
// Some space between buttons on the menubar
const int air = 2;
char const * menu_tabstop = "aa";
char const * default_tabstop = "aaaaaaaa";
static const int air = 2;
static char const * menu_tabstop = "aa";
static char const * default_tabstop = "aaaaaaaa";
//Defined later, used in makeMenubar().
extern "C"
@ -186,7 +185,7 @@ string limit_string_length(string const & str)
string::size_type const max_item_length = 45;
if (str.size() > max_item_length)
return str.substr(0, max_item_length-3) + "...";
return str.substr(0, max_item_length - 3) + "...";
else
return str;
}
@ -303,11 +302,11 @@ void Menubar::Pimpl::add_toc(int menu, string const & extra_label,
fl_addtopup(menu2, label.c_str());
}
if (j == max_nonempty) {
string label = _(MenuNames[j-1]);
string label = _(MenuNames[j - 1]);
label += "%l";
fl_addtopup(menu, label.c_str(), menu2);
} else
fl_addtopup(menu, _(MenuNames[j-1]), menu2);
fl_addtopup(menu, _(MenuNames[j - 1]), menu2);
}
// Handle normal TOC
@ -569,7 +568,8 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
string shortcut = item.shortcut();
if (!shortcut.empty()) {
shortcut += lowercase(shortcut[0]);
fl_addtopup(menu, (label + "%h").c_str(),
label += "%h";
fl_addtopup(menu, label.c_str(),
submenu, shortcut.c_str());
}
else {

View File

@ -220,15 +220,16 @@ void Toolbar::Pimpl::updateLayoutList(bool force)
for (LyXTextClass::const_iterator cit = tc.begin();
cit != end; ++cit) {
if ((*cit).obsoleted_by().empty())
combox->addline(_((*cit).name().c_str()));
combox->addline(_((*cit).name()));
else
combox->addline(("@N" + string(_((*cit).name().c_str()))).c_str());
combox->addline("@N" + _((*cit).name()));
}
}
// we need to do this.
combox->Redraw();
}
void Toolbar::Pimpl::clearLayoutList()
{
if (combox) {
@ -237,12 +238,14 @@ void Toolbar::Pimpl::clearLayoutList()
}
}
void Toolbar::Pimpl::openLayoutList()
{
if (combox)
combox->Show();
}
static
void ToolbarCB(FL_OBJECT * ob, long ac)
{
@ -260,6 +263,7 @@ extern "C" void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
ToolbarCB(ob, data);
}
#if 0
// What are we supposed to do with that??
int Toolbar::get_toolbar_func(string const & func)

22
src/gettext.C Normal file
View File

@ -0,0 +1,22 @@
#include <config.h>
#include "LString.h"
#include "gettext.h"
char const * _(char const * str)
{
return gettext(str);
}
string const _(string const & str)
{
int const s = str.length();
char * tmp = new char[s + 1];
str.copy(tmp, s);
tmp[s] = '\0';
string ret(_(tmp));
delete [] tmp;
return ret;
}

View File

@ -32,6 +32,8 @@
#ifdef ENABLE_NLS
#include "LString.h"
# if HAVE_GETTEXT
# include <libintl.h> // use the header already in the system *EK*
# ifdef HAVE_LOCALE_H
@ -41,7 +43,11 @@
# include "../intl/libintl.h"
# endif
# define _(str) gettext(str)
char const * _(char const *);
string const _(string const &);
//# define _(str) gettext(str)
# define N_(str) (str) // for detecting static strings
# ifdef HAVE_LC_MESSAGES
@ -56,6 +62,8 @@
///
# define _(str) (str)
///
# define S_(str) (str)
///
# define N_(str) (str)
///
# define locale_init()

View File

@ -41,7 +41,7 @@ GraphicsCacheItem_pimpl::GraphicsCacheItem_pimpl()
GraphicsCacheItem_pimpl::~GraphicsCacheItem_pimpl()
{
if (imageStatus_ == GraphicsCacheItem::Loaded) {
XFreePixmap(fl_display, pixmap_);
XFreePixmap(fl_get_display(), pixmap_);
}
delete renderer;

View File

@ -99,5 +99,5 @@ string const & Renderer::getFilename() const
void Renderer::freePixmap()
{
if (pixmapLoaded_)
XFreePixmap(fl_display, pixmap_);
XFreePixmap(fl_get_display(), pixmap_);
}

View File

@ -44,7 +44,7 @@ bool XPM_Renderer::renderImage()
//(BE 2000-08-05)
#warning This might be a dirty thing, but I dont know any other solution.
Screen * screen = DefaultScreenOfDisplay(display);
Screen * screen = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(display);
int status = XpmReadFileToPixmap(
display,

View File

@ -74,6 +74,7 @@ using std::find;
using std::flush;
using std::endl;
using std::ostringstream;
using std::copy;
extern BufferView * current_view;
extern FL_OBJECT * figinset_canvas;
@ -113,14 +114,14 @@ static
GC createGC()
{
XGCValues val;
val.foreground = BlackPixel(fl_display,
DefaultScreen(fl_display));
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_display, RootWindow(fl_display, 0),
return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
GCForeground | GCFunction | GCGraphicsExposures
| GCLineWidth | GCLineStyle , &val);
}
@ -137,10 +138,8 @@ void addpidwait(int pid)
if (lyxerr.debugging()) {
lyxerr << "Pids to wait for: \n";
for (list<int>::const_iterator cit = pidwaitlist.begin();
cit != pidwaitlist.end(); ++cit) {
lyxerr << (*cit) << '\n';
}
copy(pidwaitlist.begin(), pidwaitlist.end(),
ostream_iterator<int>(lyxerr, "\n"));
lyxerr << flush;
}
}
@ -200,11 +199,11 @@ int GhostscriptMsg(FL_OBJECT *, Window, int, int,
Display * tmpdisp;
GC gc = local_gc_copy;
XGetWindowAttributes(fl_display,
XGetWindowAttributes(fl_get_display(),
fl_get_canvas_id(
figinset_canvas),
&wa);
XFlush(fl_display);
XFlush(fl_get_display());
if (lyxerr.debugging()) {
lyxerr << "Starting image translation "
<< p->bitmap << " "
@ -219,7 +218,7 @@ int GhostscriptMsg(FL_OBJECT *, Window, int, int,
lyxerr.debug()
<< "Cannot fork, using slow "
"method for pixmap translation." << endl;
tmpdisp = fl_display;
tmpdisp = fl_get_display();
} else if (forkstat > 0) { // parent
// register child
if (lyxerr.debugging()) {
@ -318,9 +317,9 @@ void AllocColors(int num)
xcol.green = short(65535 * ((i / num) % num) / (num - 1));
xcol.blue = short(65535 * (i % num) / (num - 1));
xcol.flags = DoRed | DoGreen | DoBlue;
if (!XAllocColor(fl_display,
if (!XAllocColor(fl_get_display(),
fl_state[fl_get_vclass()].colormap, &xcol)) {
if (i) XFreeColors(fl_display,
if (i) XFreeColors(fl_get_display(),
fl_state[fl_get_vclass()].colormap,
gs_pixels, i, 0);
if(lyxerr.debugging()) {
@ -356,9 +355,9 @@ void AllocGrays(int num)
for (int i = 0; i < num; ++i) {
xcol.red = xcol.green = xcol.blue = short(65535 * i / (num - 1));
xcol.flags = DoRed | DoGreen | DoBlue;
if (!XAllocColor(fl_display,
if (!XAllocColor(fl_get_display(),
fl_state[fl_get_vclass()].colormap, &xcol)) {
if (i) XFreeColors(fl_display,
if (i) XFreeColors(fl_get_display(),
fl_state[fl_get_vclass()].colormap,
gs_pixels, i, 0);
if (lyxerr.debugging()) {
@ -391,8 +390,8 @@ void InitFigures()
local_gc_copy = createGC();
Visual * vi = DefaultVisual(fl_display,
DefaultScreen(fl_display));
Visual * vi = DefaultVisual(fl_get_display(),
DefaultScreen(fl_get_display()));
if (lyxerr.debugging()) {
printf("Visual ID: %ld, class: %d, bprgb: %d, mapsz: %d\n",
vi->visualid, vi->c_class,
@ -445,7 +444,7 @@ void freefigdata(figdata * tmpdata)
kill_gs(pid, SIGKILL);
}
if (tmpdata->bitmap) XFreePixmap(fl_display, tmpdata->bitmap);
if (tmpdata->bitmap) XFreePixmap(fl_get_display(), tmpdata->bitmap);
bitmaps.erase(find(bitmaps.begin(), bitmaps.end(), tmpdata));
delete tmpdata;
}
@ -732,12 +731,12 @@ figdata * getfigdata(int wid, int hgh, string const & fname,
p->flags = flags;
bitmaps.push_back(p);
XWindowAttributes wa;
XGetWindowAttributes(fl_display, fl_get_canvas_id(
XGetWindowAttributes(fl_get_display(), fl_get_canvas_id(
figinset_canvas), &wa);
if (lyxerr.debugging()) {
lyxerr << "Create pixmap disp:" << fl_display
<< " scr:" << DefaultScreen(fl_display)
lyxerr << "Create pixmap disp:" << fl_get_display()
<< " scr:" << DefaultScreen(fl_get_display())
<< " w:" << wid
<< " h:" << hgh
<< " depth:" << wa.depth << endl;
@ -748,7 +747,7 @@ figdata * getfigdata(int wid, int hgh, string const & fname,
p->broken = false;
p->gspid = -1;
if (flags) {
p->bitmap = XCreatePixmap(fl_display, fl_get_canvas_id(
p->bitmap = XCreatePixmap(fl_get_display(), fl_get_canvas_id(
figinset_canvas), wid, hgh, wa.depth);
p->gsdone = false;
// initialize reading of .eps file with correct sizes and stuff
@ -995,7 +994,7 @@ void InsetFig::draw(BufferView * bv, LyXFont const & f,
wid + 1, hgh + 1);
} else {
char * msg = 0;
char const * msg = 0;
string lfname = fname;
if (!fname.empty() && GetExtension(fname).empty())
lfname += ".eps";

View File

@ -137,7 +137,6 @@ void InsetExternal::browseCB(FL_OBJECT * ob, long)
bool error = false;
do {
// ProhibitInput(current_view);
if (once) {
p = fileDlg.Select(_("External inset file"),
current_path,
@ -146,7 +145,6 @@ void InsetExternal::browseCB(FL_OBJECT * ob, long)
p = fileDlg.Select(_("External inset file"), buf,
regexp, string());
}
// AllowInput(current_view);
if (p.empty()) return;

View File

@ -112,7 +112,7 @@ void InsetText::init(InsetText const * ins)
InsetText::~InsetText()
{
for(Cache::const_iterator cit=cache.begin(); cit != cache.end(); ++cit)
for(Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit)
delete (*cit).second;
// deleteLyXText((*cit).first);
LyXParagraph * p = par->next;

View File

@ -135,7 +135,7 @@ void Intl::KeyMapPrim()
fl_set_button(fd_form_keymap->KeyOnBtn2, 0);
/* read text from choice */
int i = Language->get();
int const i = Language->get();
string p;
if (i == otherkeymap)
@ -166,7 +166,7 @@ void Intl::KeyMapSec()
fl_set_button(fd_form_keymap->KeyOnBtn2, 1);
/* read text from choice */
int i = Language2->get();
int const i = Language2->get();
string p;
if (i == otherkeymap)
@ -291,7 +291,7 @@ void Intl::InitKeyMapper(bool on)
Language2->addto(_("other..."));
otherkeymap = n + 1;
if (!Language->select_text(prim_lang)) {
Language->select(n+1);
Language->select(n + 1);
fl_set_input(fd_form_keymap->OtherKeymap, prim_lang.c_str());
}
else

View File

@ -232,7 +232,7 @@ kb_keymap::~kb_keymap()
{
// This could be done by a destructor in kb_key.
Table::iterator end = table.end();
for(Table::iterator it = table.begin(); it != end; ++it) {
for (Table::iterator it = table.begin(); it != end; ++it) {
delete (*it).table;
}
}
@ -253,7 +253,7 @@ string const kb_keymap::findbinding(int act) const
if (table.empty()) return res;
Table::const_iterator end = table.end();
for(Table::const_iterator cit = table.begin();
for (Table::const_iterator cit = table.begin();
cit != end; ++cit) {
if ((*cit).table) {
string suffix = (*cit).table->findbinding(act);
@ -265,7 +265,9 @@ string const kb_keymap::findbinding(int act) const
+ suffix + "] ";
}
} else if ((*cit).action == act) {
res += "[" + keyname((*cit)) + "] ";
res += "[";
res += keyname((*cit));
res += "] ";
}
}
return res;

View File

@ -24,6 +24,7 @@
#include "debug.h"
#include "gettext.h"
#include "support/LAssert.h"
#include "support/lyxfunctional.h"
using std::pair;
using std::make_pair;
@ -1142,49 +1143,43 @@ void LyXTextClass::readClassOptions(LyXLex & lexrc)
bool LyXTextClass::hasLayout(string const & name) const
{
for (LayoutList::const_iterator cit = layoutlist.begin();
cit != layoutlist.end(); ++cit) {
if ((*cit).name() == name)
return true;
}
return false;
return find_if(layoutlist.begin(), layoutlist.end(),
compare_memfun(&LyXLayout::name, name))
!= layoutlist.end();
}
LyXLayout const & LyXTextClass::GetLayout (string const & name) const
{
for (LayoutList::const_iterator cit = layoutlist.begin();
cit != layoutlist.end(); ++cit) {
if ((*cit).name() == name)
return (*cit);
}
Assert(false); // we actually require the name to exist.
return layoutlist.front();
LayoutList::const_iterator cit =
find_if(layoutlist.begin(),
layoutlist.end(),
compare_memfun(&LyXLayout::name, name));
Assert(cit != layoutlist.end()); // we require the name to exist
return (*cit);
}
LyXLayout & LyXTextClass::GetLayout(string const & name)
{
for (LayoutList::iterator it = layoutlist.begin();
it != layoutlist.end(); ++it) {
if ((*it).name() == name)
return (*it);
}
Assert(false); // we actually require the name to exist.
return layoutlist.front();
LayoutList::iterator it =
find_if(layoutlist.begin(),
layoutlist.end(),
compare_memfun(&LyXLayout::name, name));
Assert(it != layoutlist.end()); // we require the name to exist
return (*it);
}
bool LyXTextClass::delete_layout (string const & name)
bool LyXTextClass::delete_layout(string const & name)
{
for(LayoutList::iterator it = layoutlist.begin();
it != layoutlist.end(); ++it) {
if ((*it).name() == name) {
layoutlist.erase(it);
return true;
}
}
return false;
LayoutList::iterator it =
remove_if(layoutlist.begin(), layoutlist.end(),
compare_memfun(&LyXLayout::name, name));
LayoutList::iterator end = layoutlist.end();
bool const ret = (it != end);
layoutlist.erase(it, end);
return ret;
}
@ -1194,7 +1189,7 @@ void LyXTextClass::load()
if (loaded) return;
// Read style-file
string real_file = LibFileSearch("layouts", name_, "layout");
string const real_file = LibFileSearch("layouts", name_, "layout");
if (Read(real_file)) {
lyxerr << "Error reading `"
@ -1213,13 +1208,12 @@ void LyXTextClass::load()
pair<bool, LyXTextClassList::size_type> const
LyXTextClassList::NumberOfClass(string const & textclass) const
{
for (ClassList::const_iterator cit = classlist.begin();
cit != classlist.end(); ++cit) {
if ((*cit).name() == textclass)
return make_pair(true,
size_type(cit - classlist.begin()));
}
return make_pair(false, size_type(0));
ClassList::const_iterator cit =
find_if(classlist.begin(), classlist.end(),
compare_memfun(&LyXTextClass::name, textclass));
return cit != classlist.end() ?
make_pair(true, size_type(cit - classlist.begin())) :
make_pair(false, size_type(0));
}

View File

@ -180,7 +180,7 @@ void ShowMessage(Buffer const * buf,
// should be moved to lyxfunc.C
bool MenuWrite(Buffer * buffer)
{
XFlush(fl_display);
XFlush(fl_get_display());
if (!buffer->save()) {
string fname = buffer->fileName();
string s = MakeAbsPath(fname);
@ -732,7 +732,7 @@ LyXFont const UserFreeFont(BufferParams const & params)
case 11: font.setColor(LColor::inherit); break;
}
int choice = combo_language2->get();
int const choice = combo_language2->get();
if (choice == 1)
font.setLanguage(ignore_language);
else if (choice == 2)

View File

@ -78,7 +78,6 @@ FL_resource res[] =
extern "C"
int LyX_XErrHandler(Display * display, XErrorEvent * xeev)
{
//#warning Please see if you can trigger this!
// emergency save
if (!bufferlist.empty())
bufferlist.emergencyWriteAll();
@ -131,25 +130,25 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
// If width is not set by geometry, check it against monitor width
if ( !(geometryBitmask & 4) ) {
Screen * scr = DefaultScreenOfDisplay(fl_get_display());
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(fl_get_display());
if (WidthOfScreen(scr) - 8 < width)
width = WidthOfScreen(scr) - 8;
}
// If height is not set by geometry, check it against monitor height
if ( !(geometryBitmask & 8) ) {
Screen * scr = DefaultScreenOfDisplay(fl_get_display());
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(fl_get_display());
if (HeightOfScreen(scr) - 24 < height)
height = HeightOfScreen(scr) - 24;
}
// Recalculate xpos if it's negative
if (geometryBitmask & 16)
xpos += WidthOfScreen(DefaultScreenOfDisplay(fl_get_display())) - width;
xpos += WidthOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen)) - width; //DefaultScreen(fl_get_display())) - width;
// Recalculate ypos if it's negative
if (geometryBitmask & 32)
ypos += HeightOfScreen(DefaultScreenOfDisplay(fl_get_display())) - height;
ypos += HeightOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen)) - height; //DefaultScreen(fl_get_display())) - height;
// Initialize the LyXColorHandler
lyxColorHandler = new LyXColorHandler;
@ -333,7 +332,7 @@ void LyXGUI::create_forms()
#ifdef DO_USE_DEFAULT_LANGUAGE
if ((*cit).second.lang() != "default")
#endif
combo_language2->addto((*cit).second.lang().c_str());
combo_language2->addto((*cit).second.lang());
}
combo_language2->select_text(_("No change"));

View File

@ -397,7 +397,7 @@ void WarnReadonly(string const & file)
/// Get the dpi setting of the current screen
float getScreenDPI()
{
Screen * scr = DefaultScreenOfDisplay(fl_get_display());
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(fl_get_display());
return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
(WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
}

View File

@ -449,6 +449,7 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
// lyxserver = new LyXServer;
}
// These are the default bindings known to LyX
void LyX::defaultKeyBindings(kb_keymap * kbmap)
{
@ -498,6 +499,7 @@ void LyX::defaultKeyBindings(kb_keymap * kbmap)
kbmap->bind("S-Tab", LFUN_SHIFT_TAB); // jug20000522
}
// LyX can optionally take over the handling of deadkeys
void LyX::deadKeyBindings(kb_keymap * kbmap)
{
@ -525,7 +527,6 @@ void LyX::deadKeyBindings(kb_keymap * kbmap)
}
// This one is not allowed to use anything on the main form, since that
// one does not exist yet. (Asger)
void LyX::queryUserLyXDir(bool explicit_userdir)
@ -680,6 +681,7 @@ void LyX::ReadEncodingsFile(string const & name)
// Set debugging level and report result to user
static
void setDebuggingLevel(string const & dbgLevel)
{
lyxerr << _("Setting debug level to ") << dbgLevel << endl;
@ -689,6 +691,7 @@ void setDebuggingLevel(string const & dbgLevel)
// Give command line help
static
void commandLineHelp()
{
lyxerr << "LyX " LYX_VERSION << " of " LYX_RELEASE << endl;
@ -705,6 +708,7 @@ void commandLineHelp()
"Check the LyX man page for more options.") << endl;
}
bool LyX::easyParse(int * argc, char * argv[])
{
bool gui = true;

View File

@ -408,7 +408,7 @@ string const LyXFont::stateText(BufferParams * params) const
if (bits == inherit)
ost << _("Default") << ", ";
if (!params || (language() != params->language))
ost << _("Language: ") << _(language()->display().c_str()) << ", ";
ost << _("Language: ") << _(language()->display()) << ", ";
if (number() != OFF)
ost << _(" Number ") << _(GUIMiscNames[number()]);

View File

@ -68,6 +68,7 @@
#include "support/syscall.h"
#include "support/lstrings.h"
#include "support/path.h"
#include "support/lyxfunctional.h"
#include "debug.h"
#include "lyxrc.h"
#include "lyxtext.h"
@ -1207,17 +1208,21 @@ string const LyXFunc::Dispatch(int ac,
break;
}
case LFUN_HELP_VERSION:
case LFUN_HELP_VERSION: {
ProhibitInput(owner->view());
fl_show_message((string(_("LyX Version ")) + LYX_VERSION
+ _(" of ") + LYX_RELEASE).c_str(),
string msg(_("LyX Version "));
msg += LYX_VERSION;
msg += " of ";
msg += LYX_RELEASE;
fl_show_message(msg.c_str(),
(_("Library directory: ")
+ MakeDisplayPath(system_lyxdir)).c_str(),
(_("User directory: ")
+ MakeDisplayPath(user_lyxdir)).c_str());
AllowInput(owner->view());
break;
}
// --- version control -------------------------------
case LFUN_VC_REGISTER:
{
@ -2432,7 +2437,7 @@ string const LyXFunc::Dispatch(int ac,
case LFUN_GOTOFILEROW:
{
char file_name[100];
int row;
int row;
::sscanf(argument.c_str(), " %s %d", file_name, &row);
// Must replace extension of the file to be .lyx and get full path
@ -3052,8 +3057,10 @@ string const LyXFunc::Dispatch(int ac,
}
}
} else {
owner->getMiniBuffer()->Set(string(_(res.c_str()))
+ " " + commandshortcut);
string msg(_(res));
msg += " ";
msg += commandshortcut;
owner->getMiniBuffer()->Set(msg);
}
return res;
@ -3069,7 +3076,8 @@ void LyXFunc::setupLocalKeymap()
void LyXFunc::MenuNew(bool fromTemplate)
{
string fname, initpath = lyxrc.document_path;
string fname;
string initpath = lyxrc.document_path;
LyXFileDlg fileDlg;
if (owner->view()->available()) {
@ -3132,7 +3140,7 @@ void LyXFunc::MenuNew(bool fromTemplate)
// loads document
owner->getMiniBuffer()->Set(_("Opening document"),
MakeDisplayPath(s), "...");
XFlush(fl_display);
XFlush(fl_get_display());
owner->view()->buffer(
bufferlist.loadLyXFile(s));
owner->getMiniBuffer()->Set(_("Document"),
@ -3482,13 +3490,12 @@ Inset * LyXFunc::getInsetByCode(Inset::Code code)
{
LyXCursor cursor = owner->view()->text->cursor;
Buffer * buffer = owner->view()->buffer();
for (Buffer::inset_iterator it = Buffer::inset_iterator(cursor.par(),
cursor.pos());
it != buffer->inset_iterator_end(); ++it) {
if ((*it)->LyxCode() == code)
return *it;
}
return 0;
Buffer::inset_iterator it =
find_if(Buffer::inset_iterator(cursor.par(),
cursor.pos()),
buffer->inset_iterator_end(),
compare_memfun(&Inset::LyxCode, code));
return it != buffer->inset_iterator_end() ? (*it) : 0;
}

View File

@ -148,9 +148,15 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
c = cc;
if (c == '#') {
// Read rest of line (fast :-)
// That is not fast... (Lgb)
#if 1
is.getline(buff, sizeof(buff));
lyxerr[Debug::LYXLEX] << "Comment read: `" << c
<< buff << "'" << endl;
#else
// unfortunately is ignore buggy (Lgb)
is.ignore(100, '\n');
#endif
++lineno;
continue;
}
@ -258,9 +264,16 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
if (c == '#') {
// Read rest of line (fast :-)
// That is still not fast... (Lgb)
#if 1
is.getline(buff, sizeof(buff));
lyxerr[Debug::LYXLEX] << "Comment read: `" << c
<< buff << "'" << endl;
#else
// but ignore is also still buggy (Lgb)
// This is fast (Lgb)
is.ignore(100, '\n');
#endif
++lineno;
continue;
}

View File

@ -647,7 +647,7 @@ public:
///
Inset * operator*() { return (*it).inset; }
///
size_type getPos() {return (*it).pos; }
size_type getPos() const {return (*it).pos; }
///
bool operator==(inset_iterator const & iter) const {
return it == iter.it;

View File

@ -583,7 +583,7 @@ void InsetFormula::ToggleInsetSelection(BufferView * bv)
//int n;
//XPoint * p =
//mathcursor->SelGetArea(n);
// XFillPolygon(fl_display, pm, LyXGetSelectionGC(), p, n, Nonconvex, CoordModeOrigin);
// XFillPolygon(fl_get_display(), pm, LyXGetSelectionGC(), p, n, Nonconvex, CoordModeOrigin);
// x -= par->xo;
// y -= par->yo;
@ -781,8 +781,7 @@ InsetFormula::LocalDispatch(BufferView * bv,
result = DISPATCHED_NOUPDATE;
break;
case LFUN_DELETE_LINE_FORWARD:
//current_view->lockedInsetStoreUndo(Undo::INSERT);
bv->lockedInsetStoreUndo(Undo::DELETE);
bv->lockedInsetStoreUndo(Undo::DELETE);
mathcursor->DelLine();
UpdateLocal(bv);
break;
@ -812,8 +811,7 @@ InsetFormula::LocalDispatch(BufferView * bv,
}
case LFUN_DELETE:
//current_view->lockedInsetStoreUndo(Undo::INSERT);
bv->lockedInsetStoreUndo(Undo::DELETE);
bv->lockedInsetStoreUndo(Undo::DELETE);
mathcursor->Delete();
bv->updateInset(this, true);
break;
@ -995,7 +993,7 @@ InsetFormula::LocalDispatch(BufferView * bv,
if (arg.empty())
break;
strncpy(arg2, arg.c_str(), 40); arg2[39]= '\0';
::strncpy(arg2, arg.c_str(), 40); arg2[39]= '\0';
int n = sscanf(arg2, "%s %s", lf, rg);
lf[39] = '\0'; rg[39] = '\0';
@ -1069,8 +1067,7 @@ InsetFormula::LocalDispatch(BufferView * bv,
}
case LFUN_MATH_DISPLAY:
//current_view->lockedInsetStoreUndo(Undo::INSERT);
bv->lockedInsetStoreUndo(Undo::EDIT);
bv->lockedInsetStoreUndo(Undo::EDIT);
display(!disp_flag);
UpdateLocal(bv);
break;

View File

@ -419,8 +419,6 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
string const name(&yytext[1]);
// ugly trick to be removed soon (lyx3)
//char c; yyis->get(c);
//yyis->putback(c);
char const c = yyis->peek();
if (c == '[') {
LexGetArg('[');

View File

@ -526,7 +526,7 @@ char const ** pixmapFromBitmapData(char const * s, int wx, int hx)
}
int ww = w/dw, hh = h/dh, x, y;
XImage * xima = XCreateImage(fl_display, 0, 1, XYBitmap, 0,
XImage * xima = XCreateImage(fl_get_display(), 0, 1, XYBitmap, 0,
const_cast<char*>(reinterpret_cast<char const *>(bdata)), w, h, 8, 0);
xima->byte_order = LSBFirst;
xima->bitmap_bit_order = LSBFirst;
@ -535,7 +535,7 @@ char const ** pixmapFromBitmapData(char const * s, int wx, int hx)
if (ww > wx) ww = wx;
if (hh > hx) hh = hx;
XImage * sbima = XSubImage(xima, x, y, ww, hh);
XpmCreateDataFromImage(fl_display, const_cast<char***>(&data), sbima, sbima, 0);
XpmCreateDataFromImage(fl_get_display(), const_cast<char***>(&data), sbima, sbima, 0);
// Dirty hack to get blue symbols quickly
char * sx = const_cast<char*>(strstr(data[2], "FFFFFFFF"));

View File

@ -185,7 +185,7 @@ void MiniBuffer::Set(string const& s1, string const& s2,
if (!the_buffer->focus) {
fl_set_input(the_buffer, ntext.c_str());
XFlush(fl_display);
XFlush(fl_get_display());
text = ntext;
}
}
@ -237,7 +237,7 @@ void MiniBuffer::Init()
fl_set_input(the_buffer, text.c_str());
setTimer(0);
XFlush(fl_display);
XFlush(fl_get_display());
}

View File

@ -50,7 +50,7 @@ using std::reverse;
int tex_code_break_column = 72; // needs non-zero initialization. set later.
// this is a bad idea, but how can LyXParagraph find its buffer to get
// parameters? (JMarc)
extern BufferView * current_view;
extern string bibitemWidest(Buffer const *);
// this is a minibuffer
@ -59,6 +59,8 @@ static LyXFont minibuffer_font;
static Inset * minibuffer_inset;
extern BufferView * current_view;
// Initialization of the counter for the paragraph id's,
// declared in lyxparagraph.h
unsigned int LyXParagraph::paragraph_id = 0;

View File

@ -32,14 +32,14 @@ static
GC createGC()
{
XGCValues val;
val.foreground = BlackPixel(fl_display,
DefaultScreen(fl_display));
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_display, RootWindow(fl_display, 0),
return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
GCForeground | GCFunction | GCGraphicsExposures
| GCLineWidth | GCLineStyle , &val);
}
@ -75,7 +75,7 @@ void LyXScreen::Redraw(LyXText * text)
void LyXScreen::expose(int x, int y, int exp_width, int exp_height)
{
XCopyArea(fl_display,
XCopyArea(fl_get_display(),
owner.getPixmap(),
owner.getWin(),
gc_copy,
@ -156,7 +156,7 @@ void LyXScreen::Draw(LyXText * text, unsigned int y)
&& (old_first - y) < owner.height()) {
if (text->first < old_first) {
DrawFromTo(text, 0, old_first - text->first);
XCopyArea (fl_display,
XCopyArea (fl_get_display(),
owner.getWin(),
owner.getWin(),
gc_copy,
@ -175,7 +175,7 @@ void LyXScreen::Draw(LyXText * text, unsigned int y)
DrawFromTo(text,
owner.height() + old_first - text->first,
owner.height());
XCopyArea (fl_display,
XCopyArea (fl_get_display(),
owner.getWin(),
owner.getWin(),
gc_copy,
@ -251,7 +251,7 @@ void LyXScreen::ShowManualCursor(LyXText const * text, int x, int y,
y2 = max(y2, y1);
if (cursor_pixmap){
XFreePixmap(fl_display, cursor_pixmap);
XFreePixmap(fl_get_display(), cursor_pixmap);
cursor_pixmap = 0;
}
@ -275,12 +275,12 @@ void LyXScreen::ShowManualCursor(LyXText const * text, int x, int y,
}
cursor_pixmap =
XCreatePixmap (fl_display,
XCreatePixmap (fl_get_display(),
fl_root,
cursor_pixmap_w,
cursor_pixmap_h,
fl_get_visual_depth());
XCopyArea (fl_display,
XCopyArea (fl_get_display(),
owner.getWin(),
cursor_pixmap,
gc_copy,
@ -289,7 +289,7 @@ void LyXScreen::ShowManualCursor(LyXText const * text, int x, int y,
cursor_pixmap_w,
cursor_pixmap_h,
0, 0);
XDrawLine(fl_display,
XDrawLine(fl_get_display(),
owner.getWin(),
gc_copy,
x + owner.xpos(),
@ -302,7 +302,7 @@ void LyXScreen::ShowManualCursor(LyXText const * text, int x, int y,
case L_SHAPE:
case REVERSED_L_SHAPE:
int rectangle_h = (cursor_pixmap_h+10)/20;
XFillRectangle(fl_display,
XFillRectangle(fl_get_display(),
owner.getWin(),
gc_copy,
cursor_pixmap_x + owner.xpos(),
@ -321,7 +321,7 @@ void LyXScreen::HideCursor()
if (!cursor_visible) return;
if (cursor_pixmap){
XCopyArea (fl_display,
XCopyArea (fl_get_display(),
cursor_pixmap,
owner.getWin(),
gc_copy,

View File

@ -38,6 +38,7 @@ libsupport_la_SOURCES = \
date.C \
filetools.C \
filetools.h \
fmt.C \
getUserName.C \
getcwd.C \
kill.C \
@ -45,6 +46,7 @@ libsupport_la_SOURCES = \
lstrings.h \
lxtl.h \
lyxalgo.h \
lyxfunctional.h \
lyxlib.h \
lyxmanip.h \
$(LYXSTRING) lyxsum.C \

View File

@ -15,6 +15,7 @@
#include <config.h>
#include "StrPool.h"
StrPool::~StrPool()
{
for (Pool::const_iterator cit = pool_.begin();
@ -23,6 +24,11 @@ StrPool::~StrPool()
}
}
/* One interesting thing here would be to store the strings in a map,
so that one string is only stored once. This would make things a
bit slower, but memory requirements would be lower in the long run.
I expect that it would be fast enough anyway. (Lgb)
*/
char const * StrPool::add(string const & str)
{
int s = str.length();
@ -33,3 +39,5 @@ char const * StrPool::add(string const & str)
return buf;
}
//StrPool strPool;

View File

@ -34,4 +34,6 @@ private:
Pool pool_;
};
//extern StrPool strPool;
#endif

49
src/support/fmt.C Normal file
View File

@ -0,0 +1,49 @@
#include <config.h>
#include <cstdio>
#include <cstdarg>
#include "LString.h"
/* This output manipulator gives the option to use Old style format
specifications in ostreams. Note that this is done at the expense
of typesafety, so if possible this manipulator should be avoided.
When is it allowed to use this manipulator? I wrote it to be used
i18n strings and gettext, and it should only(?) be used in that
context.
Ad. the implementation. I have only tested this on egcs-2.91.66 with
glibc 2.1.2. So further testing is needed. The loop in fmt(...) will
usually spin one or two times, but might spin more times with older
glibc libraries, since the returned -1 when size is too small. Newer
glibc returns the needed size.
One problem can be that vsnprintf is not implemented on all archs,
but AFAIK it is part of the new ANSI C standard.
Lgb
*/
string fmt(char const * fmtstr ...)
{
int size = 80;
char * str = new char[size];
va_list ap;
while (true) {
va_start(ap, fmtstr);
int const r = ::vsnprintf(str, size, fmtstr, ap);
va_end(ap);
if (r == -1) { // size is too small
delete [] str;
size *= 2; // seems quite safe to double.
str = new char[size];
} else if (r >= size) { // r gives the needed size
delete [] str;
size += r;
str = new char[size];
} else {
break;
}
}
string res(str);
delete [] str;
return res;
}

View File

@ -59,7 +59,6 @@ int compare_no_case(string const & s, string const & s2)
int compare_no_case(string const & s, string const & s2, unsigned int len)
{
//#warning verify this func please
string::const_iterator p = s.begin();
string::const_iterator p2 = s2.begin();
unsigned int i = 0;
@ -169,16 +168,17 @@ char uppercase(char c)
string const lowercase(string const & a)
{
string tmp(a);
//#ifdef __GLIBCPP__
#if 1
string::iterator result = tmp.begin();
string::iterator end = tmp.end();
for (string::iterator first = tmp.begin();
first != end; ++first, ++result) {
*result = lowercase(*first);
}
//#else
// transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
//#endif
#else
// We want to use this one. (Lgb)
transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
#endif
return tmp;
}
@ -186,16 +186,17 @@ string const lowercase(string const & a)
string const uppercase(string const & a)
{
string tmp(a);
//#ifdef __GLIBCPP__
#if 1
string::iterator result = tmp.begin();
string::iterator end = tmp.end();
for (string::iterator first = tmp.begin();
first != end; ++first, ++result) {
*result = uppercase(*first);
}
//#else
// transform(tmp.begin(), tmp.end(), tmp.begin(), toupper);
//#endif
#else
// We want to use this one. (Lgb)
transform(tmp.begin(), tmp.end(), tmp.begin(), toupper);
#endif
return tmp;
}

128
src/support/lyxfunctional.h Normal file
View File

@ -0,0 +1,128 @@
// -*- C++ -*-
#ifndef LYX_FUNCTIONAL_H
#define LYX_FUNCTIONAL_H
//namespace lyx {
template<class R, class C, class A>
class class_fun_t {
public:
class_fun_t(C & ct, R(C::*p)(A))
: c(ct), cmf(p) {}
R operator()(A & a) const {
return (c.*cmf)(a);
}
private:
C & c;
R(C::*cmf)(A);
};
template <class R, class C, class A> class_fun_t<R, C, A>
class_fun(C & c, R(C::*f)(A))
{
return class_fun_t<R, C, A>(c, f);
}
template <class Cont, class Type, class MemRet>
class back_insert_fun_iterator {
protected:
Cont & container;
MemRet(Type::*pmf)();
public:
back_insert_fun_iterator(Cont & x, MemRet(Type::*p)())
: container(x), pmf(p) {}
back_insert_fun_iterator &
operator=(Type * val) {
container.push_back((val->*pmf)());
return *this;
}
back_insert_fun_iterator & operator*() {
return *this;
}
back_insert_fun_iterator & operator++() { // prefix ++
return *this;
}
back_insert_fun_iterator & operator++(int) { // postfix ++
return *this;
}
};
template <class Cont, class Type, class MemRet>
back_insert_fun_iterator<Cont, Type, MemRet>
back_inserter_fun(Cont & cont, MemRet(Type::*p)())
{
return back_insert_fun_iterator<Cont, Type, MemRet>(cont, p);
}
template <class R, class C, class A>
class compare_memfun_t {
public:
compare_memfun_t(R(C::*p)(), A const & a)
: pmf(p), arg(a) {}
bool operator()(C * c) {
return (c->*pmf)() == arg;
}
bool operator()(C & c) {
return (c.*pmf)() == arg;
}
private:
R(C::*pmf)();
A const & arg;
};
template <class R, class C, class A>
compare_memfun_t<R, C, A>
compare_memfun(R(C::*p)(), A const & a)
{
return compare_memfun_t<R, C, A>(p, a);
}
// Functors used in the template.
///
template<typename T1, typename T2>
class equal_1st_in_pair {
public:
///
equal_1st_in_pair(T1 const & value) : value_(value) {}
///
typedef std::pair<T1, T2> pair_type;
///
bool operator() (pair_type const & p) const {
return p.first == value_;
}
private:
///
T1 const & value_;
};
///
template<typename T1, typename T2>
class equal_2nd_in_pair {
public:
///
equal_2nd_in_pair(T2 const & value) : value_(value) {}
///
typedef std::pair<T1, T2> pair_type;
///
bool operator() (pair_type const & p) const {
return p.second == value_;
}
private:
///
T2 const & value_;
};
// } // end of namespace lyx
#endif

View File

@ -9,7 +9,7 @@ struct NewLineAndDepth_ {
int depth_;
};
//
///
inline
NewLineAndDepth_ newlineAndDepth(int n)
{
@ -18,7 +18,7 @@ NewLineAndDepth_ newlineAndDepth(int n)
return nlad_;
}
//
///
inline
std::ostream & operator<<(std::ostream & os, NewLineAndDepth_ const & nlad_)
{
@ -26,4 +26,7 @@ std::ostream & operator<<(std::ostream & os, NewLineAndDepth_ const & nlad_)
return os;
}
///
std::string fmt(char const * fmtstr ...);
#endif

View File

@ -232,7 +232,7 @@ int Systemcalls::startscript(Starttype how, string const & what,
int SimulateTimer;
void back(string cmd, int retval)
{
printf("Done: %s gave %d\n", cmd.c_str(), retval);
::printf("Done: %s gave %d\n", cmd.c_str(), retval);
SimulateTimer = 0;
}

View File

@ -18,45 +18,7 @@
#include <functional>
#include "support/LAssert.h"
// Functors used in the template.
///
template<typename T1, typename T2>
class equal_1st_in_pair {
public:
///
equal_1st_in_pair(T1 const & value) : value_(value) {}
///
typedef std::pair<T1, T2> pair_type;
///
bool operator() (pair_type const & p) const {
return p.first == value_;
}
private:
///
T1 const & value_;
};
///
template<typename T1, typename T2>
class equal_2nd_in_pair {
public:
///
equal_2nd_in_pair(T2 const & value) : value_(value) {}
///
typedef std::pair<T1, T2> pair_type;
///
bool operator() (pair_type const & p) const {
return p.second == value_;
}
private:
///
T2 const & value_;
};
#include "support/lyxfunctional.h"
/** This class template is used to translate between two elements, specifically
it was worked out to translate between an enum and strings when reading
the lyx file.

View File

@ -42,8 +42,6 @@ using std::vector;
static int const WIDTH_OF_LINE = 5;
extern BufferView * current_view;
/// Define a few methods for the inner structs
LyXTabular::cellstruct::cellstruct()
@ -1303,10 +1301,20 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
string s1;
string s2;
is >> a >> b >> c;
#if 1
char ch; // skip '"'
is >> ch;
#else
// ignore is buggy but we will use it later (Lgb)
is.ignore(); // skip '"'
#endif
getline(is, s1, '"');
#if 1
is >> ch; // skip '"'
#else
// ignore is buggy but we will use it later (Lgb)
is.ignore(); // skip '"'
#endif
getline(is, s2, '"');
column_info[i].alignment = static_cast<LyXAlignment>(a);
column_info[i].left_line = b;
@ -1319,10 +1327,20 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
string s1;
string s2;
is >> a >> b >> c >> d >> e >> f >> g;
#if 1
char ch;
is >> ch; // skip '"'
#else
// ignore is buggy but we will use it later (Lgb)
is.ignore(); // skip '"'
#endif
getline(is, s1, '"');
#if 1
is >> ch; // skip '"'
#else
// ignore is buggy but we will use it later (Lgb)
is.ignore(); // skip '"'
#endif
getline(is, s2, '"');
cell_info[i][j].multicolumn = static_cast<char>(a);
cell_info[i][j].alignment = static_cast<LyXAlignment>(b);
@ -2362,18 +2380,17 @@ int LyXTabular::AsciiPrintCell(Buffer const * buf, ostream & os,
break;
}
unsigned int i;
for(i=0; i < len1; ++i)
for(unsigned int i = 0; i < len1; ++i)
os << " ";
os << sstr.str();
for(i=0; i < len2; ++i)
for(unsigned int i = 0; i < len2; ++i)
os << " ";
if (RightLine(cell))
os << " |";
else
os << " ";
return ret * 0;
return ret * 0; // eh? (Lgb)
}
@ -2395,7 +2412,7 @@ int LyXTabular::Ascii(Buffer const * buf, ostream & os) const
if (IsMultiColumn(cell, true))
continue;
ostringstream sstr;
(void)GetCellInset(cell)->Ascii(buf, sstr, 0);
GetCellInset(cell)->Ascii(buf, sstr, 0);
if (clen[j] < sstr.str().length())
clen[j] = sstr.str().length();
}
@ -2407,13 +2424,13 @@ int LyXTabular::Ascii(Buffer const * buf, ostream & os) const
if (!IsMultiColumn(cell, true) || IsPartOfMultiColumn(i, j))
continue;
ostringstream sstr;
(void)GetCellInset(cell)->Ascii(buf, sstr, 0);
int len = (int)sstr.str().length();
int n = cells_in_multicolumn(cell);
for (int k = j; (len > 0) && (k < (j+n-1)); ++k)
GetCellInset(cell)->Ascii(buf, sstr, 0);
string::size_type len = sstr.str().length();
int const n = cells_in_multicolumn(cell);
for (int k = j; (len > 0) && (k < (j + n - 1)); ++k)
len -= clen[k];
if (len > (int)clen[j+n-1])
clen[j+n-1] = len;
if (len > clen[j + n - 1])
clen[j + n - 1] = len;
}
}
cell = 0;
@ -2428,6 +2445,7 @@ int LyXTabular::Ascii(Buffer const * buf, ostream & os) const
os << endl;
AsciiBottomHLine(os, i, clen);
}
return ret;
}

View File

@ -168,13 +168,13 @@ public:
LyXTabular * Clone(InsetTabular *);
/// Returns true if there is a topline, returns false if not
bool TopLine(int cell, bool onlycolumn=false) const;
bool TopLine(int cell, bool onlycolumn = false) const;
/// Returns true if there is a topline, returns false if not
bool BottomLine(int cell, bool onlycolumn=false) const;
bool BottomLine(int cell, bool onlycolumn = false) const;
/// Returns true if there is a topline, returns false if not
bool LeftLine(int cell, bool onlycolumn=false) const;
bool LeftLine(int cell, bool onlycolumn = false) const;
/// Returns true if there is a topline, returns false if not
bool RightLine(int cell, bool onlycolumn=false) const;
bool RightLine(int cell, bool onlycolumn = false) const;
///
bool TopAlreadyDrawed(int cell) const;
@ -493,7 +493,7 @@ private: //////////////////////////////////////////////////////////////////
///
void Reinit();
///
void set_row_column_number_info(bool oldformat=false);
void set_row_column_number_info(bool oldformat = false);
/// Returns true if a complete update is necessary, otherwise false
bool SetWidthOfMulticolCell(int cell, int new_width);
///

View File

@ -284,9 +284,9 @@ void TransManager::TranslateAndInsert(char c, LyXText * text)
void TransManager::insertVerbatim(string const & str, LyXText * text)
{
int const l = str.length();
string::size_type const l = str.length();
for (int i = 0; i < l; ++i){
for (string::size_type i = 0; i < l; ++i) {
if (str[i] == '\"'
&& text->GetFont(current_view->buffer(),text->cursor.par(),
text->cursor.pos()).latex() == LyXFont::OFF