1package soy.iko.opencode.ui.components
3import androidx.compose.runtime.compositionLocalOf
4import androidx.compose.material3.Typography
7 * Chat presentation preferences, threaded through the composition so the markdown and
8 * code renderers can honor them without every call site plumbing them explicitly.
10 * - [LocalChatTextScale]: a multiplier applied to chat/message/code font sizes.
11 * - [LocalCodeWrap]: whether code blocks soft-wrap long lines (vs. horizontal scroll).
13 * Provided once near the app root from the persisted [soy.iko.opencode.data.repo.SettingsStore]
14 * values. Defaults keep the design behavior when no provider is present (e.g. previews/tests).
16val LocalChatTextScale = compositionLocalOf { 1f }
17val LocalCodeWrap = compositionLocalOf { false }
20 * Return a copy of this [Typography] with every text role's font size and line height
21 * multiplied by [scale]. Used to scale a whole markdown subtree (headings, lists, code,
22 * body) from a single user preference. Returns the receiver unchanged when [scale] is 1.
24fun Typography.scaledBy(scale: Float): Typography {
25 if (scale == 1f) return this
26 fun androidx.compose.ui.text.TextStyle.scaled() = copy(
27 fontSize = if (fontSize.isSp) fontSize * scale else fontSize,
28 lineHeight = if (lineHeight.isSp) lineHeight * scale else lineHeight,
31 displayLarge = displayLarge.scaled(),
32 displayMedium = displayMedium.scaled(),
33 displaySmall = displaySmall.scaled(),
34 headlineLarge = headlineLarge.scaled(),
35 headlineMedium = headlineMedium.scaled(),
36 headlineSmall = headlineSmall.scaled(),
37 titleLarge = titleLarge.scaled(),
38 titleMedium = titleMedium.scaled(),
39 titleSmall = titleSmall.scaled(),
40 bodyLarge = bodyLarge.scaled(),
41 bodyMedium = bodyMedium.scaled(),
42 bodySmall = bodySmall.scaled(),
43 labelLarge = labelLarge.scaled(),
44 labelMedium = labelMedium.scaled(),
45 labelSmall = labelSmall.scaled(),
49/** True when this [androidx.compose.ui.unit.TextUnit] is expressed in sp (safe to scale). */
50private val androidx.compose.ui.unit.TextUnit.isSp: Boolean
51 get() = type == androidx.compose.ui.unit.TextUnitType.Sp
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list