Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/toad/client/prompt_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
from __future__ import annotations

from abc import abstractmethod
from typing import ClassVar

from metaclass_registry import AbstractHooksMeta
from ui_theme.scheme import PromptToneColour, ThemeColour

from toad.client.input_decision import InputAccepted, InputDecision
from toad.setting_declarations import EachOpenWidget
Expand All @@ -36,6 +38,8 @@ class PromptComposer(metaclass=AbstractHooksMeta):
"""A conversation's composer: its submission owner, queue and leading glyph."""

submissions: object | None
# The surface the composer's area is painted on, a tier off the transcript above it.
area_tone: ClassVar[type[ThemeColour]] = PromptToneColour

@property
@abstractmethod
Expand Down
8 changes: 6 additions & 2 deletions src/toad/qt/composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ class Composer(PromptSettingEffects, PromptComposer, MentionEditor, SubmitsContr
def __init__(self, host: ComposerHost, renderer: QtLineRenderer, placeholder: str) -> None:
super().__init__()
self.host, self.renderer = host, renderer
# The composer's area is its own surface (`area_tone`), as Textual's prompt area is.
self.setObjectName("composer")
self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)
self.given_placeholder = placeholder
self.mention_candidates: tuple[MentionCandidate, ...] = ()
self.commands: list[SlashCommand] = []
Expand Down Expand Up @@ -398,8 +401,9 @@ def submissions(self) -> BusSubmissions:
return self.host.submissions

def paint_colours(self) -> None:
"""The muted placeholder, the offer list, the glyph and the frame's border, under the
renderer's current scheme."""
"""The area's tone, the muted placeholder, the offer list, the glyph and the frame's
border, under the renderer's current scheme."""
self.setStyleSheet(f"#composer {{ background: {self.renderer.theme(self.area_tone)} }}")
palette = self.editor.palette()
palette.setColor(QPalette.ColorRole.PlaceholderText, QColor(self.renderer.colour(MutedRole)))
self.editor.setPalette(palette)
Expand Down
5 changes: 3 additions & 2 deletions src/toad/widgets/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from textual.widgets import Label, OptionList, TextArea
from textual.widgets.option_list import Option, OptionListComponent
from textual.widgets.text_area import Selection, TextAreaComponent
from ui_theme.scheme import ErrorColour, MutedColour, PrimaryColour, PromptToneColour, SecondaryColour
from ui_theme.scheme import ErrorColour, MutedColour, PrimaryColour, SecondaryColour

from toad import messages
from toad.clipboard_image import PastesClipboard, read_clipboard, save_clipboard_png
Expand Down Expand Up @@ -715,7 +715,8 @@ class Prompt(NativeMethodKeys, HiddenActions, DismissibleControl, PromptSettingE
containers.VerticalGroup, ToadNode, PromptComposer, actions=(PromptFrameAction,)):
"""The Textual composer; `PromptComposer` owns its submissions, queue, glyph and draft
decisions, shared with Qt's `Composer`."""
tone = PromptToneColour
# `TonePaint` comes first in the bases, so its `tone` would hide the composer's own.
tone = PromptComposer.area_tone


TEXT_AREA_CLASS = PromptTextArea
Expand Down
11 changes: 11 additions & 0 deletions src/toad/widgets/session_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ForegroundColour,
HeaderToneColour,
MutedColour,
SelectedTabToneColour,
)

from toad.core import events as core_events
Expand All @@ -52,6 +53,16 @@ class SessionLabel(WidgetView, PrimaryActivation, ViewLabel, ChangingText, widge
def current(self) -> bool:
return self.mode_name == self.app.selected_mode

# TonePaint declares a class tone; the open tab is raised a tier off the bar, the rest sit on it.
@property
def tone(self): # type: ignore[override]
return SelectedTabToneColour if self.current else None

def paint_current(self) -> None:
"""The tab opened or closed: its tone is part of its cached paint."""
self.refresh_paint()
super().paint_current()

@property
def paint_text_style(self):
return RichStyle(dim=not self.mouse_hover)
Expand Down
Loading