mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
fix some of the bugs reported, should hopefully be a bit better now.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@436 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9a34f1b0e7
commit
1bc4b73575
28
ChangeLog
28
ChangeLog
@ -1,3 +1,24 @@
|
|||||||
|
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>
|
2000-01-21 Juergen Vigna <jug@sad.it>
|
||||||
|
|
||||||
* src/buffer.C (writeFileAscii): Disabled code for special groff
|
* src/buffer.C (writeFileAscii): Disabled code for special groff
|
||||||
@ -11,6 +32,13 @@
|
|||||||
|
|
||||||
2000-01-20 Lars Gullik Bjønnes <larsbj@lyx.org>
|
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
|
* src/support/lyxsum.C: move using std::ifstream inside
|
||||||
MODERN_STL_STREAMS
|
MODERN_STL_STREAMS
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ void fl_set_bmtable_file(FL_OBJECT * ob, int nx, int ny, char const * filename)
|
|||||||
|
|
||||||
#else
|
#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 "
|
fprintf(stderr, "Set bmtable file: Sorry, I need X11 release 6 to do "
|
||||||
"work!\n");
|
"work!\n");
|
||||||
|
@ -40,8 +40,10 @@ extern long int background_pixels;
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <queue>
|
||||||
using std::ofstream;
|
using std::ofstream;
|
||||||
using std::ifstream;
|
using std::ifstream;
|
||||||
|
using std::queue;
|
||||||
|
|
||||||
#include "figinset.h"
|
#include "figinset.h"
|
||||||
#include "lyx.h"
|
#include "lyx.h"
|
||||||
@ -87,11 +89,10 @@ static int figarrsize = 0; /* current max number of figures */
|
|||||||
static int bmpinsref = 0; /* number of bitmaps */
|
static int bmpinsref = 0; /* number of bitmaps */
|
||||||
static int bmparrsize = 0; /* current max number of bitmaps */
|
static int bmparrsize = 0; /* current max number of bitmaps */
|
||||||
|
|
||||||
struct queue {
|
struct queue_element {
|
||||||
float rx, ry; /* resolution x and y */
|
float rx, ry; // resolution x and y
|
||||||
int ofsx, ofsy; /* x and y translation */
|
int ofsx, ofsy; // x and y translation
|
||||||
figdata * data; /* we are doing it for this data */
|
figdata * data; // we are doing it for this data
|
||||||
queue * next; /* next item in queue */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pidwait {
|
struct pidwait {
|
||||||
@ -103,7 +104,9 @@ static int const MAXGS = 3; /* maximum 3 gs's at a time */
|
|||||||
|
|
||||||
static Figref ** figures; /* all the figures */
|
static Figref ** figures; /* all the figures */
|
||||||
static figdata ** bitmaps; /* all the bitmaps */
|
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 int gsrunning = 0; /* currently so many gs's are running */
|
||||||
static bool bitmap_waiting = false; /* bitmaps are waiting finished */
|
static bool bitmap_waiting = false; /* bitmaps are waiting finished */
|
||||||
static char bittable[256]; /* bit reversion table */
|
static char bittable[256]; /* bit reversion table */
|
||||||
@ -509,7 +512,7 @@ static void runqueue()
|
|||||||
Atom * prop;
|
Atom * prop;
|
||||||
int nprop, i;
|
int nprop, i;
|
||||||
|
|
||||||
if (!gsqueue) {
|
if (gsqueue.empty()) {
|
||||||
if (!gsrunning && gs_xcolor) {
|
if (!gsrunning && gs_xcolor) {
|
||||||
// de-allocate rest of colors
|
// de-allocate rest of colors
|
||||||
// *****
|
// *****
|
||||||
@ -517,10 +520,9 @@ static void runqueue()
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
queue * p = gsqueue;
|
queue_element * p = &gsqueue.front();
|
||||||
|
|
||||||
if (!p->data) {
|
if (!p->data) {
|
||||||
delete p;
|
gsqueue.pop();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,10 +722,10 @@ static void runqueue()
|
|||||||
if (lyxerr.debugging()) {
|
if (lyxerr.debugging()) {
|
||||||
lyxerr << "GS [" << pid << "] started" << endl;
|
lyxerr << "GS [" << pid << "] started" << endl;
|
||||||
}
|
}
|
||||||
gsqueue = gsqueue->next;
|
|
||||||
gsrunning++;
|
|
||||||
p->data->gspid = pid;
|
p->data->gspid = pid;
|
||||||
delete p;
|
++gsrunning;
|
||||||
|
gsqueue.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,22 +733,15 @@ static void runqueue()
|
|||||||
static void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
|
static void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
|
||||||
{
|
{
|
||||||
// recompute the stuff and put in the queue
|
// recompute the stuff and put in the queue
|
||||||
queue * p = new queue;
|
queue_element p;
|
||||||
p->ofsx = psx;
|
p.ofsx = psx;
|
||||||
p->ofsy = psy;
|
p.ofsy = psy;
|
||||||
p->rx = (float(data->raw_wid) * 72.0) / pswid;
|
p.rx = (float(data->raw_wid) * 72.0) / pswid;
|
||||||
p->ry = (float(data->raw_hgh) * 72.0) / pshgh;
|
p.ry = (float(data->raw_hgh) * 72.0) / pshgh;
|
||||||
|
|
||||||
p->data = data;
|
p.data = data;
|
||||||
p->next = 0;
|
|
||||||
|
|
||||||
// now put into queue
|
gsqueue.push(p);
|
||||||
queue * p2 = gsqueue;
|
|
||||||
if (!gsqueue) gsqueue = p;
|
|
||||||
else {
|
|
||||||
while (p2->next) p2 = p2->next;
|
|
||||||
p2->next = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if possible, run the queue
|
// if possible, run the queue
|
||||||
runqueue();
|
runqueue();
|
||||||
|
@ -418,6 +418,15 @@ void InsetLatexAccent::Draw(LyXFont font,
|
|||||||
tmpvar, wid,
|
tmpvar, wid,
|
||||||
font.ascent('i') -
|
font.ascent('i') -
|
||||||
font.ascent('x') - 1);
|
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)
|
// now the rest - draw within (x, y, x+wid, y+hg)
|
||||||
switch (modtype) {
|
switch (modtype) {
|
||||||
|
12
src/kbmap.C
12
src/kbmap.C
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ enum { ModsMask = ShiftMask | ControlMask | Mod1Mask};
|
|||||||
Returns : length of printed string if ok, 0 otherwise.
|
Returns : length of printed string if ok, 0 otherwise.
|
||||||
\* ---F------------------------------------------------------------------- */
|
\* ---F------------------------------------------------------------------- */
|
||||||
static
|
static
|
||||||
void printKeysym(KeySym key, unsigned int mod, string & buf)
|
void printKeysym(unsigned long key, unsigned int mod, string & buf)
|
||||||
{
|
{
|
||||||
mod &= ModsMask;
|
mod &= ModsMask;
|
||||||
|
|
||||||
@ -90,7 +92,7 @@ void printKeyTab(kb_key * tabPt, string & buf)
|
|||||||
Returns : action or -1 if error (no map defined or key not found)
|
Returns : action or -1 if error (no map defined or key not found)
|
||||||
\* ---F------------------------------------------------------------------- */
|
\* ---F------------------------------------------------------------------- */
|
||||||
|
|
||||||
int kb_sequence::addkey(KeySym key,
|
int kb_sequence::addkey(unsigned long key,
|
||||||
unsigned int mod, unsigned int nmod /*= 0*/)
|
unsigned int mod, unsigned int nmod /*= 0*/)
|
||||||
{
|
{
|
||||||
if(length < 0) length = 0;
|
if(length < 0) length = 0;
|
||||||
@ -343,7 +345,7 @@ int kb_keymap::bind(char const * seq, int action)
|
|||||||
Returns : user defined action; 0 for prefix key, -1 if key not found
|
Returns : user defined action; 0 for prefix key, -1 if key not found
|
||||||
\* ---F------------------------------------------------------------------- */
|
\* ---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;
|
unsigned int ksym, msk1, msk0;
|
||||||
kb_key * tab;
|
kb_key * tab;
|
||||||
@ -493,13 +495,13 @@ int kb_keymap::defkey(kb_sequence * seq, int action, int idx /*= 0*/)
|
|||||||
|
|
||||||
// --- define rest of sequence --------------------------------------
|
// --- define rest of sequence --------------------------------------
|
||||||
|
|
||||||
if(idx+1 == seq->length) {
|
if(idx + 1 == seq->length) {
|
||||||
newone->action = action;
|
newone->action = action;
|
||||||
newone->table = 0;
|
newone->table = 0;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
newone->table = new kb_keymap;
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
|
|
||||||
#include "LString.h"
|
#include "LString.h"
|
||||||
|
|
||||||
#define KB_PREALLOC 16
|
#define KB_PREALLOC 16
|
||||||
@ -58,7 +56,7 @@ public:
|
|||||||
void print(string & buf) const;
|
void print(string & buf) const;
|
||||||
|
|
||||||
/// Look up a key in the keymap
|
/// 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.
|
/// Given an action, find all keybindings.
|
||||||
string findbinding(int action) const;
|
string findbinding(int action) const;
|
||||||
@ -102,7 +100,7 @@ public:
|
|||||||
/// 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
|
||||||
/** 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. */
|
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;
|
int print(string & buf, bool when_defined = false) const;
|
||||||
@ -117,7 +115,7 @@ public:
|
|||||||
char getiso();
|
char getiso();
|
||||||
|
|
||||||
///
|
///
|
||||||
KeySym getsym();
|
unsigned long getsym();
|
||||||
|
|
||||||
///
|
///
|
||||||
void reset();
|
void reset();
|
||||||
|
@ -879,18 +879,18 @@ int LyXFont::textWidth(char const * s, int n) const
|
|||||||
} else {
|
} else {
|
||||||
// emulate smallcaps since X doesn't support this
|
// emulate smallcaps since X doesn't support this
|
||||||
unsigned int result = 0;
|
unsigned int result = 0;
|
||||||
char c;
|
char c[2]; c[1] = '\0';
|
||||||
LyXFont smallfont = *this;
|
LyXFont smallfont = *this;
|
||||||
smallfont.decSize();
|
smallfont.decSize();
|
||||||
smallfont.decSize();
|
smallfont.decSize();
|
||||||
smallfont.setShape(LyXFont::UP_SHAPE);
|
smallfont.setShape(LyXFont::UP_SHAPE);
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
c = s[i];
|
c[0] = s[i];
|
||||||
if (islower(c)){
|
if (islower(c[0])){
|
||||||
c = toupper(c);
|
c[0] = toupper(c[0]);
|
||||||
result += XTextWidth(smallfont.getXFontstruct(), &c, 1);
|
result += XTextWidth(smallfont.getXFontstruct(), c, 1);
|
||||||
} else {
|
} else {
|
||||||
result += XTextWidth(getXFontstruct(), &c, 1);
|
result += XTextWidth(getXFontstruct(), c, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include "math_panel.h"
|
#include "math_panel.h"
|
||||||
|
|
||||||
FD_panel *create_form_panel(void)
|
FD_panel * create_form_panel(void)
|
||||||
{
|
{
|
||||||
FL_OBJECT *obj;
|
FL_OBJECT *obj;
|
||||||
FD_panel *fdui = (FD_panel *) fl_calloc(1, sizeof(FD_panel));
|
FD_panel *fdui = (FD_panel *) fl_calloc(1, sizeof(FD_panel));
|
||||||
|
@ -323,7 +323,7 @@ FD_panel * create_math_panel( )
|
|||||||
return fd_panel;
|
return fd_panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern BitmapMenu* sym_menu;
|
extern BitmapMenu * sym_menu;
|
||||||
extern void create_symbol_menues(FD_panel *);
|
extern void create_symbol_menues(FD_panel *);
|
||||||
|
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ void free_symbols_form()
|
|||||||
fl_hide_form(fd_panel->panel);
|
fl_hide_form(fd_panel->panel);
|
||||||
fl_free_form(fd_panel->panel);
|
fl_free_form(fd_panel->panel);
|
||||||
delete sym_menu;
|
delete sym_menu;
|
||||||
delete fd_panel;
|
free(fd_panel);
|
||||||
fd_panel = 0;
|
fd_panel = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1577,8 +1577,7 @@ LyXParagraph * LyXParagraph::FirstPhysicalPar()
|
|||||||
tmppar = tmppar->previous;
|
tmppar = tmppar->previous;
|
||||||
|
|
||||||
if (!tmppar) {
|
if (!tmppar) {
|
||||||
Assert(false); // let's get an abort then
|
return this;
|
||||||
return this; // This should never happen!
|
|
||||||
} else
|
} else
|
||||||
return tmppar;
|
return tmppar;
|
||||||
}
|
}
|
||||||
@ -1590,13 +1589,13 @@ LyXParagraph const * LyXParagraph::FirstPhysicalPar() const
|
|||||||
return this;
|
return this;
|
||||||
LyXParagraph const * tmppar = this;
|
LyXParagraph const * tmppar = this;
|
||||||
|
|
||||||
while (tmppar && (tmppar->IsDummy()
|
while (tmppar &&
|
||||||
|| tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
|
(tmppar->IsDummy()
|
||||||
|
|| tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
|
||||||
tmppar = tmppar->previous;
|
tmppar = tmppar->previous;
|
||||||
|
|
||||||
if (!tmppar) {
|
if (!tmppar) {
|
||||||
Assert(false); // let's get an abort then
|
return this;
|
||||||
return this; // This should never happen!
|
|
||||||
} else
|
} else
|
||||||
return tmppar;
|
return tmppar;
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#ifdef HAVE_SSTREAM
|
|
||||||
#include <sstream>
|
|
||||||
using std::ostringstream;
|
|
||||||
#else
|
|
||||||
#include <strstream>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "LString.h"
|
#include "LString.h"
|
||||||
#include "lstrings.h"
|
#include "lstrings.h"
|
||||||
#include "LRegex.h"
|
#include "LRegex.h"
|
||||||
@ -134,87 +127,6 @@ string uppercase(string const & a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
bool prefixIs(string const & a, char const * pre)
|
||||||
{
|
{
|
||||||
unsigned int l = strlen(pre);
|
unsigned int l = strlen(pre);
|
||||||
|
@ -9,39 +9,15 @@
|
|||||||
#define LSTRINGS_H
|
#define LSTRINGS_H
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
//#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;
|
|
||||||
//}
|
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
|
#ifdef HAVE_SSTREAM
|
||||||
|
#include <sstream>
|
||||||
|
using std::ostringstream;
|
||||||
|
#else
|
||||||
|
#include <strstream>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "LString.h"
|
#include "LString.h"
|
||||||
|
|
||||||
|
|
||||||
@ -77,30 +53,35 @@ string lowercase(string const &);
|
|||||||
///
|
///
|
||||||
string uppercase(string const &);
|
string uppercase(string const &);
|
||||||
|
|
||||||
/// int to string
|
/// convert T to string
|
||||||
string tostr(int i);
|
template<typename T>
|
||||||
|
inline string tostr(T const & t)
|
||||||
///
|
{
|
||||||
string tostr(unsigned int);
|
#ifdef HAVE_SSTREAM
|
||||||
|
ostringstream ostr;
|
||||||
/// long to string
|
ostr << t;
|
||||||
string tostr(long l);
|
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
|
||||||
string tostr(unsigned long l);
|
// basic_string<char>.
|
||||||
|
#else
|
||||||
///
|
// The buf is probably a bit large, but if we want to be safer
|
||||||
string tostr(char c);
|
// we should leave it this big. As compiler/libs gets updated
|
||||||
|
// this part of the code will cease to be used and we loose
|
||||||
/// void * to string
|
// nothing.
|
||||||
string tostr(void * v);
|
char buf[2048]; // a bit too large perhaps?
|
||||||
|
ostrstream ostr(buf, sizeof(buf));
|
||||||
/// bool to string
|
ostr << t << '\0';
|
||||||
string tostr(bool b);
|
return buf;
|
||||||
|
#endif
|
||||||
///
|
}
|
||||||
string tostr(double d);
|
|
||||||
|
|
||||||
|
inline
|
||||||
|
string tostr(bool b)
|
||||||
|
{
|
||||||
|
return (b ? "true" : "false");
|
||||||
|
}
|
||||||
|
|
||||||
/// Does the string start with this prefix?
|
/// Does the string start with this prefix?
|
||||||
bool prefixIs(string const &, char const *);
|
bool prefixIs(string const &, char const *);
|
||||||
|
|
||||||
|
30
src/text.C
30
src/text.C
@ -281,9 +281,6 @@ void LyXText::Draw(Row const * row, LyXParagraph::size_type & pos,
|
|||||||
// exactly the label-width.
|
// exactly the label-width.
|
||||||
int LyXText::LeftMargin(Row const * row) const
|
int LyXText::LeftMargin(Row const * row) const
|
||||||
{
|
{
|
||||||
LyXFont labelfont;
|
|
||||||
LyXParagraph * newpar;
|
|
||||||
Row dummyrow;
|
|
||||||
LyXLayout const & layout = textclasslist.Style(parameters->textclass,
|
LyXLayout const & layout = textclasslist.Style(parameters->textclass,
|
||||||
row->par->GetLayout());
|
row->par->GetLayout());
|
||||||
|
|
||||||
@ -315,7 +312,7 @@ int LyXText::LeftMargin(Row const * row) const
|
|||||||
if (!row->par->GetLayout()) {
|
if (!row->par->GetLayout()) {
|
||||||
// find the previous same level paragraph
|
// find the previous same level paragraph
|
||||||
if (row->par->FirstPhysicalPar()->Previous()) {
|
if (row->par->FirstPhysicalPar()->Previous()) {
|
||||||
newpar = row->par
|
LyXParagraph * newpar = row->par
|
||||||
->DepthHook(row->par->GetDepth());
|
->DepthHook(row->par->GetDepth());
|
||||||
if (newpar &&
|
if (newpar &&
|
||||||
textclasslist.Style(parameters->textclass,
|
textclasslist.Style(parameters->textclass,
|
||||||
@ -327,7 +324,7 @@ int LyXText::LeftMargin(Row const * row) const
|
|||||||
} else {
|
} else {
|
||||||
// find the next level paragraph
|
// 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()
|
// make a corresponding row. Needed to call LeftMargin()
|
||||||
|
|
||||||
@ -336,6 +333,7 @@ int LyXText::LeftMargin(Row const * row) const
|
|||||||
&& textclasslist
|
&& textclasslist
|
||||||
.Style(parameters->textclass,
|
.Style(parameters->textclass,
|
||||||
newpar->GetLayout()).isEnvironment()) {
|
newpar->GetLayout()).isEnvironment()) {
|
||||||
|
Row dummyrow;
|
||||||
dummyrow.par = newpar;
|
dummyrow.par = newpar;
|
||||||
dummyrow.pos = newpar->Last();
|
dummyrow.pos = newpar->Last();
|
||||||
x = LeftMargin(&dummyrow);
|
x = LeftMargin(&dummyrow);
|
||||||
@ -358,7 +356,7 @@ int LyXText::LeftMargin(Row const * row) const
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
labelfont = GetFont(row->par, -2);
|
LyXFont labelfont = GetFont(row->par, -2);
|
||||||
switch (layout.margintype) {
|
switch (layout.margintype) {
|
||||||
case MARGIN_DYNAMIC:
|
case MARGIN_DYNAMIC:
|
||||||
if (!layout.leftmargin.empty()) {
|
if (!layout.leftmargin.empty()) {
|
||||||
@ -427,7 +425,7 @@ int LyXText::LeftMargin(Row const * row) const
|
|||||||
tmprow = tmprow->previous;
|
tmprow = tmprow->previous;
|
||||||
|
|
||||||
int minfill = tmprow->fill;
|
int minfill = tmprow->fill;
|
||||||
while (tmprow-> next && tmprow->next->par == row->par) {
|
while (tmprow->next && tmprow->next->par == row->par) {
|
||||||
tmprow = tmprow->next;
|
tmprow = tmprow->next;
|
||||||
if (tmprow->fill < minfill)
|
if (tmprow->fill < minfill)
|
||||||
minfill = tmprow->fill;
|
minfill = tmprow->fill;
|
||||||
@ -2932,14 +2930,26 @@ void LyXText::Delete()
|
|||||||
// this is a very easy implementation
|
// this is a very easy implementation
|
||||||
|
|
||||||
LyXCursor old_cursor = cursor;
|
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
|
// just move to the right
|
||||||
CursorRightIntern();
|
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
|
if (cursor.par->previous == old_cursor.par->previous
|
||||||
&& cursor.par != old_cursor.par)
|
&& 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 you had success make a backspace
|
||||||
if (old_cursor.par != cursor.par || old_cursor.pos != cursor.pos) {
|
if (old_cursor.par != cursor.par || old_cursor.pos != cursor.pos) {
|
||||||
LyXCursor tmpcursor = cursor;
|
LyXCursor tmpcursor = cursor;
|
||||||
|
Loading…
Reference in New Issue
Block a user