Public Access
- Alt + ; / Alt + . scroll the Buffer back and forward - Up / Down (Fn + ; / Fn + .) browse the last 30 sent lines, shell-style, returning to the draft past the newest (InputHistory, host-tested) - /j is short for /join Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "app.h"
|
|
#include "event_bus.h"
|
|
#include "input_history.h"
|
|
#include "line_editor.h"
|
|
#include "list_model.h"
|
|
#include "services/irc_service.h"
|
|
#include "ui/theme.h"
|
|
|
|
namespace roro {
|
|
|
|
// IRC: one Buffer at a time with an input line; /settings opens the server form. Opening the App
|
|
// starts the IRC Service, which keeps running after the App is left.
|
|
class IrcApp : public App {
|
|
public:
|
|
IrcApp(IrcService& irc, ClockService& clock, EventBus& bus) : irc_(irc), clock_(clock), bus_(bus) {}
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
bool onKey(const KeyEvent& e) override;
|
|
void update(uint32_t nowMs) override;
|
|
bool textEntryActive() const override { return page_ == Page::Chat || editing_; }
|
|
void draw(Canvas& c) override;
|
|
|
|
private:
|
|
enum class Page { Chat, Settings };
|
|
enum Field { kHost, kPort, kTls, kSelfSigned, kNick, kSaslUser, kSaslPass, kNickserv, kAutojoin, kSave, kFields };
|
|
|
|
bool onChatKey(const KeyEvent& e);
|
|
bool onSettingsKey(const KeyEvent& e);
|
|
void view(int buffer);
|
|
void drawChat(Canvas& c);
|
|
void drawSettings(Canvas& c);
|
|
std::string fieldLabel(int f) const;
|
|
std::string fieldValue(int f) const;
|
|
void startEditing(int f);
|
|
void finishEditing();
|
|
void warn(const std::string& text);
|
|
|
|
IrcService& irc_;
|
|
ClockService& clock_;
|
|
EventBus& bus_;
|
|
Page page_ = Page::Chat;
|
|
int current_ = 0;
|
|
int scroll_ = 0; // wrapped lines scrolled back from the bottom
|
|
uint32_t seenRevision_ = 0;
|
|
IrcService::Status seenStatus_ = IrcService::Status::Stopped;
|
|
LineEditor input_{400};
|
|
InputHistory history_{30};
|
|
ListModel fields_{theme::kContent.h / theme::kLineHeight};
|
|
bool editing_ = false;
|
|
LineEditor fieldEditor_{63};
|
|
std::unique_ptr<IrcConfig> draft_; // the settings being edited, applied on Save
|
|
};
|
|
|
|
} // namespace roro
|