[dasher] Fix paragraph/space symbol indices (one more than indices in vector)



commit 018f06fe423fa29f0175e1b9e5d4651e1d59e3be
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Wed Nov 24 18:26:51 2010 +0000

    Fix paragraph/space symbol indices (one more than indices in vector)

 Src/DasherCore/Alphabet/AlphIO.cpp   |   26 +++++++++++++++-----------
 Src/DasherCore/Alphabet/AlphInfo.cpp |    4 ++--
 Src/DasherCore/Alphabet/AlphInfo.h   |    4 ++--
 3 files changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/Src/DasherCore/Alphabet/AlphIO.cpp b/Src/DasherCore/Alphabet/AlphIO.cpp
index b5a8bd0..342d7e3 100644
--- a/Src/DasherCore/Alphabet/AlphIO.cpp
+++ b/Src/DasherCore/Alphabet/AlphIO.cpp
@@ -347,18 +347,22 @@ CAlphInfo *CAlphIO::CreateDefault() {
     Default.m_vCharacters[i].Colour = i + 10;
   }
   Default.Orientation = Opts::LeftToRight;
-  Default.iParagraphCharacter = Chars.size();
-  Default.m_vCharacters[Default.iParagraphCharacter].Display = "¶";
+  //note iSpaceCharacter/iParagraphCharacter, as all symbol numbers, are one _more_
+  // than their index into m_vCharacters... (as "unknown symbol" 0 does not appear in vector)
+  Default.m_vCharacters.push_back(CAlphInfo::character());
+  Default.iParagraphCharacter = Default.m_vCharacters.size();
+  Default.m_vCharacters.back().Display = "¶";
 #ifdef WIN32
-  Default.m_vCharacters[Default.iParagraphCharacter].Text = "\r\n";
+  Default.m_vCharacters.back().Text = "\r\n";
 #else
-  Default.m_vCharacters[Default.iParagraphCharacter].Text = "\n";
+  Default.m_vCharacters.back().Text = "\n";
 #endif
-  Default.m_vCharacters[Default.iParagraphCharacter].Colour = 9;
-  Default.iSpaceCharacter = Chars.size()+1;
-  Default.m_vCharacters[Default.iSpaceCharacter].Display = "_";
-  Default.m_vCharacters[Default.iSpaceCharacter].Text = " ";
-  Default.m_vCharacters[Default.iSpaceCharacter].Colour = 9;
+  Default.m_vCharacters.back().Colour = 9;
+  Default.m_vCharacters.push_back(CAlphInfo::character());
+  Default.iSpaceCharacter = Default.m_vCharacters.size();
+  Default.m_vCharacters.back().Display = "_";
+  Default.m_vCharacters.back().Text = " ";
+  Default.m_vCharacters.back().Colour = 9;
   
   Default.ControlCharacter = new CAlphInfo::character();
   Default.ControlCharacter->Display = "Control";
@@ -631,13 +635,13 @@ void CAlphIO::XML_EndElement(void *userData, const XML_Char *name) {
     Reverse(Me->InputInfo->m_pBaseGroup);
     
     if (Me->ParagraphCharacter) {
-      Me->InputInfo->iParagraphCharacter = Me->InputInfo->m_vCharacters.size();
+      Me->InputInfo->iParagraphCharacter = Me->InputInfo->m_vCharacters.size()+1;
       Me->InputInfo->m_vCharacters.push_back(*(Me->ParagraphCharacter));
       Me->InputInfo->iNumChildNodes++;
       delete Me->ParagraphCharacter;
     }
     if (Me->SpaceCharacter) {
-      Me->InputInfo->iSpaceCharacter = Me->InputInfo->m_vCharacters.size();
+      Me->InputInfo->iSpaceCharacter = Me->InputInfo->m_vCharacters.size()+1;
       Me->InputInfo->m_vCharacters.push_back(*(Me->SpaceCharacter));
       Me->InputInfo->iNumChildNodes++;
       delete Me->SpaceCharacter;
diff --git a/Src/DasherCore/Alphabet/AlphInfo.cpp b/Src/DasherCore/Alphabet/AlphInfo.cpp
index 93fc3f3..89aa9e4 100644
--- a/Src/DasherCore/Alphabet/AlphInfo.cpp
+++ b/Src/DasherCore/Alphabet/AlphInfo.cpp
@@ -89,8 +89,8 @@ CAlphabetMap *CAlphInfo::MakeMap() const {
 }
 
 CAlphInfo::CAlphInfo() {
-  iSpaceCharacter=-1;
-  iParagraphCharacter = -1;
+  iSpaceCharacter=0;
+  iParagraphCharacter = 0;
   ControlCharacter=NULL;
   StartConvertCharacter=NULL;
   EndConvertCharacter=NULL;
diff --git a/Src/DasherCore/Alphabet/AlphInfo.h b/Src/DasherCore/Alphabet/AlphInfo.h
index 2c3a73c..06bc7d1 100644
--- a/Src/DasherCore/Alphabet/AlphInfo.h
+++ b/Src/DasherCore/Alphabet/AlphInfo.h
@@ -140,8 +140,8 @@ private:
     
   std::vector<character> m_vCharacters;
   
-  int iParagraphCharacter;       // index into m_vCharacters of paragraph char (display and edit text), -1 for none.
-  int iSpaceCharacter;   // index into m_vCharacters of space char (display and edit text), -1 for none.
+  symbol iParagraphCharacter;       // symbol number (index into m_vCharacters +1) of paragraph char (for display and default edit-text), 0 for none.
+  symbol iSpaceCharacter;   // symbol number (index into m_vCharacters +1) of space char (display and edit text), 0 for none.
   character *ControlCharacter; // display and edit text of Control character. Typically ("", "Control"). Use ("", "") if no control character.
   character *StartConvertCharacter;
   character *EndConvertCharacter;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]