+2000-01-21 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/bmtable.c (fl_set_bmtable_file): have arguments in the X r5
+ version also.
+
+ * src/paragraph.C (FirstPhysicalPar): remove assert and comment
+ that obviously was wrong...
+
+ * src/lyxfont.C (textWidth): have c as char c[2] instead of char
+ c, this avoids warnings with purify and islower.
+
+ * src/insets/figinset.C: rename struct queue to struct
+ queue_element and rewrite to use a std::queue. gsqueue is now a
+ std::queue<queue_element>
+ (runqueue): reflect move to std::queue
+ (addwait): ditto
+
+ * src/support/lstrings.h (tostr): specialize for bool, otherwise
+ we would get "1" "0" instead of "true" "false. Also make the tostr
+ functions inline.
+
2000-01-21 Juergen Vigna <jug@sad.it>
* src/buffer.C (writeFileAscii): Disabled code for special groff
2000-01-20 Lars Gullik Bjønnes <larsbj@lyx.org>
+ * src/insets/insetlatexaccent.C (Draw): make accents on top of 'i'
+ and 'j' look better. This might fix the "macron" bug that has been
+ observed.
+
+ * src/support/lstrings.[Ch] (tostr): reimplement all the tostr
+ functions as one template function. Delete the old versions.
+
* src/support/lyxsum.C: move using std::ifstream inside
MODERN_STL_STREAMS
#else
-void fl_set_bmtable_file(FL_OBJECT *, int, int, char const *)
+void fl_set_bmtable_file(FL_OBJECT * ob, int nx, int ny, char const * filename)
{
fprintf(stderr, "Set bmtable file: Sorry, I need X11 release 6 to do "
"work!\n");
#include <cctype>
#include <cmath>
#include <fstream>
+#include <queue>
using std::ofstream;
using std::ifstream;
+using std::queue;
#include "figinset.h"
#include "lyx.h"
static int bmpinsref = 0; /* number of bitmaps */
static int bmparrsize = 0; /* current max number of bitmaps */
-struct queue {
- float rx, ry; /* resolution x and y */
- int ofsx, ofsy; /* x and y translation */
- figdata * data; /* we are doing it for this data */
- queue * next; /* next item in queue */
+struct queue_element {
+ float rx, ry; // resolution x and y
+ int ofsx, ofsy; // x and y translation
+ figdata * data; // we are doing it for this data
};
struct pidwait {
static Figref ** figures; /* all the figures */
static figdata ** bitmaps; /* all the bitmaps */
-static queue * gsqueue = 0; /* queue for ghostscripting */
+
+static queue<queue_element> gsqueue; // queue for ghostscripting
+
static int gsrunning = 0; /* currently so many gs's are running */
static bool bitmap_waiting = false; /* bitmaps are waiting finished */
static char bittable[256]; /* bit reversion table */
Atom * prop;
int nprop, i;
- if (!gsqueue) {
+ if (gsqueue.empty()) {
if (!gsrunning && gs_xcolor) {
// de-allocate rest of colors
// *****
}
return;
}
- queue * p = gsqueue;
-
+ queue_element * p = &gsqueue.front();
if (!p->data) {
- delete p;
+ gsqueue.pop();
continue;
}
if (lyxerr.debugging()) {
lyxerr << "GS [" << pid << "] started" << endl;
}
- gsqueue = gsqueue->next;
- gsrunning++;
+
p->data->gspid = pid;
- delete p;
+ ++gsrunning;
+ gsqueue.pop();
}
}
static void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
{
// recompute the stuff and put in the queue
- queue * p = new queue;
- p->ofsx = psx;
- p->ofsy = psy;
- p->rx = (float(data->raw_wid) * 72.0) / pswid;
- p->ry = (float(data->raw_hgh) * 72.0) / pshgh;
-
- p->data = data;
- p->next = 0;
-
- // now put into queue
- queue * p2 = gsqueue;
- if (!gsqueue) gsqueue = p;
- else {
- while (p2->next) p2 = p2->next;
- p2->next = p;
- }
+ queue_element p;
+ p.ofsx = psx;
+ p.ofsy = psy;
+ p.rx = (float(data->raw_wid) * 72.0) / pswid;
+ p.ry = (float(data->raw_hgh) * 72.0) / pshgh;
+
+ p.data = data;
+
+ gsqueue.push(p);
// if possible, run the queue
runqueue();
tmpvar, wid,
font.ascent('i') -
font.ascent('x') - 1);
+ // the five lines below is a simple hack to
+ // make the display of accent 'i' and 'j'
+ // better. It makes the accent be written
+ // closer to the top of the dot-less 'i' or 'j'.
+ char tmpic = ic; // store the ic when we
+ ic = 'x'; // calculates the ascent of
+ asc = Ascent(font); // the dot-less version (here: 'x')
+ ic = tmpic; // set the orig ic back
+ y = baseline - asc; // update to new y coord.
}
// now the rest - draw within (x, y, x+wid, y+hg)
switch (modtype) {
#include <config.h>
#include <cstring>
+#include <X11/Xlib.h>
+
#include "support/lstrings.h"
#include "gettext.h"
Returns : length of printed string if ok, 0 otherwise.
\* ---F------------------------------------------------------------------- */
static
-void printKeysym(KeySym key, unsigned int mod, string & buf)
+void printKeysym(unsigned long key, unsigned int mod, string & buf)
{
mod &= ModsMask;
Returns : action or -1 if error (no map defined or key not found)
\* ---F------------------------------------------------------------------- */
-int kb_sequence::addkey(KeySym key,
+int kb_sequence::addkey(unsigned long key,
unsigned int mod, unsigned int nmod /*= 0*/)
{
if(length < 0) length = 0;
Returns : user defined action; 0 for prefix key, -1 if key not found
\* ---F------------------------------------------------------------------- */
-int kb_keymap::lookup(KeySym key, unsigned int mod, kb_sequence * seq)
+int kb_keymap::lookup(unsigned long key, unsigned int mod, kb_sequence * seq)
{
unsigned int ksym, msk1, msk0;
kb_key * tab;
// --- define rest of sequence --------------------------------------
- if(idx+1 == seq->length) {
+ if(idx + 1 == seq->length) {
newone->action = action;
newone->table = 0;
return 0;
} else {
newone->table = new kb_keymap;
- int res = newone->table->defkey(seq, action, idx+1);
+ int res = newone->table->defkey(seq, action, idx + 1);
return res;
}
}
#pragma interface
#endif
-#include <X11/Xlib.h>
-
#include "LString.h"
#define KB_PREALLOC 16
void print(string & buf) const;
/// Look up a key in the keymap
- int lookup(KeySym key, unsigned mod, kb_sequence * seq);
+ int lookup(unsigned long key, unsigned mod, kb_sequence * seq);
/// Given an action, find all keybindings.
string findbinding(int action) const;
/// Add a key to the key sequence and look it up in the curmap
/** Add a key to the key sequence and look it up in the curmap
if the latter is defined. */
- int addkey(KeySym key, unsigned mod, unsigned nmod = 0);
+ int addkey(unsigned long key, unsigned mod, unsigned nmod = 0);
///
int print(string & buf, bool when_defined = false) const;
char getiso();
///
- KeySym getsym();
+ unsigned long getsym();
///
void reset();
} else {
// emulate smallcaps since X doesn't support this
unsigned int result = 0;
- char c;
+ char c[2]; c[1] = '\0';
LyXFont smallfont = *this;
smallfont.decSize();
smallfont.decSize();
smallfont.setShape(LyXFont::UP_SHAPE);
for (int i = 0; i < n; ++i) {
- c = s[i];
- if (islower(c)){
- c = toupper(c);
- result += XTextWidth(smallfont.getXFontstruct(), &c, 1);
+ c[0] = s[i];
+ if (islower(c[0])){
+ c[0] = toupper(c[0]);
+ result += XTextWidth(smallfont.getXFontstruct(), c, 1);
} else {
- result += XTextWidth(getXFontstruct(), &c, 1);
+ result += XTextWidth(getXFontstruct(), c, 1);
}
}
return result;
#include <cstdlib>
#include "math_panel.h"
-FD_panel *create_form_panel(void)
+FD_panel * create_form_panel(void)
{
FL_OBJECT *obj;
FD_panel *fdui = (FD_panel *) fl_calloc(1, sizeof(FD_panel));
return fd_panel;
}
-extern BitmapMenu* sym_menu;
+extern BitmapMenu * sym_menu;
extern void create_symbol_menues(FD_panel *);
fl_hide_form(fd_panel->panel);
fl_free_form(fd_panel->panel);
delete sym_menu;
- delete fd_panel;
+ free(fd_panel);
fd_panel = 0;
}
}
tmppar = tmppar->previous;
if (!tmppar) {
- Assert(false); // let's get an abort then
- return this; // This should never happen!
+ return this;
} else
return tmppar;
}
return this;
LyXParagraph const * tmppar = this;
- while (tmppar && (tmppar->IsDummy()
- || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
+ while (tmppar &&
+ (tmppar->IsDummy()
+ || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
tmppar = tmppar->previous;
if (!tmppar) {
- Assert(false); // let's get an abort then
- return this; // This should never happen!
+ return this;
} else
return tmppar;
}
#endif
#include <cstdlib>
-#ifdef HAVE_SSTREAM
-#include <sstream>
-using std::ostringstream;
-#else
-#include <strstream>
-#endif
-
#include "LString.h"
#include "lstrings.h"
#include "LRegex.h"
}
-string tostr(long i)
-{
-#ifndef HAVE_SSTREAM
- // "Hey!", you say. "Why do we need the char str[30]?".
- // Since strstream does not handle memory for us we have to do
- // that ourselves, if we don't pass str in we have to capture
- // oss.str() in a tmp variable and delete that manually.
- // Thus we then require more temporary variables and the code
- // gets more obfuscated.
- char str[30];
- ostrstream oss(str, 30);
- oss << i << '\0';
- return oss.str();
-#else
- ostringstream oss;
- oss << i;
- return oss.str().c_str();
-#endif
-}
-
-
-string tostr(unsigned long i)
-{
-#ifndef HAVE_SSTREAM
- char str[30];
- ostrstream oss(str, 30);
- oss << i << '\0';
- return oss.str();
-#else
- ostringstream oss;
- oss << i;
- return oss.str().c_str();
-#endif
-}
-
-
-string tostr(void * v)
-{
- return tostr(long(v));
-}
-
-
-string tostr(int i)
-{
- return tostr(long(i));
-}
-
-
-string tostr(unsigned int ui)
-{
- return tostr(long(ui));
-}
-
-
-string tostr(char c)
-{
- return string(1, c);
-}
-
-
-string tostr(bool b)
-{
- return b ? "true" : "false";
-}
-
-
-string tostr(double d)
-{
-#ifndef HAVE_SSTREAM
- char tmp[40];
- ostrstream oss(tmp, 40);
- oss << d << '\0';
- return oss.str();
-#else
- ostringstream oss;
- oss << d;
- return oss.str().c_str();
-#endif
-}
-
-
bool prefixIs(string const & a, char const * pre)
{
unsigned int l = strlen(pre);
#define LSTRINGS_H
#include <cstring>
+#include <cctype>
-//#include "LAssert.h"
-
-//#warning verify this please. Lgb
-///
-//template<class T>
-//size_t lstrlen(T const * t)
-//{
-// Assert(t); // we don't want null pointers
-// size_t count = 0;
-// T const * r = t;
-// while(*r != 0) ++r, ++count;
-// return count;
-//}
-
-
-//#Warning verify this please. Lgb
-///
-//template<class T>
-//T * lstrchr(T const * t, int c)
-//{
-// Assert(t); // we don't want null pointers
-// T * r = const_cast<T*>(t);
-// while(*r != 0) {
-// if (*r == c)
-// return r;
-// else
-// ++r;
-// }
-// return 0;
-//}
+#ifdef HAVE_SSTREAM
+#include <sstream>
+using std::ostringstream;
+#else
+#include <strstream>
+#endif
-#include <cctype>
#include "LString.h"
///
string uppercase(string const &);
-/// int to string
-string tostr(int i);
-
-///
-string tostr(unsigned int);
-
-/// long to string
-string tostr(long l);
-
-///
-string tostr(unsigned long l);
-
-///
-string tostr(char c);
-
-/// void * to string
-string tostr(void * v);
-
-/// bool to string
-string tostr(bool b);
-
-///
-string tostr(double d);
+/// convert T to string
+template<typename T>
+inline string tostr(T const & t)
+{
+#ifdef HAVE_SSTREAM
+ ostringstream ostr;
+ ostr << t;
+ return ostr.str().c_str();
+ // We need to use the .c_str since we sometimes are using
+ // our own string class and that is not compatible with
+ // basic_string<char>.
+#else
+ // The buf is probably a bit large, but if we want to be safer
+ // we should leave it this big. As compiler/libs gets updated
+ // this part of the code will cease to be used and we loose
+ // nothing.
+ char buf[2048]; // a bit too large perhaps?
+ ostrstream ostr(buf, sizeof(buf));
+ ostr << t << '\0';
+ return buf;
+#endif
+}
+inline
+string tostr(bool b)
+{
+ return (b ? "true" : "false");
+}
+
/// Does the string start with this prefix?
bool prefixIs(string const &, char const *);
// exactly the label-width.
int LyXText::LeftMargin(Row const * row) const
{
- LyXFont labelfont;
- LyXParagraph * newpar;
- Row dummyrow;
LyXLayout const & layout = textclasslist.Style(parameters->textclass,
row->par->GetLayout());
if (!row->par->GetLayout()) {
// find the previous same level paragraph
if (row->par->FirstPhysicalPar()->Previous()) {
- newpar = row->par
+ LyXParagraph * newpar = row->par
->DepthHook(row->par->GetDepth());
if (newpar &&
textclasslist.Style(parameters->textclass,
} else {
// find the next level paragraph
- newpar = row->par->DepthHook(row->par->GetDepth()-1);
+ LyXParagraph * newpar = row->par->DepthHook(row->par->GetDepth()-1);
// make a corresponding row. Needed to call LeftMargin()
&& textclasslist
.Style(parameters->textclass,
newpar->GetLayout()).isEnvironment()) {
+ Row dummyrow;
dummyrow.par = newpar;
dummyrow.pos = newpar->Last();
x = LeftMargin(&dummyrow);
}
- labelfont = GetFont(row->par, -2);
+ LyXFont labelfont = GetFont(row->par, -2);
switch (layout.margintype) {
case MARGIN_DYNAMIC:
if (!layout.leftmargin.empty()) {
tmprow = tmprow->previous;
int minfill = tmprow->fill;
- while (tmprow-> next && tmprow->next->par == row->par) {
+ while (tmprow->next && tmprow->next->par == row->par) {
tmprow = tmprow->next;
if (tmprow->fill < minfill)
minfill = tmprow->fill;
// this is a very easy implementation
LyXCursor old_cursor = cursor;
+ int old_cur_par_id = old_cursor.par->id();
+ int old_cur_par_prev_id = old_cursor.par->previous->id();
// just move to the right
CursorRightIntern();
-
+
+ // This check is not very good...
+ // The CursorRightIntern calls DeleteEmptyParagrapgMechanism
+ // and that can very well delete the par or par->previous in
+ // old_cursor. Will a solution where we compare paragraph id's
+ //work better?
+#if 1
+ if (cursor.par->previous->id() == old_cur_par_prev_id
+ && cursor.par->id() != old_cur_par_id)
+ return; // delete-empty-paragraph-mechanism has done it
+#else
if (cursor.par->previous == old_cursor.par->previous
&& cursor.par != old_cursor.par)
- return; // delete-emty-paragraph-mechanism has done it
-
+ return; // delete-empty-paragraph-mechanism has done it
+#endif
// if you had success make a backspace
if (old_cursor.par != cursor.par || old_cursor.pos != cursor.pos) {
LyXCursor tmpcursor = cursor;