rigCodeEditor 0.1.0
RigKit pack API - rigCodeEditor
Loading...
Searching...
No Matches
rigkit::TextEditorPanel Class Reference

Full code-editor chrome (menu, find/replace, open-file tabs). More...

#include <rigCodeEditor/src/TextEditorPanel.h>

Classes

struct  SidebarEntry
 One host-supplied source tab - a file or a live buffer. More...

Public Member Functions

void setDialogCallbacks (std::function< void(const std::string &title, std::vector< std::string > filters, ConfirmPath onConfirm)> openFile, std::function< void(const std::string &title, std::vector< std::string > filters, ConfirmPath onConfirm)> saveFile)
 Host open/save (IMui FileDialogs - extension filters like ".py", ".*").
void drawContents ()
 Menu bar + tabs + editor + status - call inside an open ImGui window.
bool selectSidebarEntryById (const std::string &id)
 Activate the host tab whose id matches (no-op if missing).
std::string selectedSidebarId () const
 Id of the host tab currently shown.
void setOpenFilesSidebarEnabled (bool enabled)
 Show disk-opened buffers as closable tabs (default on).
void setShowTabBar (bool enabled)
 Draw the tab strip.
void setFileActions (std::function< void()> onNew, std::function< void(const std::string &)> onOpen, std::function< void()> onClose)
 Hand New / Open / Close to the host.
void setStatusNote (std::function< StatusNote(const std::string &text, const char *language)> fn)
 Extra status-bar text for the buffer on screen.
void openPath (const std::string &path)
 Open a disk path as its own tab.
void loadPath (const std::string &path)
 Load path into this panel.
void setOpenResourceMenuDraw (std::function< void()> cb)
 Optional File to Open to Resource menu body (drawn live each frame).
void setFont (ImFont *font)
 Monospace editor font (JetBrains Mono).

Static Public Attributes

static constexpr std::size_t kMaxLoadBytes = 2 * 1024 * 1024
 Refuse loads larger than this (TextEditor builds one glyph per character).

Detailed Description

Full code-editor chrome (menu, find/replace, open-file tabs).

Draw into an existing ImGui window begun with ImGuiWindowFlags_MenuBar. Host buffers and disk opens appear as Sublime-style tabs above the editor.

Member Function Documentation

◆ loadPath()

void rigkit::TextEditorPanel::loadPath ( const std::string & path)

Load path into this panel.

Does not call the Open file action.

◆ openPath()

void rigkit::TextEditorPanel::openPath ( const std::string & path)

Open a disk path as its own tab.

Reloads when that path is already open. Directories are refused. Does not create a CCode entity.

◆ selectedSidebarId()

std::string rigkit::TextEditorPanel::selectedSidebarId ( ) const

Id of the host tab currently shown.

Returns
The entry id (or its label when it has no id). Empty when a disk-opened file is active or no host tab is selected - hosts that mirror the editor selection (a live preview, say) should leave their own selection alone while this is empty.

◆ selectSidebarEntryById()

bool rigkit::TextEditorPanel::selectSidebarEntryById ( const std::string & id)

Activate the host tab whose id matches (no-op if missing).

Re-selecting the tab already shown reloads it from its backing buffer, so a host that just swapped the buffer text (and bumped revision) can call this to make the editor follow.

◆ setFileActions()

void rigkit::TextEditorPanel::setFileActions ( std::function< void()> onNew,
std::function< void(const std::string &)> onOpen,
std::function< void()> onClose )
inline

Hand New / Open / Close to the host.

Set when each file is its own window. Empty callbacks keep the in-panel tab behavior. Invoked from the menu and shortcuts; the host should defer window creation until after the current ImGui frame.

◆ setOpenResourceMenuDraw()

void rigkit::TextEditorPanel::setOpenResourceMenuDraw ( std::function< void()> cb)
inline

Optional File to Open to Resource menu body (drawn live each frame).

When set, File to Open becomes a submenu: File... + Resource to ....

◆ setShowTabBar()

void rigkit::TextEditorPanel::setShowTabBar ( bool enabled)
inline

Draw the tab strip.

Off when this window is a single file.

◆ setStatusNote()

void rigkit::TextEditorPanel::setStatusNote ( std::function< StatusNote(const std::string &text, const char *language)> fn)
inline

Extra status-bar text for the buffer on screen.

Called when the undo index or language changes, with the full buffer text. Empty label draws nothing. Not called every frame.


The documentation for this class was generated from the following file: