more latex conversion cases fixed, patch from Andre, more more funcs to lowercase, some debug output to look at...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2406 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-08-02 18:46:53 +00:00
parent aae301e9cd
commit 8254b16fd1
19 changed files with 118 additions and 176 deletions

View File

@ -67,7 +67,6 @@
#include "mathed/formulabase.h"
extern LyXTextClass::size_type current_layout;
extern int greek_kb_flag;
using std::vector;
using std::find_if;
@ -85,7 +84,6 @@ bool selection_possible = false;
extern BufferList bufferlist;
extern char ascii_type;
extern bool math_insert_greek(BufferView *, char);
extern void sigchldchecker(pid_t pid, int * status);
extern int bibitemMaxWidth(BufferView *, LyXFont const &);
@ -1668,58 +1666,58 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
break;
case LFUN_LANGUAGE:
Lang(bv_, argument);
lang(bv_, argument);
setState();
owner_->showState();
break;
case LFUN_EMPH:
Emph(bv_);
emph(bv_);
owner_->showState();
break;
case LFUN_BOLD:
Bold(bv_);
bold(bv_);
owner_->showState();
break;
case LFUN_NOUN:
Noun(bv_);
noun(bv_);
owner_->showState();
break;
case LFUN_CODE:
Code(bv_);
code(bv_);
owner_->showState();
break;
case LFUN_SANS:
Sans(bv_);
sans(bv_);
owner_->showState();
break;
case LFUN_ROMAN:
Roman(bv_);
roman(bv_);
owner_->showState();
break;
case LFUN_DEFAULT:
StyleReset(bv_);
styleReset(bv_);
owner_->showState();
break;
case LFUN_UNDERLINE:
Underline(bv_);
underline(bv_);
owner_->showState();
break;
case LFUN_FONT_SIZE:
FontSize(bv_, argument);
fontSize(bv_, argument);
owner_->showState();
break;
case LFUN_FONT_STATE:
owner_->getLyXFunc()->setMessage(CurrentState(bv_));
owner_->getLyXFunc()->setMessage(currentState(bv_));
break;
case LFUN_UPCASE_WORD:
@ -3002,10 +3000,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
InsetCommandParams p("index");
if (argument.empty()) {
string const idxstring(bv_->getLyXText()->getStringToIndex(bv_));
if (!idxstring.empty())
if (!idxstring.empty()) {
p.setContents(idxstring);
else
} else {
break;
}
} else {
p.setContents(argument);
}
@ -3137,10 +3136,6 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
string::const_iterator cit = argument.begin();
string::const_iterator end = argument.end();
for (; cit != end; ++cit) {
if (greek_kb_flag) {
if (!math_insert_greek(bv_, *cit))
owner_->getIntl()->getTrans().TranslateAndInsert(*cit, lt);
} else
owner_->getIntl()->getTrans().TranslateAndInsert(*cit, lt);
}

View File

@ -1,3 +1,8 @@
2001-08-02 André Pönitz <poenitz@gmx.net>
* lyxfunc.C:
BufferView_pimpl.C: remove broken special code for math-greek
2001-08-02 Juergen Vigna <jug@sad.it>
* BufferView_pimpl.C (update): redone this function so that we

View File

@ -181,8 +181,6 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
lfun->dispatch(LFUN_MESSAGE, str.str().c_str());
}
//WriteStatus(lfun, string(_("LaTeX run number ")) + tostr(count));
this->operator()();
scanres = scanLogFile(terr);
if (scanres & ERROR_RERUN) {
@ -319,7 +317,6 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
lfun->dispatch(LFUN_MESSAGE, str.str().c_str());
}
// WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count));
this->operator()();
scanres = scanLogFile(terr);
if (scanres & ERRORS) {

View File

@ -241,7 +241,7 @@ void LyXView::updateWindowTitle()
void LyXView::showState()
{
message(CurrentState(view()));
message(currentState(view()));
getToolbar()->update();
menubar->update();
}

View File

@ -72,7 +72,8 @@ Thesaurus::~Thesaurus()
}
std::vector<Thesaurus::ThesaurusEntry> Thesaurus::lookup(string const & text)
std::vector<Thesaurus::ThesaurusEntry>
Thesaurus::lookup(string const & /*text*/)
{
return std::vector<ThesaurusEntry>();
}

