mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +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>
|
||||
|
||||
* src/buffer.C (writeFileAscii): Disabled code for special groff
|
||||
@ -11,6 +32,13 @@
|
||||
|
||||
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
|
||||
|
||||
|
@ -308,7 +308,7 @@ void fl_set_bmtable_file(FL_OBJECT * ob, int nx, int ny, char const * filename)
|
||||
|
||||
#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");
|
||||
|
@ -40,8 +40,10 @@ extern long int background_pixels;
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <queue>
|
||||
using std::ofstream;
|
||||
using std::ifstream;
|
||||
using std::queue;
|
||||
|
||||
#include "figinset.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 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 {
|
||||
@ -103,7 +104,9 @@ static int const MAXGS = 3; /* maximum 3 gs's at a time */
|
||||
|
||||
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 */
|
||||
@ -509,7 +512,7 @@ static void runqueue()
|
||||
Atom * prop;
|
||||
int nprop, i;
|
||||
|
||||
if (!gsqueue) {
|
||||
if (gsqueue.empty()) {
|
||||
if (!gsrunning && gs_xcolor) {
|
||||
// de-allocate rest of colors
|
||||
// *****
|
||||
@ -517,10 +520,9 @@ static void runqueue()
|
||||
}
|
||||
return;
|
||||
}
|
||||
queue * p = gsqueue;
|
||||
|
||||
queue_element * p = &gsqueue.front();
|
||||
if (!p->data) {
|
||||
delete p;
|
||||
gsqueue.pop();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -720,10 +722,10 @@ static void runqueue()
|
||||
if (lyxerr.debugging()) {
|
||||
lyxerr << "GS [" << pid << "] started" << endl;
|
||||
}
|
||||
gsqueue = gsqueue->next;
|
||||
gsrunning++;
|
||||
|
||||
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)
|
||||
{
|
||||
// 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;
|
||||
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;
|
||||
p->next = 0;
|
||||
p.data = data;
|
||||
|
||||
// now put into queue
|
||||
queue * p2 = gsqueue;
|
||||
if (!gsqueue) gsqueue = p;
|
||||
else {
|
||||
while (p2->next) p2 = p2->next;
|
||||
p2->next = p;
|
||||
}
|
||||
gsqueue.push(p);
|
||||
|
||||
// if possible, run the queue
|
||||
runqueue();
|
||||
|
@ -418,6 +418,15 @@ void InsetLatexAccent::Draw(LyXFont font,
|
||||
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) {
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <cstring>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "gettext.h"
|
||||
|
||||
@ -39,7 +41,7 @@ enum { ModsMask = ShiftMask | ControlMask | Mod1Mask};
|
||||
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;
|
||||
|
||||
@ -90,7 +92,7 @@ void printKeyTab(kb_key * tabPt, string & buf)
|
||||
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;
|
||||
@ -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
|
||||
\* ---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;
|
||||
|
@ -13,8 +13,6 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
#define KB_PREALLOC 16
|
||||
@ -58,7 +56,7 @@ public:
|
||||
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;
|
||||
@ -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
|
||||
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;
|
||||
@ -117,7 +115,7 @@ public:
|
||||
char getiso();
|
||||
|
||||
///
|
||||
KeySym getsym();
|
||||
unsigned long getsym();
|
||||
|
||||
///
|
||||
void reset();
|
||||
|
@ -879,18 +879,18 @@ int LyXFont::textWidth(char const * s, int n) const
|
||||
} 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;
|
||||
|
@ -333,7 +333,7 @@ void free_symbols_form()
|
||||
fl_hide_form(fd_panel->panel);
|
||||
fl_free_form(fd_panel->panel);
|
||||
delete sym_menu;
|
||||
delete fd_panel;
|
||||
free(fd_panel);
|
||||
fd_panel = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1577,8 +1577,7 @@ LyXParagraph * LyXParagraph::FirstPhysicalPar()
|
||||
tmppar = tmppar->previous;
|
||||
|
||||
if (!tmppar) {
|
||||
Assert(false); // let's get an abort then
|
||||
return this; // This should never happen!
|
||||
return this;
|
||||
} else
|
||||
return tmppar;
|
||||
}
|
||||
@ -1590,13 +1589,13 @@ LyXParagraph const * LyXParagraph::FirstPhysicalPar() const
|
||||
return this;
|
||||
LyXParagraph const * tmppar = this;
|
||||
|
||||
while (tmppar && (tmppar->IsDummy()
|
||||
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;
|
||||
}
|
||||
|
@ -9,13 +9,6 @@
|
||||
#endif
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
using std::ostringstream;
|
||||
#else
|
||||
#include <strstream>
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
#include "lstrings.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)
|
||||
{
|
||||
unsigned int l = strlen(pre);
|
||||
|
@ -9,39 +9,15 @@
|
||||
#define LSTRINGS_H
|
||||
|
||||
#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>
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
using std::ostringstream;
|
||||
#else
|
||||
#include <strstream>
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
|
||||
@ -77,29 +53,34 @@ string lowercase(string const &);
|
||||
///
|
||||
string uppercase(string const &);
|
||||
|
||||
/// int to string
|
||||
string tostr(int i);
|
||||
/// 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
|
||||
}
|
||||
|
||||
///
|
||||
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);
|
||||
inline
|
||||
string tostr(bool b)
|
||||
{
|
||||
return (b ? "true" : "false");
|
||||
}
|
||||
|
||||
/// Does the string start with this prefix?
|
||||
bool prefixIs(string const &, char const *);
|
||||
|
26
src/text.C
26
src/text.C
@ -281,9 +281,6 @@ void LyXText::Draw(Row const * row, LyXParagraph::size_type & pos,
|
||||
// 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());
|
||||
|
||||
@ -315,7 +312,7 @@ int LyXText::LeftMargin(Row const * row) const
|
||||
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,
|
||||
@ -327,7 +324,7 @@ int LyXText::LeftMargin(Row const * row) const
|
||||
} 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()
|
||||
|
||||
@ -336,6 +333,7 @@ int LyXText::LeftMargin(Row const * row) const
|
||||
&& textclasslist
|
||||
.Style(parameters->textclass,
|
||||
newpar->GetLayout()).isEnvironment()) {
|
||||
Row dummyrow;
|
||||
dummyrow.par = newpar;
|
||||
dummyrow.pos = newpar->Last();
|
||||
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) {
|
||||
case MARGIN_DYNAMIC:
|
||||
if (!layout.leftmargin.empty()) {
|
||||
@ -2932,14 +2930,26 @@ void LyXText::Delete()
|
||||
// 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;
|
||||
|
Loading…
Reference in New Issue
Block a user