Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing imports and command outputs not showing up #7

Open
TaxMachine opened this issue May 31, 2024 · 0 comments
Open

missing imports and command outputs not showing up #7

TaxMachine opened this issue May 31, 2024 · 0 comments

Comments

@TaxMachine
Copy link

when I tried to include your project into mine, I couldn't compile it since you used std::shared_ptr without including the memory header (I have no idea if it's because you used C++17 and that I'm using C++23) so I just took the headers and put them into my project to fix them manually and after I got it working, when I enter commands, nothing appears and when I try to click any of the checkboxes (autoscroll and autowrap) or if I try to select any of the log level options, it doesn't do anything
I used the ImGui docking branch.

The main loop

ImTerm::terminal<Command> terminal_log;
    terminal_log.set_min_log_level(ImTerm::message::severity::info);
    terminal_log.set_flags(ImGuiWindowFlags_NoResize |
                           ImGuiWindowFlags_NoCollapse |
                           ImGuiWindowFlags_NoMove |
                           ImGuiWindowFlags_NoSavedSettings |
                           ImGuiWindowFlags_NoBringToFrontOnFocus |
                           ImGuiWindowFlags_NoNavFocus |
                           ImGuiWindowFlags_NoDocking |
                           ImGuiWindowFlags_NoSavedSettings);
    terminal_log.set_size(ImVec2((float)g_width, (float)g_height - 20));
    terminal_log.show();

the Command class

#include "../imterm/terminal.hpp"
#include "../imterm/terminal_helpers.hpp"

class Command : public ImTerm::basic_terminal_helper<Command, void> {
public:
    Command() {
        for (const command_type& cmd : local_command_list) {
            add_command_(cmd);
        }
    }

    static std::vector<std::string> no_completion(argument_type&) { return {}; }

    static void clear(argument_type&);
    static void echo(argument_type&);
    static void help(argument_type&);
    static void whoami(argument_type&);

private:
    constexpr static std::array<command_type, 5> local_command_list = {
            command_type{"clear", "Clear the terminal", &Command::clear, &Command::no_completion},
            command_type{"echo", "Echo the input", &Command::echo, &Command::no_completion},
            command_type{"help", "Display help", &Command::help, &Command::no_completion},
            command_type{"whoami", "Display the current user", &Command::whoami, &Command::no_completion}
    };
};

each commands are defined in a separate C++ file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant