Skip to content

Commit dfb7d4c

Browse files
committed
make naming consistent
naming of files, variables, methods
1 parent 120ce8a commit dfb7d4c

11 files changed

+78
-79
lines changed

src/core/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ add_library(ostree-tui_core commit.cpp
88
footer.hpp
99
manager.cpp
1010
manager.hpp
11-
OSTreeTUI.cpp
12-
OSTreeTUI.hpp
13-
trashBin.cpp
14-
trashBin.hpp)
11+
ostreetui.cpp
12+
ostreetui.hpp
13+
trashbin.cpp
14+
trashbin.hpp)
1515

1616
target_link_libraries(ostree-tui_core
1717
PRIVATE clip

src/core/commit.cpp

+37-38
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

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

25-
#include "OSTreeTUI.hpp"
25+
#include "ostreetui.hpp"
2626

2727
namespace CommitRender {
2828

@@ -76,8 +76,8 @@ Element DefaultRenderState(const WindowRenderState& state,
7676
class CommitComponentImpl : public ComponentBase, public WindowOptions {
7777
public:
7878
explicit CommitComponentImpl(size_t position, std::string commit, OSTreeTUI& ostreetui)
79-
: drag_initial_x(1),
80-
drag_initial_y(static_cast<int>(position) * COMMIT_WINDOW_HEIGHT),
79+
: defaultX(1),
80+
defaultY(static_cast<int>(position) * COMMIT_WINDOW_HEIGHT),
8181
commitPosition(position),
8282
hash(std::move(commit)),
8383
ostreetui(ostreetui),
@@ -96,20 +96,20 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
9696
Add(inner);
9797

9898
title = hash.substr(0, 8);
99-
top = drag_initial_y;
100-
left = drag_initial_x;
99+
top = defaultY;
100+
left = defaultX;
101101
width = COMMIT_WINDOW_WIDTH;
102102
height = COMMIT_WINDOW_HEIGHT;
103103
}
104104

105105
private:
106106
void resetWindow(bool positionReset = true) {
107107
if (positionReset) {
108-
left() = drag_initial_x;
109-
top() = drag_initial_y;
108+
left() = defaultX;
109+
top() = defaultY;
110110
}
111-
width() = width_initial;
112-
height() = height_initial;
111+
width() = defaultWidth;
112+
height() = defaultHeight;
113113
// reset window contents
114114
DetachAllChildren();
115115
Add(simpleCommit);
@@ -202,7 +202,7 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
202202
}
203203

204204
// Position and record the drawn area of the window.
205-
element |= reflect(box_window_);
205+
element |= reflect(boxWindow_);
206206
element |= PositionAndSize(left(), top() + ostreetui.GetScrollOffset(), width(), height());
207207
element |= reflect(box_);
208208

@@ -253,22 +253,22 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
253253
return true;
254254
}
255255

256-
mouse_hover_ = box_window_.Contain(event.mouse().x, event.mouse().y);
256+
mouseHover_ = boxWindow_.Contain(event.mouse().x, event.mouse().y);
257257

258-
if (mouse_hover_ && event.mouse().button == Mouse::Left) {
258+
if (mouseHover_ && event.mouse().button == Mouse::Left) {
259259
ostreetui.SetSelectedCommit(commitPosition);
260260
}
261261

262-
if (captured_mouse_) {
262+
if (capturedMouse_) {
263263
if (event.mouse().motion == Mouse::Released) {
264264
// reset mouse
265-
captured_mouse_ = nullptr;
265+
capturedMouse_ = nullptr;
266266
// drop commit
267267
if (event.mouse().y > ostreetui.GetScreen().dimy() - 8) {
268268
ostreetui.SetViewMode(ViewMode::COMMIT_DROP, hash);
269269
ostreetui.SetModeBranch(
270270
ostreetui.GetOstreeRepo().GetCommitList().at(hash).branch);
271-
top() = drag_initial_y;
271+
top() = defaultY;
272272
}
273273
// check if position matches branch & do something if it does
274274
else if (ostreetui.GetModeBranch().empty()) {
@@ -281,8 +281,8 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
281281
}
282282

283283
if (drag_) {
284-
left() = event.mouse().x - drag_start_x - box_.x_min;
285-
top() = event.mouse().y - drag_start_y - box_.y_min;
284+
left() = event.mouse().x - dragStartX - box_.x_min;
285+
top() = event.mouse().y - dragStartY - box_.y_min;
286286
ostreetui.SetViewMode(ViewMode::COMMIT_DRAGGING, hash);
287287
// check if potential commit deletion
288288
if (event.mouse().y > ostreetui.GetScreen().dimy() - 8) {
@@ -318,7 +318,7 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
318318
return true;
319319
}
320320

321-
if (!mouse_hover_) {
321+
if (!mouseHover_) {
322322
return false;
323323
}
324324

@@ -335,38 +335,37 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
335335

336336
TakeFocus();
337337

338-
captured_mouse_ = CaptureMouse(event);
339-
if (!captured_mouse_) {
338+
capturedMouse_ = CaptureMouse(event);
339+
if (!capturedMouse_) {
340340
return true;
341341
}
342342

343-
drag_start_x = event.mouse().x - left() - box_.x_min;
344-
drag_start_y = event.mouse().y - top() - box_.y_min;
343+
dragStartX = event.mouse().x - left() - box_.x_min;
344+
dragStartY = event.mouse().y - top() - box_.y_min;
345345

346-
const bool drag_old = drag_;
346+
const bool dragOld = drag_;
347347
drag_ = true;
348-
if (!drag_old && drag_) { // if we start dragging
349-
drag_initial_x = left();
350-
drag_initial_y = top();
348+
if (!dragOld && drag_) { // if we start dragging
349+
defaultX = left();
350+
defaultY = top();
351351
}
352352
return true;
353353
}
354354

355355
// window specific members
356356
Box box_;
357-
Box box_window_;
357+
Box boxWindow_;
358358

359-
CapturedMouse captured_mouse_;
360-
int drag_start_x = 0;
361-
int drag_start_y = 0;
362-
363-
int drag_initial_x;
364-
int drag_initial_y;
365-
int width_initial = COMMIT_WINDOW_WIDTH;
366-
int height_initial = COMMIT_WINDOW_HEIGHT;
367-
368-
bool mouse_hover_ = false;
359+
bool mouseHover_ = false;
369360
bool drag_ = false;
361+
CapturedMouse capturedMouse_;
362+
int dragStartX = 0;
363+
int dragStartY = 0;
364+
365+
int defaultX;
366+
int defaultY;
367+
int defaultWidth = COMMIT_WINDOW_WIDTH;
368+
int defaultHeight = COMMIT_WINDOW_HEIGHT;
370369

371370
// ostree-tui specific members
372371
size_t commitPosition;
@@ -447,7 +446,7 @@ ftxui::Component CommitComponent(size_t position, const std::string& commit, OST
447446
return ftxui::Make<CommitComponentImpl>(position, commit, ostreetui);
448447
}
449448

450-
ftxui::Element commitRender(OSTreeTUI& ostreetui,
449+
ftxui::Element CommitRender(OSTreeTUI& ostreetui,
451450
const std::unordered_map<std::string, ftxui::Color>& branchColorMap) {
452451
using namespace ftxui;
453452

src/core/commit.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ enum RenderTree : uint8_t {
6363
* @param selectedCommit Commit that should be marked as selected.
6464
* @return UI Element
6565
*/
66-
[[nodiscard]] ftxui::Element commitRender(
66+
[[nodiscard]] ftxui::Element CommitRender(
6767
OSTreeTUI& ostreetui,
6868
const std::unordered_map<std::string, ftxui::Color>& branchColorMap);
6969

src/core/footer.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Footer {
1212
void ResetContent();
1313

1414
/// @brief Creates a Renderer for the footer section.
15-
ftxui::Element FooterRender();
15+
[[nodiscard]] ftxui::Element FooterRender();
1616

1717
// Setter
1818
void SetContent(std::string content);

src/core/manager.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

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

13-
#include "OSTreeTUI.hpp"
13+
#include "ostreetui.hpp"
1414

1515
// Manager
1616

@@ -20,9 +20,9 @@ Manager::Manager(OSTreeTUI& ostreetui,
2020
: ostreetui(ostreetui) {
2121
using namespace ftxui;
2222

23-
tabSelection = Menu(&tab_entries, &tab_index, MenuOption::HorizontalAnimated());
23+
tabSelection = Menu(&tabEntries, &tabIndex, MenuOption::HorizontalAnimated());
2424

25-
tabContent = Container::Tab({infoView, filterView}, &tab_index);
25+
tabContent = Container::Tab({infoView, filterView}, &tabIndex);
2626

2727
managerRenderer = Container::Vertical(
2828
{tabSelection, tabContent,
@@ -38,12 +38,12 @@ Manager::Manager(OSTreeTUI& ostreetui,
3838
})});
3939
}
4040

41-
ftxui::Component Manager::getManagerRenderer() {
41+
ftxui::Component Manager::GetManagerRenderer() {
4242
return managerRenderer;
4343
}
4444

45-
int Manager::getTabIndex() const {
46-
return tab_index;
45+
int Manager::GetTabIndex() const {
46+
return tabIndex;
4747
}
4848

4949
// BranchBoxManager
@@ -63,21 +63,21 @@ BranchBoxManager::BranchBoxManager(OSTreeTUI& ostreetui,
6363
}
6464
}
6565

66-
ftxui::Element BranchBoxManager::branchBoxRender() {
66+
ftxui::Element BranchBoxManager::BranchBoxRender() {
6767
using namespace ftxui;
6868

6969
// branch filter
70-
Elements bfb_elements = {
70+
Elements bfbElements = {
7171
text(L"branches:") | bold,
7272
filler(),
7373
branchBoxes->Render() | vscroll_indicator | frame | size(HEIGHT, LESS_THAN, 10),
7474
};
75-
return vbox(bfb_elements);
75+
return vbox(bfbElements);
7676
}
7777

7878
// CommitInfoManager
7979

80-
ftxui::Element CommitInfoManager::renderInfoView(const cpplibostree::Commit& displayCommit) {
80+
ftxui::Element CommitInfoManager::RenderInfoView(const cpplibostree::Commit& displayCommit) {
8181
using namespace ftxui;
8282

8383
// selected commit info

src/core/manager.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ class Manager {
2121
const ftxui::Component& infoView,
2222
const ftxui::Component& filterView);
2323

24+
public:
25+
[[nodiscard]] ftxui::Component GetManagerRenderer();
26+
[[nodiscard]] int GetTabIndex() const;
27+
2428
private:
2529
OSTreeTUI& ostreetui;
2630

27-
int tab_index{0};
28-
std::vector<std::string> tab_entries = {" Info ", " Filter "};
31+
int tabIndex{0};
32+
std::vector<std::string> tabEntries = {" Info ", " Filter "};
2933

3034
// because the combination of all interchangeable views is very simple,
3135
// we can (in contrast to the other ones) render this one here
3236
ftxui::Component managerRenderer;
3337
ftxui::Component tabSelection;
3438
ftxui::Component tabContent;
35-
36-
public:
37-
ftxui::Component getManagerRenderer();
38-
int getTabIndex() const;
3939
};
4040

4141
class CommitInfoManager {
@@ -46,7 +46,7 @@ class CommitInfoManager {
4646
* @param displayCommit Commit to display the information of.
4747
* @return ftxui::Element
4848
*/
49-
[[nodiscard]] static ftxui::Element renderInfoView(const cpplibostree::Commit& displayCommit);
49+
[[nodiscard]] static ftxui::Element RenderInfoView(const cpplibostree::Commit& displayCommit);
5050
};
5151

5252
class BranchBoxManager {
@@ -60,7 +60,7 @@ class BranchBoxManager {
6060
*
6161
* @return ftxui::Element
6262
*/
63-
[[nodiscard]] ftxui::Element branchBoxRender();
63+
[[nodiscard]] ftxui::Element BranchBoxRender();
6464

6565
public:
6666
ftxui::Component branchBoxes = ftxui::Container::Vertical({});

src/core/OSTreeTUI.cpp src/core/ostreetui.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "OSTreeTUI.hpp"
1+
#include "ostreetui.hpp"
22

33
#include <fcntl.h>
44
#include <algorithm>
@@ -55,9 +55,9 @@ OSTreeTUI::OSTreeTUI(const std::string& repo, const std::vector<std::string>& st
5555
promotionBranchColorMap.insert({str, Color::GrayDark});
5656
}
5757
}
58-
return CommitRender::commitRender(*this, promotionBranchColorMap);
58+
return CommitRender::CommitRender(*this, promotionBranchColorMap);
5959
}
60-
return CommitRender::commitRender(*this, branchColorMap);
60+
return CommitRender::CommitRender(*this, branchColorMap);
6161
});
6262

6363
commitListComponent = Container::Horizontal({tree, commitList});
@@ -87,19 +87,19 @@ OSTreeTUI::OSTreeTUI(const std::string& repo, const std::vector<std::string>& st
8787
if (visibleCommitViewMap.size() <= 0) {
8888
return text(" no commit info available ") | color(Color::RedLight) | bold | center;
8989
}
90-
return CommitInfoManager::renderInfoView(
90+
return CommitInfoManager::RenderInfoView(
9191
ostreeRepo.GetCommitList().at(visibleCommitViewMap.at(selectedCommit)));
9292
});
9393

9494
// filter
9595
filterManager =
9696
std::unique_ptr<BranchBoxManager>(new BranchBoxManager(*this, ostreeRepo, visibleBranches));
9797
filterView =
98-
Renderer(filterManager->branchBoxes, [&] { return filterManager->branchBoxRender(); });
98+
Renderer(filterManager->branchBoxes, [&] { return filterManager->BranchBoxRender(); });
9999

100100
// interchangeable view (composed)
101101
manager = std::unique_ptr<Manager>(new Manager(*this, infoView, filterView));
102-
managerRenderer = manager->getManagerRenderer();
102+
managerRenderer = manager->GetManagerRenderer();
103103

104104
// FOOTER
105105
FooterRenderer = Renderer([&] { return footer.FooterRender(); });
@@ -143,7 +143,7 @@ OSTreeTUI::OSTreeTUI(const std::string& repo, const std::vector<std::string>& st
143143
}
144144
// make commit list focussable
145145
if (event == Event::ArrowLeft && managerRenderer->Focused() &&
146-
manager->getTabIndex() == 0) {
146+
manager->GetTabIndex() == 0) {
147147
commitListComponent->TakeFocus();
148148
return true;
149149
}
@@ -380,7 +380,7 @@ int OSTreeTUI::showHelp(const std::string& caller, const std::string& errorMessa
380380
using namespace ftxui;
381381

382382
// define command line options
383-
std::vector<std::vector<std::string>> command_options{
383+
std::vector<std::vector<std::string>> commandOptions{
384384
// option, arguments, meaning
385385
{"-h, --help", "", "Show help options. The REPOSITORY_PATH can be omitted"},
386386
{"-r, --refs", "REF [REF...]",
@@ -390,7 +390,7 @@ int OSTreeTUI::showHelp(const std::string& caller, const std::string& errorMessa
390390
Elements options{text("Options:")};
391391
Elements arguments{text("Arguments:")};
392392
Elements meanings{text("Meaning:")};
393-
for (const auto& command : command_options) {
393+
for (const auto& command : commandOptions) {
394394
options.push_back(text(command.at(0) + " ") | color(Color::GrayLight));
395395
arguments.push_back(text(command.at(1) + " ") | color(Color::GrayLight));
396396
meanings.push_back(text(command.at(2) + " "));

src/core/OSTreeTUI.hpp src/core/ostreetui.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "commit.hpp"
1818
#include "footer.hpp"
1919
#include "manager.hpp"
20-
#include "trashBin.hpp"
20+
#include "trashbin.hpp"
2121

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

0 commit comments

Comments
 (0)