Skip to content

Commit d03c8b0

Browse files
committed
Prepare commit-tree rebuild
1 parent ca1e134 commit d03c8b0

File tree

3 files changed

+77
-7
lines changed

3 files changed

+77
-7
lines changed

src/core/OSTreeTUI.cpp

+20-7
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,28 @@ int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& sta
142142
// interchangeable view (composed)
143143
Manager manager(infoView, filterView, promotionView);
144144
Component managerRenderer = manager.managerRenderer;
145-
146-
// COMMIT TREE
147-
Component logRenderer = Scroller(&selectedCommit, CommitRender::COMMIT_DETAIL_LEVEL, Renderer([&] {
148-
visibleCommitViewMap = parseVisibleCommitMap(ostreeRepo, visibleBranches);
149-
selectedCommit = std::min(selectedCommit, visibleCommitViewMap.size() - 1);
150-
return CommitRender::commitRender(ostreeRepo, visibleCommitViewMap, visibleBranches, branchColorMap, selectedCommit);
151-
}));
152145

153146
// FOOTER
154147
Footer footer;
155148
Component footerRenderer = Renderer([&] {
156149
return footer.footerRender();
157150
});
158151

152+
// COMMIT TREE
153+
/* TODO - The commit-tree is currentrly under a heavy rebuild, see implementation To-Dos below.
154+
* For a general list of To-Dos refer to https://github.com/AP-Sensing/ostree-tui/pull/21
155+
*
156+
* > Component commitTree should be a Stacked(...) to allow for snappy windows to be arranged with
157+
* a drag & drop funcitonality.
158+
* > Snappy Windows should be an abstracted element, similar to windows, but snapping back to their
159+
* place after being dropped.
160+
*/
161+
Component logRenderer = Scroller(&selectedCommit, CommitRender::COMMIT_DETAIL_LEVEL, Renderer([&] {
162+
visibleCommitViewMap = parseVisibleCommitMap(ostreeRepo, visibleBranches);
163+
selectedCommit = std::min(selectedCommit, visibleCommitViewMap.size() - 1);
164+
return CommitRender::commitRender(ostreeRepo, visibleCommitViewMap, visibleBranches, branchColorMap, selectedCommit);
165+
}));
166+
159167
// window specific shortcuts
160168
logRenderer = CatchEvent(logRenderer, [&](Event event) {
161169
// switch through commits
@@ -168,6 +176,11 @@ int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& sta
168176
return false;
169177
});
170178

179+
/*
180+
* END of commit-tree TODO
181+
* Probably shouldn't have to change anything outside of this.
182+
*/
183+
171184
int logSize{45};
172185
int footerSize{1};
173186
Component container{managerRenderer};

src/util/snappyWindow.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "scroller.hpp"
2+
3+
#include <algorithm> // for max, min
4+
#include <ftxui/component/component_base.hpp> // for Component, ComponentBase
5+
#include <ftxui/component/event.hpp> // for Event, Event::ArrowDown, Event::ArrowUp, Event::End, Event::Home, Event::PageDown, Event::PageUp
6+
#include <utility> // for move
7+
8+
#include "ftxui/component/component.hpp"// for Make
9+
#include "ftxui/component/mouse.hpp" // for Mouse, Mouse::WheelDown, Mouse::WheelUp
10+
#include "ftxui/dom/deprecated.hpp" // for text
11+
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, vbox, EQUAL, HEIGHT, dbox, reflect, focus, inverted, nothing, select, vscroll_indicator, yflex, yframe
12+
#include "ftxui/dom/node.hpp" // for Node
13+
#include "ftxui/dom/requirement.hpp" // for Requirement
14+
#include "ftxui/screen/box.hpp" // for Box
15+
16+
namespace ftxui {
17+
18+
class SnappyWindowBase : public ComponentBase {
19+
public:
20+
SnappyWindowBase() {}
21+
22+
private:
23+
Element Render() final {
24+
return text("not implemented yet");
25+
}
26+
27+
bool Focusable() const final { return true; }
28+
};
29+
30+
Component SnappyWindow() {
31+
return Make<SnappyWindowBase>();
32+
}
33+
34+
} // namespace ftxui

src/util/snappyWindow.hpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef SCROLLER_H
2+
#define SCROLLER_H
3+
4+
#include <ftxui/component/component.hpp>
5+
6+
#include "ftxui/component/component_base.hpp" // for Component
7+
8+
namespace ftxui {
9+
/**
10+
* @brief This Scroller Element is a modified version of the Scroller in the following repository:
11+
* Title: git-tui
12+
* Author: Arthur Sonzogni
13+
* Date: 2021
14+
* Availability: https://github.com/ArthurSonzogni/git-tui/blob/master/src/scroller.cpp
15+
*
16+
* @param selectedCommit
17+
* @param child
18+
* @return Component
19+
*/
20+
Component SnappyWindow(size_t *selectedCommit, size_t elementLength, Component child);
21+
22+
} // namespace ftxui
23+
#endif /* end of include guard: SCROLLER_H */

0 commit comments

Comments
 (0)