wxMaxima
Loading...
Searching...
No Matches
RegexCtrl.h
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
22#ifndef REGEXCTRL_H
23#define REGEXCTRL_H
24
25#include "precomp.h"
26#include <wx/wx.h>
27#include <wx/regex.h>
28#include <wx/textctrl.h>
29#include "Configuration.h"
30#include "../BTextCtrl.h"
31
35class RegexCtrl : public BTextCtrl
36{
37 class wxLogBuffer_noStdErrFlush : public wxLogBuffer
38 {
39 public:
40 wxLogBuffer_noStdErrFlush(): wxLogBuffer() {};
41 virtual void Flush() override {}
42 ~wxLogBuffer_noStdErrFlush() override{};
43 };
44public:
45 RegexCtrl(wxWindow *parent,
46 wxWindowID id, Configuration *cfg, const wxString &configName);
47 bool Matches(wxString text);
48
49protected:
51 void OnTextChange(wxCommandEvent &ev);
53 void OnMouseRightDown(wxMouseEvent &event);
55 void OnMenu(wxCommandEvent &event);
57 void OnChange();
58
59 ~RegexCtrl();
60
61private:
63 bool m_isRegex = false;
65 wxString m_configName;
66 wxString m_oldRegex;
67 wxRegEx m_regex;
68 enum class RegexInputState : int8_t { empty, invalid, valid };
70 RegexInputState m_regexInputState = RegexInputState::empty;
71 RegexInputState GetNewRegexInputState() const;
73 static wxString RegexTooltip_error;
75 static wxString RegexTooltip_textsearch;
77 static wxString RegexTooltip_norm;
78};
79
80wxDECLARE_EVENT(REGEX_EVENT, wxCommandEvent);
81
82#endif // REGEXCTRL_H
A wxTextCtrl with parenthesis matching.
Definition: BTextCtrl.h:33
The configuration storage for the current worksheet.
Definition: Configuration.h:85
A BTextCtrl that allows to input a regex.
Definition: RegexCtrl.h:36
void OnMouseRightDown(wxMouseEvent &event)
Called, if the user releases the right mouse button.
Definition: RegexCtrl.cpp:134
void OnMenu(wxCommandEvent &event)
Called, if the user selects a menu item.
Definition: RegexCtrl.cpp:148
void OnChange()
Called, if the search text or method changes.
Definition: RegexCtrl.cpp:80
void OnTextChange(wxCommandEvent &ev)
Is called when the contents of the textbox changes.
Definition: RegexCtrl.cpp:76