mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Use lyxlex to parse rgb.txt + small compilation fixes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1206 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7ec7c9da44
commit
1a3ed565d9
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
2000-11-08 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* src/frontends/xforms/FormPreferences.C (ColoursLoadBrowser): use
|
||||
lyxlex to parse the rgb.txt file.
|
||||
|
||||
* src/lyxlex.[Ch]:
|
||||
* src/lyxlex_pimpl.[Ch]: implement setCommentChar method, to
|
||||
replace the default '#' comment character.
|
||||
|
||||
* src/support/tempname.C: add "using" directive
|
||||
* src/frontends/ButtonPolicies.C: ditto.
|
||||
|
||||
* src/support/filetools.C (DirList): add an explicit cast to avoid
|
||||
a compile error (probably not the right fix)
|
||||
|
||||
2000-11-08 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/support/filetools.C (DirList): implement using system functions
|
||||
|
@ -47,35 +47,35 @@ src/frontends/kde/refdlg.C
|
||||
src/frontends/kde/tocdlg.C
|
||||
src/frontends/kde/urldlg.C
|
||||
src/frontends/xforms/FormBase.h
|
||||
src/frontends/xforms/form_citation.C
|
||||
src/frontends/xforms/FormCitation.C
|
||||
src/frontends/xforms/form_copyright.C
|
||||
src/frontends/xforms/form_citation.C
|
||||
src/frontends/xforms/FormCopyright.C
|
||||
src/frontends/xforms/form_document.C
|
||||
src/frontends/xforms/form_copyright.C
|
||||
src/frontends/xforms/FormDocument.C
|
||||
src/frontends/xforms/form_error.C
|
||||
src/frontends/xforms/form_document.C
|
||||
src/frontends/xforms/FormError.C
|
||||
src/frontends/xforms/form_graphics.C
|
||||
src/frontends/xforms/form_error.C
|
||||
src/frontends/xforms/FormGraphics.C
|
||||
src/frontends/xforms/form_index.C
|
||||
src/frontends/xforms/form_graphics.C
|
||||
src/frontends/xforms/FormIndex.C
|
||||
src/frontends/xforms/form_index.C
|
||||
src/frontends/xforms/FormInset.h
|
||||
src/frontends/xforms/form_paragraph.C
|
||||
src/frontends/xforms/FormParagraph.C
|
||||
src/frontends/xforms/form_preferences.C
|
||||
src/frontends/xforms/form_paragraph.C
|
||||
src/frontends/xforms/FormPreferences.C
|
||||
src/frontends/xforms/form_print.C
|
||||
src/frontends/xforms/form_preferences.C
|
||||
src/frontends/xforms/FormPrint.C
|
||||
src/frontends/xforms/form_ref.C
|
||||
src/frontends/xforms/form_print.C
|
||||
src/frontends/xforms/FormRef.C
|
||||
src/frontends/xforms/form_tabular.C
|
||||
src/frontends/xforms/form_ref.C
|
||||
src/frontends/xforms/FormTabular.C
|
||||
src/frontends/xforms/form_tabular_create.C
|
||||
src/frontends/xforms/form_tabular.C
|
||||
src/frontends/xforms/FormTabularCreate.C
|
||||
src/frontends/xforms/form_toc.C
|
||||
src/frontends/xforms/form_tabular_create.C
|
||||
src/frontends/xforms/FormToc.C
|
||||
src/frontends/xforms/form_url.C
|
||||
src/frontends/xforms/form_toc.C
|
||||
src/frontends/xforms/FormUrl.C
|
||||
src/frontends/xforms/form_url.C
|
||||
src/frontends/xforms/Menubar_pimpl.C
|
||||
src/gettext.h
|
||||
src/importer.C
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "ButtonPolicies.h"
|
||||
#include "debug.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
/// Helper function
|
||||
static inline
|
||||
@ -38,7 +39,7 @@ void nextState(ButtonPolicy::State & state,
|
||||
<< in
|
||||
<< " from state "
|
||||
<< state
|
||||
<< std::endl;
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,6 @@ using SigC::slot;
|
||||
|
||||
using std::find;
|
||||
using std::find_if;
|
||||
using std::getline;
|
||||
using std::istream;
|
||||
using std::pair;
|
||||
using std::sort;
|
||||
using std::vector;
|
||||
@ -426,58 +424,47 @@ bool FormPreferences::inputColours( FL_OBJECT const * const ob )
|
||||
bool FormPreferences::ColoursLoadBrowser(string const & filename)
|
||||
{
|
||||
LyXLex lex(0, 0);
|
||||
|
||||
lex.setCommentChar('!');
|
||||
|
||||
if (!lex.setFile(filename))
|
||||
return false;
|
||||
|
||||
istream & is = lex.getStream();
|
||||
string line;
|
||||
|
||||
vector<RGB> cols;
|
||||
vector<string> names;
|
||||
|
||||
while (true) {
|
||||
getline( is, line );
|
||||
if (line.empty() )
|
||||
break;
|
||||
while (lex.next()) {
|
||||
RGB col;
|
||||
col.r = lex.GetInteger();
|
||||
lex.next();
|
||||
col.g = lex.GetInteger();
|
||||
lex.next();
|
||||
col.b = lex.GetInteger();
|
||||
lex.EatLine();
|
||||
string name = frontStrip(lex.GetString(), " \t");
|
||||
|
||||
if (line[0] != '!') {
|
||||
RGB col;
|
||||
string name;
|
||||
// remove redundant entries on the fly
|
||||
bool add = cols.empty();
|
||||
if (!add) {
|
||||
vector<RGB>::const_iterator it =
|
||||
find( cols.begin(), cols.end(), col );
|
||||
add = (it == cols.end());
|
||||
}
|
||||
|
||||
if (add) {
|
||||
name = lowercase( name );
|
||||
if (name == "gray0" ) name = "black";
|
||||
if (name == "gray100" ) name = "white";
|
||||
|
||||
istringstream iss(line.c_str());
|
||||
iss >> col.r >> col.g >> col.b;
|
||||
while (iss.good()) {
|
||||
string next;
|
||||
iss >> next;
|
||||
if (!name.empty() ) name += " ";
|
||||
name += next;
|
||||
if (name == "black" || name == "white") {
|
||||
cols.insert(cols.begin(), col);
|
||||
names.insert(names.begin(), name);
|
||||
} else {
|
||||
cols.push_back(col);
|
||||
names.push_back(name);
|
||||
}
|
||||
|
||||
// remove redundant entries on the fly
|
||||
bool add = cols.empty();
|
||||
if (!add) {
|
||||
vector<RGB>::const_iterator it =
|
||||
find( cols.begin(), cols.end(), col );
|
||||
add = (it == cols.end());
|
||||
}
|
||||
|
||||
if (add) {
|
||||
name = lowercase( name );
|
||||
if (name == "gray0" ) name = "black";
|
||||
if (name == "gray100" ) name = "white";
|
||||
|
||||
if (name == "black" || name == "white") {
|
||||
cols.insert(cols.begin(), col);
|
||||
names.insert(names.begin(), name);
|
||||
} else {
|
||||
cols.push_back(col);
|
||||
names.push_back(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
vector<string>::iterator sit = names.begin();
|
||||
for (vector<RGB>::const_iterator iit = cols.begin();
|
||||
iit != cols.end(); ++iit, ++sit) {
|
||||
|
@ -104,6 +104,11 @@ void LyXLex::setStream(istream & i)
|
||||
}
|
||||
|
||||
|
||||
void LyXLex::setCommentChar(char c)
|
||||
{
|
||||
pimpl_->setCommentChar(c);
|
||||
}
|
||||
|
||||
int LyXLex::lex()
|
||||
{
|
||||
return pimpl_->lex();
|
||||
|
@ -58,7 +58,9 @@ public:
|
||||
std::istream & getStream();
|
||||
/// Danger! Don't use it unless you know what you are doing.
|
||||
void setLineNo(int l);
|
||||
|
||||
/// Change the character that begins a comment. Default is '#'
|
||||
void setCommentChar(char c);
|
||||
|
||||
/// returns a lex code
|
||||
int lex();
|
||||
|
||||
|
@ -30,7 +30,7 @@ struct compare_tags {
|
||||
|
||||
LyXLex::Pimpl::Pimpl(keyword_item * tab, int num)
|
||||
: is(&fb__), table(tab), no_items(num),
|
||||
status(0), lineno(0)
|
||||
status(0), lineno(0), commentChar('#')
|
||||
{
|
||||
verifyTable();
|
||||
}
|
||||
@ -130,6 +130,11 @@ void LyXLex::Pimpl::setStream(istream & i)
|
||||
lineno = 0;
|
||||
}
|
||||
|
||||
void LyXLex::Pimpl::setCommentChar(char c)
|
||||
{
|
||||
commentChar = c;
|
||||
}
|
||||
|
||||
|
||||
bool LyXLex::Pimpl::next(bool esc /* = false */)
|
||||
{
|
||||
@ -146,7 +151,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
|
||||
while (is && !status) {
|
||||
is.get(cc);
|
||||
c = cc;
|
||||
if (c == '#') {
|
||||
if (c == commentChar) {
|
||||
// Read rest of line (fast :-)
|
||||
// That is not fast... (Lgb)
|
||||
#if 1
|
||||
@ -262,7 +267,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '#') {
|
||||
if (c == commentChar) {
|
||||
// Read rest of line (fast :-)
|
||||
// That is still not fast... (Lgb)
|
||||
#if 1
|
||||
|
@ -37,6 +37,8 @@ struct LyXLex::Pimpl : public noncopyable {
|
||||
///
|
||||
void setStream(std::istream & i);
|
||||
///
|
||||
void setCommentChar(char c);
|
||||
///
|
||||
bool next(bool esc = false);
|
||||
///
|
||||
int search_kw(char const * const tag) const;
|
||||
@ -66,6 +68,8 @@ struct LyXLex::Pimpl : public noncopyable {
|
||||
int lineno;
|
||||
///
|
||||
string pushTok;
|
||||
///
|
||||
char commentChar;
|
||||
private:
|
||||
///
|
||||
void verifyTable();
|
||||
|
@ -269,7 +269,13 @@ vector<string> const DirList( string const & dir, string const & ext)
|
||||
// This is a non-error checking C/system implementation
|
||||
// of the above.
|
||||
string extension(ext);
|
||||
if (extension[0] != '.') extension.insert(0u, 1u, '.');
|
||||
if (extension[0] != '.')
|
||||
// If I do not use the explicit cast below, compaq cxx
|
||||
// is not able to guess between
|
||||
// insert(size_type, size_type, value_type)
|
||||
// and
|
||||
// insert(iterator, size_type, value_type)
|
||||
extension.insert(string::size_type(0), 1u, '.');
|
||||
vector<string> dirlist;
|
||||
DIR * dirp = ::opendir(dir.c_str());
|
||||
dirent * dire;
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "debug.h"
|
||||
#include "filetools.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
extern string system_tempdir;
|
||||
|
||||
string const lyx::tempName(string const & dir, string const & mask)
|
||||
|
Loading…
Reference in New Issue
Block a user