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.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
38private:
39 void OnScroll(wxScrollWinEvent &event);
40 void OnToggleHorizontalSync(wxCommandEvent &event);
41 void OnToggleVerticalSync(wxCommandEvent &event);
42 void OnSearch(wxCommandEvent &event);
43 void OnSearchCancel(wxCommandEvent &event);
44 void OnDiffNext(wxCommandEvent &event);
45 void OnDiffPrev(wxCommandEvent &event);
46
50 int CurrentScrollY(size_t idx) const;
54 void SyncScrollFrom(int src_idx, int y_new_src);
55
56 std::vector<Worksheet *> m_worksheets;
57 std::vector<std::unique_ptr<Configuration>> m_worksheetConfigurations;
58 Configuration *m_configuration;
59 wxSearchCtrl *m_searchCtrl = nullptr;
60 wxRadioButton *m_searchDownRadio = nullptr;
61 wxRadioButton *m_searchUpRadio = nullptr;
62 int m_currentDiffIdx = -1;
63 bool m_syncing = false;
64 bool m_syncHorizontal = true;
65 bool m_syncVertical = true;
66 bool m_searchDown = true;
67
68 void LoadFiles(const wxArrayString &files);
69 void AlignCells();
70
71 struct DiffEntry {
72 GroupCell *cells[3]; // 0, 1, 2
73 };
74 std::vector<DiffEntry> m_diffEntries;
75 std::vector<int> m_lastScrollY;
76
79 bool IsDiffEntry(const DiffEntry &e) const;
84 void UpdateDiffNavUI();
85 void OnIdle(wxIdleEvent &event);
89 int FindAdjacentDiff(int direction) const;
92 void SetCurrentDiff(int idx);
93
94 friend class DiffMarkerBar;
97 struct DiffMark { int docY; bool current; };
99 std::vector<DiffMark> DiffMarksForPane(size_t paneIdx) const;
102 void JumpToNearestDiff(size_t paneIdx, int docY);
104 std::vector<DiffMarkerBar *> m_markerBars;
107 int m_lastBarViewTop = -1;
108 int m_lastBarCurrent = -2;
114 std::vector<int> m_lastBarDocHeights;
115
116 wxToolBar *m_toolBar = nullptr;
118 wxStaticText *m_diffStatus = nullptr;
121 int m_shownPrevEnabled = -1;
122 int m_shownNextEnabled = -1;
123
129 wxTimer m_resizeTimer;
130 void RelayoutWorksheets();
135 int m_lastLayoutWidth = -1;
136};
137
138#endif // DIFFFRAME_H
This file defines the class Worksheet.
The configuration storage for the current worksheet.
Definition: Configuration.h:97
Definition: DiffFrame.h:33
Definition: DiffFrame.cpp:42
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:87