wxMaxima
Loading...
Searching...
No Matches
DiffFrame.h
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2// Copyright (C) 2026 Gemini CLI
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//
19// SPDX-License-Identifier: GPL-2.0+
20
21#ifndef DIFFFRAME_H
22#define DIFFFRAME_H
23
24#include "worksheet/Worksheet.h"
25#include <wx/wx.h>
26#include <wx/srchctrl.h>
27#include <vector>
28#include <memory>
29
30class DiffMarkerBar;
31
32class DiffFrame : public wxFrame
33{
34public:
35 DiffFrame(wxWindow *parent, const wxArrayString &files, Configuration *config);
36 virtual ~DiffFrame();
37
39 Worksheet *GetPane(size_t idx) const
40 { return idx < m_worksheets.size() ? m_worksheets[idx] : nullptr; }
42 Worksheet *ActivePane() const;
49 bool FindNext(bool down);
51 wxSearchCtrl *GetSearchCtrl() const { return m_searchCtrl; }
52
53private:
54 void OnScroll(wxScrollWinEvent &event);
55 void OnToggleHorizontalSync(wxCommandEvent &event);
56 void OnToggleVerticalSync(wxCommandEvent &event);
57 void OnSearch(wxCommandEvent &event);
58 void OnSearchCancel(wxCommandEvent &event);
60 void OnSearchEnter(wxCommandEvent &event);
61 void OnFindNext(wxCommandEvent &event);
62 void OnFindPrev(wxCommandEvent &event);
64 void OnFocusSearch(wxCommandEvent &event);
71 void OnCopyCommand(wxCommandEvent &event);
73 void OnSelectAll(wxCommandEvent &event);
80 bool SearchPanes(const wxString &query, bool down, bool incremental);
81 void OnDiffNext(wxCommandEvent &event);
82 void OnDiffPrev(wxCommandEvent &event);
83
87 int CurrentScrollY(size_t idx) const;
91 void SyncScrollFrom(int src_idx, int y_new_src);
92
93 std::vector<Worksheet *> m_worksheets;
94 std::vector<std::unique_ptr<Configuration>> m_worksheetConfigurations;
95 Configuration *m_configuration;
96 wxSearchCtrl *m_searchCtrl = nullptr;
98 size_t m_searchPane = 0;
100 size_t m_activePane = 0;
101 int m_currentDiffIdx = -1;
102 bool m_syncing = false;
103 bool m_syncHorizontal = true;
104 bool m_syncVertical = true;
105
106 void LoadFiles(const wxArrayString &files);
107 void AlignCells();
108
109 struct DiffEntry {
110 GroupCell *cells[3]; // 0, 1, 2
111 };
112 std::vector<DiffEntry> m_diffEntries;
113 std::vector<int> m_lastScrollY;
114
117 bool IsDiffEntry(const DiffEntry &e) const;
122 void UpdateDiffNavUI();
123 void OnIdle(wxIdleEvent &event);
127 int FindAdjacentDiff(int direction) const;
130 void SetCurrentDiff(int idx);
131
132 friend class DiffMarkerBar;
135 struct DiffMark { int docY; bool current; };
137 std::vector<DiffMark> DiffMarksForPane(size_t paneIdx) const;
140 void JumpToNearestDiff(size_t paneIdx, int docY);
142 std::vector<DiffMarkerBar *> m_markerBars;
145 int m_lastBarViewTop = -1;
146 int m_lastBarCurrent = -2;
152 std::vector<int> m_lastBarDocHeights;
153
154 wxToolBar *m_toolBar = nullptr;
156 wxStaticText *m_diffStatus = nullptr;
159 int m_shownPrevEnabled = -1;
160 int m_shownNextEnabled = -1;
161
167 wxTimer m_resizeTimer;
168 void RelayoutWorksheets();
173 int m_lastLayoutWidth = -1;
174};
175
176#endif // DIFFFRAME_H
This file defines the class Worksheet.
The configuration storage for the current worksheet.
Definition: Configuration.h:101
Definition: DiffFrame.h:33
Worksheet * ActivePane() const
The pane copy commands and select-all act on (see m_activePane)
Definition: DiffFrame.cpp:741
Worksheet * GetPane(size_t idx) const
The worksheet of pane idx (nullptr if there is no such pane)
Definition: DiffFrame.h:39
bool FindNext(bool down)
Moves to the next (down) or previous match of the search field's text.
Definition: DiffFrame.cpp:682
wxSearchCtrl * GetSearchCtrl() const
The search field (exposed for the tests)
Definition: DiffFrame.h:51
Definition: DiffFrame.cpp:44
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:121