mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
feat: Added goto line popup to text editors (#1984)
Since the popup is fairly small I opted for a straight addition parallel to the find/replace. To make code more clear the functions that create each popup were coalesced and made their interface simpler. That forced a reorganization of the data processing which translates to a larger number of changes than usual. Most of those changes are just moving some action from one function to another. The old method to identify popups using the size and position of the window was dropped in favor of one based on child windows and using their names for a much easier and robust identification. Added specialized functions to text editor to jump to a line or to given coordinates with a simple interface that simplifies older code that performed the same task. Because this PR modifies heavily the same code as the previous PR (1983) it is also included here to make merging easier. --------- Co-authored-by: Nik <werwolv98@gmail.com>
This commit is contained in:
@@ -73,8 +73,9 @@ namespace hex::plugin::builtin {
|
||||
return ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string preprocessText(const std::string &code);
|
||||
void setPopupWindowHeight(u32 height) { m_popupWindowHeight = height; }
|
||||
u32 getPopupWindowHeight() const { return m_popupWindowHeight; }
|
||||
|
||||
struct VirtualFile {
|
||||
std::fs::path path;
|
||||
@@ -282,12 +283,16 @@ namespace hex::plugin::builtin {
|
||||
bool m_parentHighlightingEnabled = true;
|
||||
bool m_replaceMode = false;
|
||||
bool m_openFindReplacePopUp = false;
|
||||
|
||||
bool m_openGotoLinePopUp = false;
|
||||
std::map<std::fs::path, std::string> m_patternNames;
|
||||
|
||||
ImRect m_textEditorHoverBox;
|
||||
ImRect m_consoleHoverBox;
|
||||
std::string m_focusedSubWindowName;
|
||||
float m_popupWindowHeight = 0;
|
||||
float m_popupWindowHeightChange = 0;
|
||||
bool m_frPopupIsClosed = true;
|
||||
bool m_gotoPopupIsClosed = true;
|
||||
|
||||
static inline std::array<std::string,256> m_findHistory;
|
||||
static inline u32 m_findHistorySize = 0;
|
||||
@@ -306,7 +311,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void drawPatternTooltip(pl::ptrn::Pattern *pattern);
|
||||
|
||||
void drawFindReplaceDialog(TextEditor *textEditor, std::string &findWord, bool &requestFocus, u64 &position, u64 &count, bool &updateCount, bool canReplace);
|
||||
void drawTextEditorFindReplacePopup(TextEditor *textEditor);
|
||||
void drawTextEditorGotoLinePopup(TextEditor *textEditor);
|
||||
|
||||
void historyInsert(std::array<std::string, 256> &history, u32 &size, u32 &index, const std::string &value);
|
||||
|
||||
@@ -317,6 +323,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
TextEditor *getEditorFromFocusedWindow();
|
||||
void setupFindReplace(TextEditor *editor);
|
||||
void setupGotoLine(TextEditor *editor);
|
||||
|
||||
void registerEvents();
|
||||
void registerMenuItems();
|
||||
|
||||
Reference in New Issue
Block a user