|
|
@@ -374,18 +374,14 @@ const Optional<bool> CurseSplitOutput::redrawOneItemToWorkingWin(t_subWindow &w,
|
|
|
|
|
|
try {
|
|
|
if (w.parentsIterators.empty())
|
|
|
- result = redraw(screenSize, w.root);
|
|
|
+ result = redraw(w, screenSize, w.root);
|
|
|
else
|
|
|
- result = redraw(screenSize, w.parentsIterators.top());
|
|
|
+ result = redraw(w, screenSize, w.parentsIterators.top());
|
|
|
}
|
|
|
catch (SelectionOutOfRange &e)
|
|
|
{
|
|
|
return Optional<bool>::empty;
|
|
|
}
|
|
|
- catch (CurseSplitOutput::reachNext &)
|
|
|
- {
|
|
|
- result = true;
|
|
|
- }
|
|
|
if (!result || w.parentsIterators.empty())
|
|
|
{
|
|
|
if (!result)
|
|
|
@@ -524,81 +520,12 @@ bool CurseSplitOutput::writeContainer(const t_Cursor &maxSize, JSonContainer *it
|
|
|
if (w.cursor.second > w.scrollTop && (w.cursor.second - w.scrollTop) > maxSize.second -1)
|
|
|
return false;
|
|
|
w.parentsIterators.push(std::pair<int, JSonContainer *>(-1, item));
|
|
|
- if (!writeContent(maxSize, (std::list<JSonElement *> *)item))
|
|
|
- {
|
|
|
- w.parentsIterators.pop();
|
|
|
- return false;
|
|
|
- }
|
|
|
- w.parentsIterators.pop();
|
|
|
- w.cursor.second += write(w.cursor.first, w.cursor.second, childDelimiter[1], maxSize.first, CurseSplitOutput::getFlag(item));
|
|
|
+ w.cursor.first += INDENT_LEVEL;
|
|
|
+ return true;
|
|
|
}
|
|
|
return (w.cursor.second < w.scrollTop || (w.cursor.second - w.scrollTop) <= maxSize.second -1);
|
|
|
}
|
|
|
|
|
|
-bool CurseSplitOutput::writeContent(const t_Cursor &maxSize, std::list<JSonElement*> *_item)
|
|
|
-{
|
|
|
- t_subWindow &w = subWindows.at(workingWin);
|
|
|
- JSonContainer *item = (JSonContainer *)_item;
|
|
|
- bool containerIsObject = (dynamic_cast<JSonObject *>(item) != nullptr);
|
|
|
- bool result = true;
|
|
|
- w.cursor.first += INDENT_LEVEL;
|
|
|
- const unsigned int scrollTop = w.scrollTop;
|
|
|
-
|
|
|
- for (JSonElement *i : *item)
|
|
|
- {
|
|
|
- result = false;
|
|
|
- if (containerIsObject)
|
|
|
- {
|
|
|
- JSonObjectEntry *ent = (JSonObjectEntry*) i;
|
|
|
- bool isContainer = (dynamic_cast<JSonContainer *>(**ent) != nullptr);
|
|
|
- std::string key = ent->stringify();
|
|
|
- checkSelection(ent);
|
|
|
- if (isContainer && collapsed.find((JSonContainer*)(**ent)) != collapsed.cend())
|
|
|
- {
|
|
|
- if (dynamic_cast<JSonObject *>(**ent))
|
|
|
- {
|
|
|
- if (!CurseOutput::writeKey(key, ent->lazystrlen(), "{ ... }", w.cursor, maxSize, CurseSplitOutput::getFlag(ent)) || (w.cursor.second > scrollTop && (w.cursor.second - scrollTop) > maxSize.second -1))
|
|
|
- break;
|
|
|
- }
|
|
|
- else if (!CurseOutput::writeKey(key, ent->lazystrlen(), "[ ... ]", w.cursor, maxSize, CurseSplitOutput::getFlag(ent)) || (w.cursor.second > scrollTop && (w.cursor.second - scrollTop) > maxSize.second -1))
|
|
|
- break;
|
|
|
- }
|
|
|
- else if (!isContainer)
|
|
|
- {
|
|
|
- JSonElement *eContent = **ent;
|
|
|
- if (!writeKey(key, ent->lazystrlen(), eContent->stringify(), eContent->lazystrlen(), w.cursor, maxSize, CurseSplitOutput::getFlag(ent)) || (w.cursor.second > scrollTop && (w.cursor.second - scrollTop) > maxSize.second -1))
|
|
|
- break;
|
|
|
- }
|
|
|
- else if (((JSonContainer*)(**ent))->size() == 0)
|
|
|
- {
|
|
|
- if (dynamic_cast<const JSonObject *>(**ent) )
|
|
|
- {
|
|
|
- if (!CurseOutput::writeKey(key, ent->lazystrlen(), "{ }", w.cursor, maxSize, CurseSplitOutput::getFlag(ent)) || (w.cursor.second > scrollTop && (w.cursor.second - scrollTop) > maxSize.second -1))
|
|
|
- break;
|
|
|
- }
|
|
|
- else if (!CurseOutput::writeKey(key, ent->lazystrlen(), "[ ]", w.cursor, maxSize, CurseSplitOutput::getFlag(ent)) || (w.cursor.second > scrollTop && (w.cursor.second - scrollTop) > maxSize.second -1))
|
|
|
- break;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!writeKey(key, ent->lazystrlen(), maxSize, getFlag(ent)))
|
|
|
- break;
|
|
|
- const JSonElement *saveSelection = w.lastSelection;
|
|
|
- if (saveSelection == ent)
|
|
|
- w.selection = w.lastSelection = **ent;
|
|
|
- w.cursor.first += INDENT_LEVEL /2;
|
|
|
- throw CurseSplitOutput::reachNext();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- throw CurseSplitOutput::reachNext();
|
|
|
- result = true;
|
|
|
- }
|
|
|
- w.cursor.first -= INDENT_LEVEL;
|
|
|
- //result will be false if for loop break'd at some time, true otherwise
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
bool CurseSplitOutput::writeKey(const std::string &key, const size_t keylen, const t_Cursor &maxSize, OutputFlag flags, unsigned int extraLen)
|
|
|
{
|
|
|
t_subWindow &w = subWindows.at(workingWin);
|
|
|
@@ -653,36 +580,21 @@ bool CurseSplitOutput::isAdded(const std::pair<int, JSonContainer *> &item) cons
|
|
|
return isAdded(e);
|
|
|
}
|
|
|
|
|
|
-bool CurseSplitOutput::redraw(const t_Cursor &maxSize, std::pair<int, JSonContainer *> &item)
|
|
|
+bool CurseSplitOutput::redraw(t_subWindow &w, const t_Cursor &maxSize, std::pair<int, JSonContainer *> &item)
|
|
|
{
|
|
|
- t_subWindow &w = subWindows.at(workingWin);
|
|
|
JSonElement *currentItem;
|
|
|
|
|
|
(item.first)++;
|
|
|
if ((unsigned int) item.first == item.second->size())
|
|
|
{
|
|
|
w.parentsIterators.pop();
|
|
|
- if (!writeContainer(maxSize, item.second, false))
|
|
|
- return false;
|
|
|
- throw CurseSplitOutput::reachNext();
|
|
|
+ return writeContainer(maxSize, item.second, false);
|
|
|
}
|
|
|
currentItem = list_at<JSonElement*>(*(item.second), item.first);
|
|
|
- checkSelection(currentItem);
|
|
|
- if (dynamic_cast<const JSonContainer*>(currentItem))
|
|
|
- {
|
|
|
- if (!writeContainer(maxSize, (JSonContainer*) currentItem))
|
|
|
- return false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- w.cursor.second += CurseOutput::write(w.cursor.first, w.cursor.second, currentItem, maxSize.first, CurseSplitOutput::getFlag(currentItem));
|
|
|
- if (w.cursor.second > w.scrollTop && (w.cursor.second - w.scrollTop) > maxSize.second -1)
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
+ return redraw(w, maxSize, currentItem);
|
|
|
}
|
|
|
|
|
|
-bool CurseSplitOutput::redraw(const t_Cursor &maxSize, JSonElement *item)
|
|
|
+bool CurseSplitOutput::redraw(t_subWindow &w, const t_Cursor &maxSize, JSonElement *item)
|
|
|
{
|
|
|
checkSelection(item);
|
|
|
if (dynamic_cast<const JSonContainer*>(item))
|
|
|
@@ -692,8 +604,6 @@ bool CurseSplitOutput::redraw(const t_Cursor &maxSize, JSonElement *item)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- t_subWindow &w = subWindows.at(workingWin);
|
|
|
-
|
|
|
w.cursor.second += CurseOutput::write(w.cursor.first, w.cursor.second, item, maxSize.first, CurseSplitOutput::getFlag(item));
|
|
|
if (w.cursor.second > w.scrollTop && (w.cursor.second - w.scrollTop) > maxSize.second -1)
|
|
|
return false;
|