View File

@ -1,3 +1,4 @@
// -*- C++ -*-
/**
* \file Thesaurus.h
* Copyright 2001 the LyX Team

View File

@ -547,6 +547,11 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
#endif
} else if (token == "\\begin_float") {
insertErtContents(par, pos, font);
//insertErtContents(par, pos, font, false);
//ert_stack.push(ert_comp);
//ert_comp = ErtComp();
// This is the compability reader. It can be removed in
// LyX version 1.3.0. (Lgb)
lex.next();
@ -628,6 +633,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
inset->read(this, nylex);
par->insertInset(pos, inset, font);
++pos;
insertErtContents(par, pos, font);
} else if (token == "\\begin_deeper") {
++depth;
} else if (token == "\\end_deeper") {
@ -1051,6 +1057,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
#ifdef NO_LATEX
ert_comp = ert_stack.top();
ert_stack.pop();
insertErtContents(par, pos, font);
#endif
} else if (token == "\\SpecialChar") {
LyXLayout const & layout =

View File

@ -28,55 +28,56 @@
#include "gettext.h"
#include "ParagraphParameters.h"
void Emph(BufferView * bv)
void emph(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setEmph(LyXFont::TOGGLE);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
void Bold(BufferView * bv)
void bold(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setSeries(LyXFont::BOLD_SERIES);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
void Noun(BufferView * bv)
void noun(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setNoun(LyXFont::TOGGLE);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
void Number(BufferView * bv)
void number(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setNumber(LyXFont::TOGGLE);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
void Lang(BufferView * bv, string const & l)
void lang(BufferView * bv, string const & l)
{
LyXFont font(LyXFont::ALL_IGNORE);
Language const * lang = languages.getLanguage(l);
if (lang) {
font.setLanguage(lang);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
} else
WriteAlert(_("Error! unknown language"),l);
}
#ifndef NO_LATEX
void Tex(BufferView * bv)
void tex(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setLatex (LyXFont::TOGGLE);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
#endif
@ -103,55 +104,55 @@ void changeDepth(BufferView * bv, LyXText * text, int decInc)
}
void Code(BufferView * bv)
void code(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
void Sans(BufferView * bv)
void sans(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setFamily(LyXFont::SANS_FAMILY);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
void Roman(BufferView * bv)
void roman(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setFamily(LyXFont::ROMAN_FAMILY);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
void StyleReset(BufferView * bv)
void styleReset(BufferView * bv)
{
LyXFont font(LyXFont::ALL_INHERIT);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
void Underline(BufferView * bv)
void underline(BufferView * bv)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setUnderbar(LyXFont::TOGGLE);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
void FontSize(BufferView * bv, string const & size)
void fontSize(BufferView * bv, string const & size)
{
LyXFont font(LyXFont::ALL_IGNORE);
font.setLyXSize(size);
ToggleAndShow(bv, font);
toggleAndShow(bv, font);
}
// Returns the current font and depth as a message.
string const CurrentState(BufferView * bv)
string const currentState(BufferView * bv)
{
ostringstream state;
@ -211,7 +212,7 @@ string const CurrentState(BufferView * bv)
/* -------> Does the actual toggle job of the XxxCB() calls above.
* Also shows the current font state.
*/
void ToggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
{
if (bv->available()) {
if (bv->theLockingInset()) {

View File

@ -23,37 +23,36 @@ class LyXFont;
class LyXText;
///
extern void Emph(BufferView *);
extern void emph(BufferView *);
///
extern void Bold(BufferView *);
extern void bold(BufferView *);
///
extern void Noun(BufferView *);
extern void noun(BufferView *);
///
extern void Figure();
extern void table();
///
extern void Table();
extern void lang(BufferView *, string const &);
///
extern void Lang(BufferView *, string const &);
extern void number(BufferView *);
///
extern void Number(BufferView *);
///
extern void Tex(BufferView *);
extern void tex(BufferView *);
///
extern void changeDepth(BufferView *, LyXText *, int);
///
extern void Code(BufferView *);
extern void code(BufferView *);
///
extern void Sans(BufferView *);
extern void sans(BufferView *);
///
extern void Roman(BufferView *);
extern void roman(BufferView *);
///
extern void StyleReset(BufferView *);
extern void styleReset(BufferView *);
///
extern void Underline(BufferView *);
extern void underline(BufferView *);
///
extern void FontSize(BufferView *, string const &);
extern void fontSize(BufferView *, string const &);
/// Returns the current font and depth as a message.
extern string const CurrentState(BufferView *);
extern string const currentState(BufferView *);
///
extern void ToggleAndShow(BufferView *, LyXFont const &, bool toggleall=true);
extern void toggleAndShow(BufferView *, LyXFont const &,
bool toggleall = true);
#endif

View File

@ -69,7 +69,7 @@ void ControlCharacter::apply()
if (lv_.view()->available())
view().apply();
ToggleAndShow(lv_.view(), *(font_.get()), toggleall_);
toggleAndShow(lv_.view(), *(font_.get()), toggleall_);
lv_.view()->setState();
lv_.buffer()->markDirty();
setMinibuffer(&lv_, _("Character set"));

View File

@ -59,7 +59,8 @@ void ControlThesaurus::replace(string const & newstr)
}
std::vector<string> ControlThesaurus::getEntries(string const & str, Thesaurus::POS pos)
std::vector<string>
ControlThesaurus::getEntries(string const & str, Thesaurus::POS pos)
{
if (str != laststr_)
entries_ = thesaurus.lookup(str);

View File

@ -42,13 +42,13 @@ string const _(string const & str)
char * tmp = new char[s + 1];
str.copy(tmp, s);
tmp[s] = '\0';
string ret(gettext(tmp));
string const ret(gettext(tmp));
delete [] tmp;
return ret;
}
else
} else {
return string();
}
}
void locale_init()
{

View File

@ -1008,15 +1008,7 @@ InsetText::localDispatch(BufferView * bv,
}
lt->clearSelection();
for (string::size_type i = 0; i < arg.length(); ++i) {
if (greek_kb_flag) {
if (!math_insert_greek(bv, arg[i])) {
bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], lt);
} else if (!the_locking_inset) {
(void)moveRight(bv, false);
}
} else {
bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], lt);
}
}
}
lt->selection.cursor = lt->cursor;

