+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
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
#include "ButtonPolicies.h"
#include "debug.h"
+using std::endl;
/// Helper function
static inline
<< in
<< " from state "
<< state
- << std::endl;
+ << endl;
}
}
using std::find;
using std::find_if;
-using std::getline;
-using std::istream;
using std::pair;
using std::sort;
using std::vector;
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;
-
- if (line[0] != '!') {
- RGB col;
- string name;
+ 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");
+
+ // 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;
- }
-
- // 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 (name == "black" || name == "white") {
+ cols.insert(cols.begin(), col);
+ names.insert(names.begin(), name);
+ } else {
+ cols.push_back(col);
+ names.push_back(name);
}
-
- 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) {
}
+void LyXLex::setCommentChar(char c)
+{
+ pimpl_->setCommentChar(c);
+}
+
int LyXLex::lex()
{
return pimpl_->lex();
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();
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();
}
lineno = 0;
}
+void LyXLex::Pimpl::setCommentChar(char c)
+{
+ commentChar = c;
+}
+
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
continue;
}
- if (c == '#') {
+ if (c == commentChar) {
// Read rest of line (fast :-)
// That is still not fast... (Lgb)
#if 1
///
void setStream(std::istream & i);
///
+ void setCommentChar(char c);
+ ///
bool next(bool esc = false);
///
int search_kw(char const * const tag) const;
int lineno;
///
string pushTok;
+ ///
+ char commentChar;
private:
///
void verifyTable();
// 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;
#include "debug.h"
#include "filetools.h"
+using std::endl;
+
extern string system_tempdir;
string const lyx::tempName(string const & dir, string const & mask)