[dasher] Remove DasherModel::m_iOffset, use GetOffset() instead



commit b607f93dad0fc5441cb1a61c6fc53c99ca46ad95
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Wed Aug 4 13:28:19 2010 +0100

    Remove DasherModel::m_iOffset, use GetOffset() instead
    
    as m_iOffset tracked location in octets, but we want unicode characters;
    fixes cases where could get canvas out-of-sync with edit box w/ e.g. accents

 Src/DasherCore/DasherModel.cpp |   16 +---------------
 Src/DasherCore/DasherModel.h   |    7 ++-----
 2 files changed, 3 insertions(+), 20 deletions(-)
---
diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp
index 527d584..fbd6a15 100644
--- a/Src/DasherCore/DasherModel.cpp
+++ b/Src/DasherCore/DasherModel.cpp
@@ -60,7 +60,6 @@ CDasherModel::CDasherModel(CEventHandler *pEventHandler,
   m_pDasherInterface = pDasherInterface;
 
   m_bGameMode = GetBoolParameter(BP_GAME_MODE);
-  m_iOffset = iOffset; // TODO: Set through build routine
 
   DASHER_ASSERT(m_pNodeCreationManager != NULL);
   DASHER_ASSERT(m_pDasherInterface != NULL);
@@ -133,17 +132,6 @@ void CDasherModel::HandleEvent(Dasher::CEvent *pEvent) {
       break;
     }
   }
-  else if(pEvent->m_iEventType == EV_EDIT) {
-    // Keep track of where we are in the buffer
-    CEditEvent *pEditEvent(static_cast < CEditEvent * >(pEvent));
-
-    if(pEditEvent->m_iEditType == 1) {
-      m_iOffset += pEditEvent->m_sText.size();
-    }
-    else if(pEditEvent->m_iEditType == 2) {
-      m_iOffset -= pEditEvent->m_sText.size();
-    }
-  }
 }
 
 void CDasherModel::Make_root(CDasherNode *pNewRoot) {
@@ -787,7 +775,7 @@ void CDasherModel::LimitRoot(int iMaxWidth) {
 }
 
 void CDasherModel::SetOffset(int iLocation, CDasherView *pView) {
-  if(iLocation == m_iOffset)
+  if(iLocation == GetOffset())
     return; // We're already there
   
   //  std::cout << "Initialising at offset: " << iLocation << std::endl;
@@ -795,8 +783,6 @@ void CDasherModel::SetOffset(int iLocation, CDasherView *pView) {
   // TODO: Special cases, ie this can be done without rebuilding the
   // model
 
-  m_iOffset = iLocation;
-
   // Now actually rebuild the model
   InitialiseAtOffset(iLocation, pView);
 }
diff --git a/Src/DasherCore/DasherModel.h b/Src/DasherCore/DasherModel.h
index 075da35..f3614ed 100644
--- a/Src/DasherCore/DasherModel.h
+++ b/Src/DasherCore/DasherModel.h
@@ -187,8 +187,8 @@ class Dasher::CDasherModel:public Dasher::CFrameRate, private NoClones
   void SetOffset(int iLocation, CDasherView *pView);
 
   ///
-  /// TODO: Figure out how all these "offset"s work / relate to each other - if they do! In particular,
-  /// what do we need DasherModel's own m_iOffset (which measures in _bytes_, not unicode characters!) for?
+  /// The current offset of the cursor/insertion point in the text buffer
+  /// - measured in (unicode) characters, _not_ octets.
   ///
 
   int GetOffset() {
@@ -272,9 +272,6 @@ class Dasher::CDasherModel:public Dasher::CFrameRate, private NoClones
   //   - and that seemed even worse, so I've removed it in favour of this here....?
   unsigned long m_iStartTime;
   
-  // Offset into buffer of node currently under crosshair
-  int m_iOffset;
-
   // Debug/performance information...
 
   // Information entered so far in this model



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