Skip to content

Commit

Permalink
Add branch info
Browse files Browse the repository at this point in the history
  • Loading branch information
forgottosave committed Nov 6, 2024
1 parent 7cdd5ed commit 8464e43
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/OSTreeTUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ OSTreeTUI::OSTreeTUI (const std::string& repo, const std::vector<std::string> st
});

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

// FOOTER
Expand Down
5 changes: 4 additions & 1 deletion src/core/OSTreeTUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

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

class BranchBoxManager; // TODO fix includes
class Manager; // TODO fix includes

class OSTreeTUI {
public:
/**
Expand All @@ -42,7 +45,7 @@ class OSTreeTUI {

/// @brief Refresh Level 2: Refreshes the commit list component & upper levels
void refresh_commitListComoponent();

/// @brief Refresh Level 1: Refreshes complete repository & upper levels
bool refresh_repository();

Expand Down
3 changes: 0 additions & 3 deletions src/core/commit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,6 @@ ftxui::Element commitRender(OSTreeTUI& ostreetui, const std::unordered_map<std::
if (usedBranches.at(relevantBranch) == -1) {
ostreetui.columnToBranchMap.push_back(relevantBranch);
usedBranches.at(relevantBranch) = nextAvailableSpace--;
// TODO somehow incorporate the branch name into the commit-tree
//addLine(RenderTree::TREE_LINE_IGNORE_BRANCH, RenderLine::BRANCH_HEAD,
// treeElements, commElements, commit, highlight, usedBranches, branchColorMap);
}
// commit
if (scrollOffset++ >= 0) {
Expand Down
14 changes: 12 additions & 2 deletions src/core/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// Manager

Manager::Manager(const ftxui::Component& infoView, const ftxui::Component& filterView) {
Manager::Manager(OSTreeTUI& ostreetui, const ftxui::Component& infoView, const ftxui::Component& filterView) : ostreetui(ostreetui) {
using namespace ftxui;

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

managerRenderer = Container::Vertical({
tabSelection,
tabContent
tabContent,
Renderer([] {return vbox({filler()}) | flex;}), // push elements apart
Renderer([&] {
Elements branches;
for (int i{ostreetui.columnToBranchMap.size() - 1}; i >= 0; i--) {
std::string branch = ostreetui.columnToBranchMap.at(i);
std::string line = "――☐――― " + branch;
branches.push_back(text(line) | color(ostreetui.branchColorMap.at(branch)));
}
return vbox(branches);
})
});
}

Expand Down
9 changes: 8 additions & 1 deletion src/core/manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,24 @@
| different modes should be supported (like a rebase mode
| exchangeable with the commit info)
|___________________________________________________________*/
#pragma once

#include <string>
#include <unordered_map>

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

#include "OSTreeTUI.hpp"

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

class OSTreeTUI; // TODO fix includes

/// Interchangeable View
class Manager {
public:
OSTreeTUI& ostreetui;

int tab_index{0};

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

public:
Manager(const ftxui::Component& infoView, const ftxui::Component& filterView);
Manager(OSTreeTUI& ostreetui, const ftxui::Component& infoView, const ftxui::Component& filterView);
};

class CommitInfoManager {
Expand Down

0 comments on commit 8464e43

Please sign in to comment.