Files
roro9stack/src/apps/irc_app.h
T
twislaandClaude Opus 5.5 e2326e113b Launcher: a grid of icons, with badges; the list stays as a Setting
The Launcher shows the Apps as a 4 x 3 grid of 32 x 32 icons, the
selected one's name under it (issue #9). The icons are the website's
own, doubled, and two drawn the same way for SSH and the Shell; they
are PNGs in assets/icons, turned into arrays by scripts/make_icons.py,
which CI checks. The selected tile is the website's: dark blue on cyan,
with notched corners.

- GridModel (lib/ui, host-tested) holds the selection and the scrolling.
- App::badge(): a dot on the tile for unread IRC messages, a Track
  recording, a Capture running, an SSH session open.
- Settings > Launcher: Grid or List.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0162FokPdvY2KsS4NBfwyWPk
2026-10-09 23:14:37 +02:00

63 lines
2.0 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;
void help(std::vector<KeyHelp>& out) const override;
const char* helpTitle() const override;
bool badge() const override { return irc_.totalUnread() > 0; }
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