M1 step 5: IRC App

- Chat: header (Buffer n/N, unread elsewhere, topic or connection
  state), wrapped hh:mm <nick> lines (own in accent, Mentions green,
  info grey), input line; Tab cycles Buffers, Fn+Up/Down scrolls back,
  Enter sends, Back leaves while the IRC Service keeps running
- /settings: server form (host, port, TLS, self-signed pinning, nick,
  SASL, NickServ, auto-join); Save & reconnect restarts the session
- Opening the App starts the IRC Service; viewing a Buffer clears its
  unread count; IrcSession gains a revision counter for redraws

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-02 15:14:59 +02:00
co-authored by Claude Opus 5.5
parent 74a341418e
commit 076baa77d1
8 changed files with 397 additions and 3 deletions
+55
View File
@@ -0,0 +1,55 @@
#pragma once
#include <string>
#include "app.h"
#include "event_bus.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};
ListModel fields_{theme::kContent.h / theme::kLineHeight};
bool editing_ = false;
LineEditor fieldEditor_{63};
};
} // namespace roro