فهرست منبع

[wip][add] display "gaps" between added differences

B Thibault 9 سال پیش
والد
کامیت
0285fe922a
2فایلهای تغییر یافته به همراه46 افزوده شده و 5 حذف شده
  1. 2 1
      include/curseSplitOutput.hh
  2. 44 4
      src/curseSplitOutput.cpp

+ 2 - 1
include/curseSplitOutput.hh

@@ -39,7 +39,8 @@ class CurseSplitOutput: public CurseOutput
         bool redraw(const t_Cursor &screenSize, std::pair<int, JSonContainer *> &);
         bool redraw(const t_Cursor &screenSize, JSonElement *);
         const Optional<bool> redrawOneItemToWorkingWin(t_subWindow &w, const t_Cursor &);
-        const Optional<bool> isAdded(const std::pair<int, JSonContainer *> &);
+        bool isAdded(const std::pair<int, JSonContainer *> &) const;
+        bool isAdded(const JSonElement *e) const;
 
         bool writeContainer(const t_Cursor &maxSize, JSonContainer *, bool opening = true);
         bool writeContent(const t_Cursor &maxSize, std::list<JSonElement*> *_item);

+ 44 - 4
src/curseSplitOutput.cpp

@@ -436,12 +436,42 @@ bool CurseSplitOutput::redraw()
     }
     while (writingDone)
     {
+        bool restart = false;
         workingWin = 0;
-        //TODO first, iterate through windows to check which one has "new" items (and prints them)
         for (t_subWindow &w : subWindows)
         {
-            ;
+            if ((writingDone & (1 << workingWin)) &&
+                    ((!w.parentsIterators.empty() && isAdded(w.parentsIterators.top())) ||
+                     (w.parentsIterators.empty() && isAdded(w.root))))
+            {
+                const unsigned int startY = w.cursor.second;
+
+                do
+                {
+                    const Optional<bool> wrote = redrawOneItemToWorkingWin(w, screenSize);
+
+                    if (wrote.absent())
+                        return false;
+                    if (wrote.get())
+                    {
+                        writingDone &= ~(1 << workingWin);
+                        break;
+                    }
+                } while (isAdded(w.parentsIterators.top()));
+
+                const unsigned int diffY = w.cursor.second - startY;
+                unsigned int i = 0;
+                for (t_subWindow &wi: subWindows)
+                    if (i++ != workingWin)
+                        wi.cursor.second += diffY;
+                restart = true;
+                break;
+            }
+            ++workingWin;
         }
+        if (restart)
+            continue;
+        workingWin = 0;
         for (t_subWindow &w : subWindows)
         {
             if ((writingDone & (1 << workingWin)))
@@ -601,9 +631,19 @@ bool CurseSplitOutput::writeKey(const std::string &key, const size_t keylen, con
     return (cursor.second < w.scrollTop || (cursor.second - w.scrollTop) <= maxWidth.second);
 }
 
-const Optional<bool> CurseSplitOutput::isAdded(const std::pair<int, JSonContainer *> &item)
+bool CurseSplitOutput::isAdded(const JSonElement *e) const
+{
+    return diffMatrice->getEquivalence(e) == nullptr;
+}
+
+bool CurseSplitOutput::isAdded(const std::pair<int, JSonContainer *> &item) const
 {
-    return Optional<bool>::empty;
+    const JSonElement *e;
+
+    if ((unsigned int) (item.first +1) == item.second->size())
+        e = item.second;
+    e = list_at<JSonElement*>(*(item.second), item.first +1);
+    return isAdded(e);
 }
 
 bool CurseSplitOutput::redraw(const t_Cursor &maxSize, std::pair<int, JSonContainer *> &item)