]> git.lyx.org Git - lyx.git/blobdiff - src/kbmap.C
Move #includes out of header files.
[lyx.git] / src / kbmap.C
index e1a0cce71e5f2a95e985c175d78d8fe4aad9e487..595b6d3372ebcce40bdb98b569cf1a0ef264141c 100644 (file)
@@ -1,10 +1,14 @@
 /**
  * \file kbmap.C
- * Copyright 1995-2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author unknown
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
+ * \author John Levon
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
@@ -93,15 +97,20 @@ bool kb_keymap::read(string const & bind_file)
 
        string const tmp = i18nLibFileSearch("bind", bind_file, "bind");
        lexrc.setFile(tmp);
-       if (!lexrc.isOK()) return false;
+       if (!lexrc.isOK()) {
+               lyxerr << "kb_keymap::read: cannot open bind file:" 
+                      << tmp << endl;
+               return false;
+       }
 
-       lyxerr[Debug::KBMAP] << "Reading bindfile:" << tmp << endl;
+       lyxerr[Debug::KBMAP] << "Reading bind file:" << tmp << endl;
 
        bool error = false;
-       while (lexrc.isOK()) {
+       while (!error && lexrc.isOK()) {
                switch (lexrc.lex()) {
                case LyXLex::LEX_UNDEF:
                        lexrc.printError("Unknown tag `$$Token'");
+                       error = true;
                        continue;
                case LyXLex::LEX_FEOF:
                        continue;
@@ -113,6 +122,7 @@ bool kb_keymap::read(string const & bind_file)
                                seq = lexrc.getString();
                        } else {
                                lexrc.printError("BN_BIND: Missing key sequence");
+                               error = true;
                                break;
                        }
                        
@@ -120,6 +130,7 @@ bool kb_keymap::read(string const & bind_file)
                                cmd = lexrc.getString();
                        } else {
                                lexrc.printError("BN_BIND: missing command");
+                               error = true;
                                break;
                        }
                        
@@ -127,16 +138,17 @@ bool kb_keymap::read(string const & bind_file)
                        if (!action == LFUN_UNKNOWN_ACTION) {
                                lexrc.printError("BN_BIND: Unknown LyX"
                                                 " function `$$Token'");
+                               error = true;
                                break;
                        }
                        
-                       error = (bind(seq, kb_action(action)) != string::npos);
+                       bind(seq, kb_action(action));
                        break;
                }
                case BN_BINDFILE:
                        if (lexrc.next()) {
                                string const tmp(lexrc.getString());
-                               error = read(tmp);
+                               error = !read(tmp);
                        } else {
                                lexrc.printError("BN_BINDFILE: Missing file name");
                                error = true;
@@ -147,11 +159,10 @@ bool kb_keymap::read(string const & bind_file)
                }
        }
 
-       if (error) {
-               lyxerr << "Error reading bind file: " << tmp << endl;
-       }
-
-       return error;
+       if (error)
+               lyxerr << "kb_keymap::read: error while reading bind file:" 
+                      << tmp << endl;
+       return !error;
 }