Debian Codegraph @

git/GitConsole.h

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : GitConsole.h
6 //
7 // -------------------------------------------------------------------------
8 // A
9 // _____ _ _ _ _
10 // / __ \ | | | | (_) |
11 // | / \/ ___ __| | ___| | _| |_ ___
12 // | | / _ \ / _ |/ _ \ | | | __/ _ )
13 // | \__/\ (_) | (_| | __/ |___| | || __/
14 // \____/\___/ \__,_|\___\_____/_|\__\___|
15 //
16 // F i l e
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 //////////////////////////////////////////////////////////////////////////////
25
26 #ifndef GITCONSOLE_H
27 #define GITCONSOLE_H
28
29 #include "bitmap_loader.h"
30 #include "clGenericSTCStyler.h"
31 #include "clToolBar.h"
32 #include "clWorkspaceEvent.hpp"
33 #include "gitui.h"
34
35 #include <wx/dataview.h>
36
37 class GitPlugin;
38 class GitConsole : public GitConsoleBase
39 {
40 GitPlugin* m_git;
41 bool m_isVerbose;
42 BitmapLoader* m_bitmapLoader;
43 wxBitmap m_modifiedBmp;
44 wxBitmap m_untrackedBmp;
45 wxBitmap m_folderBmp;
46 wxBitmap m_newBmp;
47 wxBitmap m_deleteBmp;
48 size_t m_indent = 0;
49 std::unordered_set<wxString> m_errorPatterns;
50 std::unordered_set<wxString> m_successPatterns;
51 std::unordered_set<wxString> m_warningPatterns;
52 wxString m_buffer;
53
54 public:
55 GitConsole(wxWindow* parent, GitPlugin* git);
56 virtual ~GitConsole();
57 void AddText(const wxString& text);
58 void AddLine(const wxString& line);
59 void PrintPrompt();
60 bool IsVerbose() const;
61 void UpdateTreeView(const wxString& output);
62
63 /**
64 * @brief return true if there are any deleted/new/modified items
65 * @return
66 */
67 bool IsDirty() const;
68
69 //
70 // Progress bar API
71 //
72 void ShowProgress(const wxString& message, bool pulse = false);
73 void HideProgress();
74 void UpdateProgress(unsigned long current, const wxString& message);
75 bool IsProgressShown() const;
76 void PulseProgress();
77 void ShowLog();
78 void SetIndent(size_t depth = 1) { m_indent = depth; }
79
80 protected:
81 wxString GetIndent() const { return wxString(' ', (m_indent * 4)); }
82 virtual void OnUnversionedFileActivated(wxDataViewEvent& event);
83 virtual void OnUnversionedFileContextMenu(wxDataViewEvent& event);
84 virtual void OnUpdateUI(wxUpdateUIEvent& event);
85 virtual void OnStclogStcChange(wxStyledTextEvent& event);
86 virtual void OnApplyPatch(wxCommandEvent& event);
87 virtual void OnFileActivated(wxDataViewEvent& event);
88 virtual void OnItemSelectedUI(wxUpdateUIEvent& event);
89 virtual void OnResetFile(wxCommandEvent& event);
90 virtual void OnContextMenu(wxDataViewEvent& event);
91 virtual void OnStopGitProcessUI(wxUpdateUIEvent& event);
92 virtual void OnClearGitLogUI(wxUpdateUIEvent& event);
93 virtual void OnClearGitLog(wxCommandEvent& event);
94 virtual void OnStopGitProcess(wxCommandEvent& event);
95 virtual void OnOpenUnversionedFiles(wxCommandEvent& event);
96 virtual void OnAddUnversionedFiles(wxCommandEvent& event);
97 void OnSysColoursChanged(clCommandEvent& event);
98
99 void OnOpenFile(wxCommandEvent& e);
100 void OnWorkspaceClosed(clWorkspaceEvent& e);
101 void OnConfigurationChanged(wxCommandEvent& e);
102 wxString GetPrompt() const;
103 bool IsPatternFound(const wxString& buffer, const std::unordered_set<wxString>& m) const;
104 bool HasAnsiEscapeSequences(const wxString& buffer) const;
105
106 void OnGitPullDropdown(wxCommandEvent& event) { DoOnDropdown("git_pull", XRCID("git_pull")); }
107 void OnGitRebaseDropdown(wxCommandEvent& event) { DoOnDropdown("git_rebase", XRCID("git_rebase")); }
108
109 void DoOnDropdown(const wxString& commandName, int id);
110 void OnDropDownMenuEvent(wxCommandEvent& e);
111 void Clear();
112 wxArrayString GetSelectedUnversionedFiles() const;
113 };
114 #endif // GITCONSOLE_H