2 کامیت‌ها 2935798ecc ... 2376570c7d

نویسنده SHA1 پیام تاریخ
  David Blue 2376570c7d paging works much better now, that lineCount is reset to 0 each time a page is added to the pagedText. Also hoping to stop having to manually remvoing the kdevelop lock file from commits. 9 سال پیش
  David Blue a5f184b208 got width to output correctly, though there still isn't a way to configure it. 9 سال پیش
4فایلهای تغییر یافته به همراه34 افزوده شده و 6 حذف شده
  1. 1 0
      .kdev4/.gitignore
  2. 2 0
      src/back/passage.cpp
  3. 8 2
      src/front/interface.cpp
  4. 23 4
      src/front/pager.cpp

+ 1 - 0
.kdev4/.gitignore

@@ -1,3 +1,4 @@
 build/
 *~
 *.lock
+BIBISH.kdev4

+ 2 - 0
src/back/passage.cpp

@@ -76,6 +76,8 @@ std::string Passage::getText (std::string reference) {
     refRange = key.parseVerseList(reference.c_str(), key, true);
     for(refRange = sword::TOP; !refRange.popError(); refRange++) {
         module->setKey (refRange);
+        text += " "; //TODO: Fix this to show the book name on the first verse
+        //TODO: show chap and verse only after the first verse
         text += module->getKeyText();
         text += " ";
         text += module->renderText();

+ 8 - 2
src/front/interface.cpp

@@ -135,21 +135,25 @@ std::string Interface::processCommand(std::string command) {
         std::string displayText;
         pagedText = textPager.getPagedText(text);
         int numPages = pagedText.size();
+        int numLines = 0;
 
         while(!pagedText.empty()) {
             curPage = pagedText.front();
             displayText = "";
-            int numLines = curPage.size();
+            numLines = curPage.size();
             while(!curPage.empty()) {
                 std::string curWord;
                 curLine = curPage.front();
                 while(!curLine.empty()) {
                     curWord = curLine.front();
+                    if(curWord != "") {
                     displayText += curWord;
                     displayText += " ";
+                    }
                     curLine.pop_front();
                     curWord = "";
                 }
+                displayText += "\n";
                 curPage.pop_front();
             }
             pagedText.pop_front();
@@ -158,9 +162,11 @@ std::string Interface::processCommand(std::string command) {
             if(numPages > 1) {
                 std::string dummy = "";
                 std::cout << "Press enter for next page";
+//                 std::cout << std::endl;
                 getline(std::cin,dummy);
+                display.clearScreen();
             }
-            display.displaySpacer(numLines);
+            //display.displaySpacer(numLines);
         }
         return commandPart;
     } else if(commandPart == validCommands[2]) {

+ 23 - 4
src/front/pager.cpp

@@ -60,24 +60,42 @@ std::list<page> Pager::getPagedText(std::string text) {
     while(!words.empty()) {
         currentWord = words.front();
         words.pop_front();
+        if(currentWord == "\n") {
+            //Flush the line if we encounter a newline in the text
+            currentPage.push_back(currentLine);
+            currentLine.clear();
+            lineCount++;
+            currentWord = "";
+        }
+        if(currentWord == "\n\n") {
+           currentPage.push_back(currentLine);
+           currentLine.clear();
+           currentLine.push_back(" ");
+           currentPage.push_back(currentLine);
+           lineCount += 2;
+           currentLine.clear();
+           currentWord = "";
+        }
         if(colCount + currentWord.length() + 1 <= width) {
             currentLine.push_back(currentWord);
             colCount += currentWord.length() + 1; //+1 for space
+            currentWord = "";
         } else {
             //TODO: Do stuff about words that are by themselves longer than
             //TODO the width.
             currentPage.push_back(currentLine);
             currentLine.clear();
-            colCount = 0;
+            currentLine.push_back(currentWord);
+            colCount = currentWord.length() + 1;
             lineCount++;
         }
-        if(lineCount > pageSize + 3) {
+        if(lineCount >= pageSize - 3) {
             pagedText.push_back(currentPage);
             currentPage.clear();
+            lineCount = 0;
         }
     }
-    //Check to see if we have any lines that didn't get pushed due to being
-    //of size < width
+    //Check to see if we have any lines that didn't get pushed and flush them in
     if(currentLine.size() > 0) {
         currentPage.push_back(currentLine);
         currentLine.clear();
@@ -85,6 +103,7 @@ std::list<page> Pager::getPagedText(std::string text) {
     if(currentPage.size() > 0) {
         pagedText.push_back(currentPage);
         currentPage.clear();
+        lineCount = 0;
     }
 
     return pagedText;