-
Notifications
You must be signed in to change notification settings - Fork 1
/
git_view.h
50 lines (38 loc) · 902 Bytes
/
git_view.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// handy text editor
// Copyright (c) 2024 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#pragma once
#include "view.h"
#include <vector>
class GitView : public View {
public:
GitView(const std::string& path);
std::string get_status_text() const override;
void show(Ctx* ctx) override;
bool on_key(Ctx* ctx, const Key& key) override;
void on_search_text(const std::string& text, int skip) override;
private:
struct HunkRange {
int line;
int nlines;
};
struct Hunk {
HunkRange from, to;
std::string raw;
};
using Hunks = std::vector<Hunk>;
struct Item {
char x, y;
std::string file;
bool open = false;
Hunks hunks;
void fill_hunks();
};
using Items = std::vector<Item>;
void git_status();
std::string m_path;
Items m_items;
int m_selected = 0;
};