Skip to content

Commit 8464e43

Browse files
committed
Add branch info
1 parent 7cdd5ed commit 8464e43

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

src/core/OSTreeTUI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ OSTreeTUI::OSTreeTUI (const std::string& repo, const std::vector<std::string> st
141141
});
142142

143143
// interchangeable view (composed)
144-
manager = std::unique_ptr<Manager>(new Manager(infoView, filterView));
144+
manager = std::unique_ptr<Manager>(new Manager(*this, infoView, filterView));
145145
managerRenderer = manager->managerRenderer;
146146

147147
// FOOTER

src/core/OSTreeTUI.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
#include "../util/cpplibostree.hpp"
2222

23+
class BranchBoxManager; // TODO fix includes
24+
class Manager; // TODO fix includes
25+
2326
class OSTreeTUI {
2427
public:
2528
/**
@@ -42,7 +45,7 @@ class OSTreeTUI {
4245

4346
/// @brief Refresh Level 2: Refreshes the commit list component & upper levels
4447
void refresh_commitListComoponent();
45-
48+
4649
/// @brief Refresh Level 1: Refreshes complete repository & upper levels
4750
bool refresh_repository();
4851

src/core/commit.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,6 @@ ftxui::Element commitRender(OSTreeTUI& ostreetui, const std::unordered_map<std::
351351
if (usedBranches.at(relevantBranch) == -1) {
352352
ostreetui.columnToBranchMap.push_back(relevantBranch);
353353
usedBranches.at(relevantBranch) = nextAvailableSpace--;
354-
// TODO somehow incorporate the branch name into the commit-tree
355-
//addLine(RenderTree::TREE_LINE_IGNORE_BRANCH, RenderLine::BRANCH_HEAD,
356-
// treeElements, commElements, commit, highlight, usedBranches, branchColorMap);
357354
}
358355
// commit
359356
if (scrollOffset++ >= 0) {

src/core/manager.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// Manager
1414

15-
Manager::Manager(const ftxui::Component& infoView, const ftxui::Component& filterView) {
15+
Manager::Manager(OSTreeTUI& ostreetui, const ftxui::Component& infoView, const ftxui::Component& filterView) : ostreetui(ostreetui) {
1616
using namespace ftxui;
1717

1818
tabSelection = Menu(&tab_entries, &tab_index, MenuOption::HorizontalAnimated());
@@ -25,7 +25,17 @@ Manager::Manager(const ftxui::Component& infoView, const ftxui::Component& filte
2525

2626
managerRenderer = Container::Vertical({
2727
tabSelection,
28-
tabContent
28+
tabContent,
29+
Renderer([] {return vbox({filler()}) | flex;}), // push elements apart
30+
Renderer([&] {
31+
Elements branches;
32+
for (int i{ostreetui.columnToBranchMap.size() - 1}; i >= 0; i--) {
33+
std::string branch = ostreetui.columnToBranchMap.at(i);
34+
std::string line = "――☐――― " + branch;
35+
branches.push_back(text(line) | color(ostreetui.branchColorMap.at(branch)));
36+
}
37+
return vbox(branches);
38+
})
2939
});
3040
}
3141

src/core/manager.hpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,24 @@
55
| different modes should be supported (like a rebase mode
66
| exchangeable with the commit info)
77
|___________________________________________________________*/
8+
#pragma once
89

910
#include <string>
1011
#include <unordered_map>
1112

1213
#include "ftxui/component/component.hpp" // for Component
1314

15+
#include "OSTreeTUI.hpp"
16+
1417
#include "../util/cpplibostree.hpp"
1518

19+
class OSTreeTUI; // TODO fix includes
20+
1621
/// Interchangeable View
1722
class Manager {
1823
public:
24+
OSTreeTUI& ostreetui;
25+
1926
int tab_index{0};
2027

2128
std::vector<std::string> tab_entries = {
@@ -30,7 +37,7 @@ class Manager {
3037
ftxui::Component managerRenderer;
3138

3239
public:
33-
Manager(const ftxui::Component& infoView, const ftxui::Component& filterView);
40+
Manager(OSTreeTUI& ostreetui, const ftxui::Component& infoView, const ftxui::Component& filterView);
3441
};
3542

3643
class CommitInfoManager {

0 commit comments

Comments
 (0)