View File

@ -94,6 +94,7 @@
#include "TextCache.h"
#include "lyxfind.h"
#include "undo_funcs.h"
#include "figureForm.h"
using std::pair;
using std::make_pair;
@ -1454,30 +1455,6 @@ string const LyXFunc::dispatch(int ac,
// --- insert characters ----------------------------------------
// --- Mathed stuff. If we are here, there is no locked inset yet.
// Greek mode
case LFUN_GREEK:
{
if (!greek_kb_flag) {
greek_kb_flag = 1;
setMessage(N_("Math greek mode on"));
} else
greek_kb_flag = 0;
}
break;
// Greek keyboard
case LFUN_GREEK_TOGGLE:
{
greek_kb_flag = greek_kb_flag ? 0 : 2;
if (greek_kb_flag) {
setMessage(N_("Math greek keyboard on"));
} else {
setMessage(N_("Math greek keyboard off"));
}
}
break;
case LFUN_MATH_EXTERN:
case LFUN_MATH_NUMBER:
case LFUN_MATH_NONUMBER:

View File

@ -275,6 +275,7 @@ void LyXRC::readBindFileIfNeeded()
ReadBindFile(bind_file);
}
int LyXRC::read(string const & filename)
{
LyXLex lexrc(lyxrcTags, lyxrcCount);
@ -306,7 +307,8 @@ int LyXRC::read(string const & filename)
switch (static_cast<LyXRCTags>(le)) {
case RC_INPUT: // Include file
if (lexrc.next()) {
string tmp = LibFileSearch(string(),
string const tmp =
LibFileSearch(string(),
lexrc.GetString());
if (read(tmp)) {
lexrc.printError("Error reading "
@ -316,7 +318,7 @@ int LyXRC::read(string const & filename)
break;
case RC_BINDFILE: // RVDK_PATCH_5
if (lexrc.next()) {
string tmp(lexrc.GetString());
string const tmp(lexrc.GetString());
if (hasBindFile)
// We are already in the
// "actually read bind file"
@ -353,7 +355,7 @@ int LyXRC::read(string const & filename)
case RC_KBMAP_PRIMARY:
if (lexrc.next()) {
string kmap(lexrc.GetString());
string const kmap(lexrc.GetString());
if (kmap.empty()) {
// nothing
} else if (!LibFileSearch("kbd", kmap,
@ -366,7 +368,7 @@ int LyXRC::read(string const & filename)
case RC_KBMAP_SECONDARY:
if (lexrc.next()) {
string kmap(lexrc.GetString());
string const kmap(lexrc.GetString());
if (kmap.empty()) {
// nothing
} else if (!LibFileSearch("kbd", kmap,
@ -484,7 +486,8 @@ int LyXRC::read(string const & filename)
case RC_DEFAULT_PAPERSIZE:
if (lexrc.next()) {
string size = lowercase(lexrc.GetString());
string const size =
lowercase(lexrc.GetString());
if (size == "usletter")
default_papersize =
BufferParams::PAPER_USLETTER;

View File

@ -910,46 +910,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
}
/* FIXME: math-greek-toggle seems to work OK, but math-greek doesn't turn
* on greek mode */
bool math_insert_greek(BufferView * bv, char c)
{
if (!bv->available())
return false;
if (!isalpha(c))
return false;
string tmp;
tmp = c;
if (!bv->theLockingInset() || bv->theLockingInset()->isTextInset()) {
int greek_kb_flag_save = greek_kb_flag;
InsetFormula * new_inset = new InsetFormula();
bv->beforeChange(bv->text);
if (!bv->insertInset(new_inset)) {
delete new_inset;
return false;
}
//Update(1);//BUG
new_inset->edit(bv, 0, 0, 0);
new_inset->localDispatch(bv, LFUN_SELFINSERT, tmp);
if (greek_kb_flag_save < 2) {
bv->unlockInset(new_inset); // bv->theLockingInset());
bv->text->cursorRight(bv, true);
}
} else
if (bv->theLockingInset()->lyxCode() == Inset::MATH_CODE ||
bv->theLockingInset()->lyxCode() == Inset::MATHMACRO_CODE)
static_cast<InsetFormula*>(bv->theLockingInset())->localDispatch(bv, LFUN_SELFINSERT, tmp);
else
lyxerr << "Math error: attempt to write on a wrong "
"class of inset." << endl;
return true;
}
Inset::Code InsetFormulaBase::lyxCode() const
{
return Inset::MATH_CODE;

View File

@ -87,6 +87,10 @@ unsigned char getuchar(std::istream * is)
{
char c;
is->get(c);
if (!is->good()) {
lyxerr << "The input stream is not well..." << endl;
}
return static_cast<unsigned char>(c);
}
@ -349,7 +353,6 @@ int yylex()
}
MathScriptInset * prevScriptInset(MathArray const & array)
{
MathInset * p = array.back_inset();
@ -380,21 +383,21 @@ MathInset * lastScriptInset(MathArray & array, bool up, bool down, int limits)
}
static bool curr_num;
static string curr_label;
void mathed_parse_lines(MathInset * inset, int col, bool numbered, bool outmost)
void mathed_parse_lines(MathInset * inset, int col,
bool numbered, bool outmost)
{
// save global variables
bool saved_num = curr_num;
string saved_label = curr_label;
bool const saved_num = curr_num;
string const saved_label = curr_label;
MathGridInset * p = static_cast<MathGridInset *>(inset);
for (int row = 0; true; ++row) {
// reset global variables
curr_num = numbered;
curr_label = string();
curr_label.erase();
// reading a row
int idx = p->nargs() - p->ncols();
@ -429,8 +432,8 @@ MathInset * mathed_parse()
switch (t) {
case LM_TK_NEWCOMMAND: {
string name = lexArg('{').substr(1);
string arg = lexArg('[');
string const name = lexArg('{').substr(1);
string const arg = lexArg('[');
int narg = arg.empty() ? 0 : atoi(arg.c_str());
p = new MathMacroTemplate(name, narg);
mathed_parse_into(p->cell(0), FLAG_BRACE | FLAG_BRACE_LAST);
@ -453,7 +456,7 @@ MathInset * mathed_parse()
case LM_OT_SIMPLE: {
curr_num = latex_mathenv[i].numbered;
curr_label = string();
curr_label.erase();
mathed_parse_into(m->cell(0), 0);
m->numbered(0, curr_num);
m->label(0, curr_label);
@ -462,7 +465,7 @@ MathInset * mathed_parse()
case LM_OT_EQUATION: {
curr_num = latex_mathenv[i].numbered;
curr_label = string();
curr_label.erase();
mathed_parse_into(m->cell(0), FLAG_END);
m->numbered(0, curr_num);
m->label(0, curr_label);
@ -779,8 +782,8 @@ void mathed_parse_into(MathArray & array, unsigned flags)
MathInsetTypes typ = latex_mathenv[i].typ;
if (typ == LM_OT_MATRIX) {
string valign = lexArg('[') + 'c';
string halign = lexArg('{');
string const valign = lexArg('[') + 'c';
string const halign = lexArg('{');
//lyxerr << "valign: '" << valign << "'\n";
//lyxerr << "halign: '" << halign << "'\n";
MathArrayInset * m = new MathArrayInset(halign.size(), 1);
@ -822,9 +825,9 @@ void mathed_parse_into(MathArray & array, unsigned flags)
do {
t = yylex();
} while (yyis->good() && t != LM_TK_END && t);
} else
} else {
t = yylex();
}
}
--plevel;
}

View File

@ -26,7 +26,7 @@ using std::strlen;
namespace {
bool getTokenValue(string const & str, const char * token, string & ret)
bool getTokenValue(string const & str, char const * token, string & ret)
{
size_t token_length = strlen(token);
string::size_type pos = str.find(token);
@ -48,7 +48,7 @@ bool getTokenValue(string const & str, const char * token, string & ret)
}
bool getTokenValue(string const & str, const char * token, int & num)
bool getTokenValue(string const & str, char const * token, int & num)
{
string::size_type pos = str.find(token);
char ch = str[pos + strlen(token)];
@ -72,7 +72,7 @@ bool getTokenValue(string const & str, const char * token, int & num)
}
bool getTokenValue(string const & str, const char * token, LyXAlignment & num)
bool getTokenValue(string const & str, char const * token, LyXAlignment & num)
{
int tmp;
bool const ret = getTokenValue(str, token, tmp);
@ -81,7 +81,7 @@ bool getTokenValue(string const & str, const char * token, LyXAlignment & num)
}
bool getTokenValue(string const & str, const char * token,
bool getTokenValue(string const & str, char const * token,
LyXTabular::VAlignment & num)
{
int tmp;
@ -91,7 +91,7 @@ bool getTokenValue(string const & str, const char * token,
}
bool getTokenValue(string const & str, const char * token,
bool getTokenValue(string const & str, char const * token,
LyXTabular::BoxType & num)
{
int tmp;
@ -101,7 +101,7 @@ bool getTokenValue(string const & str, const char * token,
}
bool getTokenValue(string const & str, const char * token, bool & flag)
bool getTokenValue(string const & str, char const * token, bool & flag)
{
string::size_type pos = str.find(token);
char ch = str[pos + strlen(token)];

View File

@ -1747,10 +1747,10 @@ void LyXText::insertChar(BufferView * bview, char c)
cursor.par(),
cursor.pos()-1).number() == LyXFont::ON)
)
Number(bview); // Set current_font.number to OFF
number(bview); // Set current_font.number to OFF
} else if (isdigit(c) &&
real_current_font.isVisibleRightToLeft()) {
Number(bview); // Set current_font.number to ON
number(bview); // Set current_font.number to ON
if (cursor.pos() > 0) {
char const c = cursor.par()->getChar(cursor.pos() - 1);