feat(options): command line text colour and a fonts folder

Display gets a command line text colour (blank keeps the theme's); it
covers history, prompts and the input, while errors stay red. Files
lists the fonts folder that text resolution searches, so .shx files can
be added by hand; opening it creates it first.

Discussions #1493, #1372

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-07 08:50:12 +03:00
1 parent 1c37c90c75
commit 7a8ec02003
29 files changed
+144 -15

No files matched your search

+1
View File
@@ -2341,6 +2341,7 @@ common =
.load-linetypes = تحميل أنواع الخطوط
.requires-two-positive-values = يتطلب قيمتين موجبتين (x,y) أو قيمة واحدة لكليهما.
.snap-marker-color = لون علامة الالتقاط
.command-line-text-color = لون نص سطر الأوامر
.linetypes-loaded = تم تحميل __ocs_fmt_0__ من أنواع الخطوط.
.geometric-center-snap = المركز الهندسي
.no-trim-option = بدون تشذيب
+1
View File
@@ -2328,6 +2328,7 @@ common =
.load-linetypes = Зареждане на типове линии
.requires-two-positive-values = Изискват се две положителни стойности (x,y) или една за двете.
.snap-marker-color = Цвят на маркера за прихващане
.command-line-text-color = Цвят на текста в командния ред
.linetypes-loaded = Заредени типове линии: __ocs_fmt_0__.
.geometric-center-snap = Геометричен център
.no-trim-option = Без подрязване
+1
View File
@@ -2328,6 +2328,7 @@ common =
.load-linetypes = Načíst typy čar
.requires-two-positive-values = Vyžaduje dvě kladné hodnoty (x,y) nebo jednu pro obě.
.snap-marker-color = Barva značky uchopení
.command-line-text-color = Barva textu příkazového řádku
.linetypes-loaded = Načteno typů čar: __ocs_fmt_0__.
.geometric-center-snap = Geometrický střed
.no-trim-option = Neoříznout
+1
View File
@@ -2329,6 +2329,7 @@ common =
.load-linetypes = Linientypen laden
.requires-two-positive-values = Erfordert zwei positive Werte (x,y) oder einen für beide.
.snap-marker-color = Farbe der Fangmarkierung
.command-line-text-color = Textfarbe der Befehlszeile
.linetypes-loaded = __ocs_fmt_0__ Linientyp(en) geladen.
.geometric-center-snap = Geometrischer Mittelpunkt
.no-trim-option = Nicht stutzen
+1
View File
@@ -2328,6 +2328,7 @@ common =
.load-linetypes = Φόρτωση τύπων γραμμής
.requires-two-positive-values = Απαιτούνται δύο θετικές τιμές (x,y) ή μία και για τις δύο.
.snap-marker-color = Χρώμα δείκτη έλξης
.command-line-text-color = Χρώμα κειμένου γραμμής εντολών
.linetypes-loaded = Φορτώθηκαν __ocs_fmt_0__ τύποι γραμμής.
.geometric-center-snap = Γεωμετρικό κέντρο
.no-trim-option = Χωρίς περικοπή
+1
View File
@@ -2329,6 +2329,7 @@ common =
.load-linetypes = Load Linetypes
.requires-two-positive-values = Requires two positive values (x,y) or one for both.
.snap-marker-color = Snap marker color
.command-line-text-color = Command line text color
.linetypes-loaded = __ocs_fmt_0__ linetype(s) loaded.
.geometric-center-snap = Geometric Center
.no-trim-option = No trim
+1
View File
@@ -2329,6 +2329,7 @@ common =
.load-linetypes = Cargar tipos de línea
.requires-two-positive-values = Requiere dos valores positivos (x,y) o uno para ambos.
.snap-marker-color = Color del marcador de referencia
.command-line-text-color = Color del texto de la línea de comandos
.linetypes-loaded = __ocs_fmt_0__ tipo(s) de línea cargado(s).
.geometric-center-snap = Centro geométrico
.no-trim-option = No recortar
+1
View File
@@ -2328,6 +2328,7 @@ common =
.load-linetypes = Lataa viivatyypit
.requires-two-positive-values = Vaatii kaksi positiivista arvoa (x,y) tai yhden molemmille.
.snap-marker-color = Kohdistusmerkin väri
.command-line-text-color = Komentorivin tekstin väri
.linetypes-loaded = Ladattu __ocs_fmt_0__ viivatyyppiä.
.geometric-center-snap = Geometrinen keskipiste
.no-trim-option = Ei trimmausta
+1
View File
@@ -2329,6 +2329,7 @@ common =
.load-linetypes = Charger des types de ligne
.requires-two-positive-values = Nécessite deux valeurs positives (x,y) ou une seule pour les deux.
.snap-marker-color = Couleur du marqueur d'accrochage
.command-line-text-color = Couleur du texte de la ligne de commande
.linetypes-loaded = __ocs_fmt_0__ type(s) de ligne chargé(s).
.geometric-center-snap = Centre géométrique
.no-trim-option = Sans ajuster
+1
View File
@@ -2317,6 +2317,7 @@ common =
.load-linetypes = लाइनटाइप लोड करें
.requires-two-positive-values = दो धनात्मक मान (x,y) या दोनों के लिए एक मान आवश्यक है।
.snap-marker-color = स्नैप मार्कर का रंग
.command-line-text-color = कमांड लाइन टेक्स्ट रंग
.linetypes-loaded = __ocs_fmt_0__ लाइनटाइप लोड हुए।
.geometric-center-snap = ज्यामितीय केंद्र
.no-trim-option = ट्रिम नहीं
+1
View File
@@ -2328,6 +2328,7 @@ common =
.load-linetypes = Vonaltípusok betöltése
.requires-two-positive-values = Két pozitív érték (x,y) vagy egy közös érték szükséges.
.snap-marker-color = Illesztési jelölő színe
.command-line-text-color = Parancssor szövegszíne
.linetypes-loaded = __ocs_fmt_0__ vonaltípus betöltve.
.geometric-center-snap = Geometriai középpont
.no-trim-option = Nincs vágás
+1
View File
@@ -2328,6 +2328,7 @@ common =
.load-linetypes = Carica tipi di linea
.requires-two-positive-values = Richiede due valori positivi (x,y) o uno per entrambi.
.snap-marker-color = Colore del marcatore di snap
.command-line-text-color = Colore del testo della riga di comando
.linetypes-loaded = __ocs_fmt_0__ tipo/i di linea caricato/i.
.geometric-center-snap = Centro geometrico
.no-trim-option = Non tagliare
+1
View File
@@ -2319,6 +2319,7 @@ common =
.load-linetypes = 線種をロード
.requires-two-positive-values = 2つの正の値 (x,y)、または両方に共通の1つの値が必要です。
.snap-marker-color = スナップ マーカーの色
.command-line-text-color = コマンドラインの文字色
.linetypes-loaded = __ocs_fmt_0__ 個の線種をロードしました。
.geometric-center-snap = 図心
.no-trim-option = トリムしない
+1
View File
@@ -2328,6 +2328,7 @@ common =
.load-linetypes = 선종류 로드
.requires-two-positive-values = 양수 값 두 개(x,y) 또는 둘 다에 쓸 값 하나가 필요합니다.
.snap-marker-color = 스냅 마커 색상
.command-line-text-color = 명령줄 텍스트 색상
.linetypes-loaded = 선종류 __ocs_fmt_0__개를 로드했습니다.
.geometric-center-snap = 기하학적 중심
.no-trim-option = 자르지 않기
+1
View File
@@ -2329,6 +2329,7 @@ common =
.load-linetypes = Lijntypen laden
.requires-two-positive-values = Vereist twee positieve waarden (x,y) of één voor beide.
.snap-marker-color = Kleur van snapmarkering
.command-line-text-color = Tekstkleur opdrachtregel
.linetypes-loaded = __ocs_fmt_0__ lijntype(n) geladen.
.geometric-center-snap = Geometrisch middelpunt
.no-trim-option = Niet trimmen
+1
View File
@@ -2328,6 +2328,7 @@ common =
.load-linetypes = Wczytaj rodzaje linii
.requires-two-positive-values = Wymaga dwóch wartości dodatnich (x,y) lub jednej dla obu.
.snap-marker-color = Kolor znacznika przyciągania
.command-line-text-color = Kolor tekstu wiersza poleceń
.linetypes-loaded = Wczytano rodzaje linii: __ocs_fmt_0__.
.geometric-center-snap = Środek geometryczny
.no-trim-option = Bez przycinania
+1
View File
@@ -2329,6 +2329,7 @@ common =
.load-linetypes = Carregar tipos de linha
.requires-two-positive-values = Requer dois valores positivos (x,y) ou um para ambos.
.snap-marker-color = Cor do marcador de snap
.command-line-text-color = Cor do texto da linha de comando
.linetypes-loaded = __ocs_fmt_0__ tipo(s) de linha carregado(s).
.geometric-center-snap = Centro geométrico
.no-trim-option = Não aparar
+1
View File
@@ -2332,6 +2332,7 @@ common =
.load-linetypes = Загрузить типы линий
.requires-two-positive-values = Требуются два положительных значения (x,y) или одно для обоих.
.snap-marker-color = Цвет маркера привязки
.command-line-text-color = Цвет текста командной строки
.linetypes-loaded = Загружено типов линий: __ocs_fmt_0__.
.geometric-center-snap = Геометрический центр
.no-trim-option = Без обрезки
+1
View File
@@ -2313,6 +2313,7 @@ common =
.load-linetypes = Çizgi tiplerini yükle
.requires-two-positive-values = İki pozitif değer (x,y) ya da ikisi için tek değer gerekir.
.snap-marker-color = Yakalama işaretçisi rengi
.command-line-text-color = Komut satırı metin rengi
.linetypes-loaded = __ocs_fmt_0__ çizgi tipi yüklendi.
.geometric-center-snap = Geometrik merkez
.no-trim-option = Budama yok
+1
View File
@@ -2316,6 +2316,7 @@ common =
.load-linetypes = 加载线型
.requires-two-positive-values = 需要两个正值 (x,y),或一个同时用于两者的值。
.snap-marker-color = 捕捉标记颜色
.command-line-text-color = 命令行文字颜色
.linetypes-loaded = 已加载 __ocs_fmt_0__ 个线型。
.geometric-center-snap = 几何中心
.no-trim-option = 不修剪
+1
View File
@@ -2328,6 +2328,7 @@ common =
.load-linetypes = 載入線型
.requires-two-positive-values = 需要兩個正值 (x,y),或一個同時用於兩者的值。
.snap-marker-color = 鎖點標記顏色
.command-line-text-color = 命令列文字顏色
.linetypes-loaded = 已載入 __ocs_fmt_0__ 個線型。
.geometric-center-snap = 幾何中心
.no-trim-option = 不修剪
+7
View File
@@ -592,6 +592,10 @@ pub(super) struct OpenCADStudio {
crosshair_color_input: String,
/// Explicit object-snap marker colour; `None` keeps the automatic one.
snap_marker_color: Option<[u8; 3]>,
/// Explicit command-line text colour; `None` keeps the theme's.
command_text_color: Option<[u8; 3]>,
/// Editable Options buffer for the command-line text colour.
command_text_color_input: String,
/// Editable Options buffer for the snap marker colour.
snap_marker_color_input: String,
/// Defer the ISOLINES mesh rebuild until the slider is released.
@@ -2296,6 +2300,7 @@ pub enum Message {
/// Edit the optional crosshair RGB value; blank restores automatic contrast.
CrosshairColorChanged(String),
SnapMarkerColorChanged(String),
CommandTextColorChanged(String),
/// Options → Files: the default template for new drawings.
QnewTemplateChanged(String),
QnewTemplateBrowse,
@@ -4167,6 +4172,8 @@ impl OpenCADStudio {
crosshair_color_input: String::new(),
snap_marker_color: None,
snap_marker_color_input: String::new(),
command_text_color: None,
command_text_color_input: String::new(),
isolines_awaiting_regen: false,
snap_angle_input: "0".to_string(),
lineweight_display_scale: 100,
+3
View File
@@ -432,6 +432,8 @@ pub struct UserSettings {
pub crosshair_color: Option<[u8; 3]>,
/// Explicit object-snap marker RGB. `None` keeps the automatic colour.
pub snap_marker_color: Option<[u8; 3]>,
/// Explicit command-line text RGB. `None` keeps the theme's.
pub command_text_color: Option<[u8; 3]>,
/// Model-space lineweight preview scale as a percentage.
pub lineweight_display_scale: i32,
/// Isometric drafting changes the grid and crosshair to the active axis
@@ -825,6 +827,7 @@ impl Default for UserSettings {
cursor_type: CursorType::Crosshair,
crosshair_color: None,
snap_marker_color: None,
command_text_color: None,
lineweight_display_scale: 100,
isometric_drafting: false,
iso_plane: IsoPlane::Left,
+7
View File
@@ -682,6 +682,7 @@ impl OpenCADStudio {
cursor_type: self.cursor_type,
crosshair_color: self.crosshair_color,
snap_marker_color: self.snap_marker_color,
command_text_color: self.command_text_color,
lineweight_display_scale: self.lineweight_display_scale,
isometric_drafting: self.isometric_drafting,
iso_plane: self.iso_plane,
@@ -798,6 +799,12 @@ impl OpenCADStudio {
.snap_marker_color
.map(crate::app::config::rgb_to_hex)
.unwrap_or_default();
self.command_text_color = s.command_text_color;
self.command_text_color_input = s
.command_text_color
.map(crate::app::config::rgb_to_hex)
.unwrap_or_default();
crate::ui::command_line::set_text_color(s.command_text_color);
self.lineweight_display_scale = s.lineweight_display_scale.clamp(25, 200);
self.isometric_drafting = s.isometric_drafting;
self.iso_plane = s.iso_plane;
+19 -1
View File
@@ -8060,6 +8060,20 @@ impl OpenCADStudio {
None => Message::Noop,
},
),
Message::CommandTextColorChanged(value) => {
self.command_text_color_input = value.clone();
let color = if value.trim().is_empty() {
None
} else if let Some(rgb) = crate::app::config::parse_hex(&value) {
Some(rgb)
} else {
return Task::none();
};
self.command_text_color = color;
crate::ui::command_line::set_text_color(color);
self.persist_settings_if_changed();
Task::none()
}
Message::SnapMarkerColorChanged(value) => {
self.snap_marker_color_input = value.clone();
if value.trim().is_empty() {
@@ -8532,7 +8546,11 @@ impl OpenCADStudio {
Task::none()
}
Message::OpenFolder(path) => crate::sys::open_url(&path, None),
Message::OpenFolder(path) => {
// The fonts folder exists only once something is put in it.
let _ = std::fs::create_dir_all(&path);
crate::sys::open_url(&path, None)
}
Message::PickDragRectToggled(rectangle) => {
self.pick_drag_rect = rectangle;
+4
View File
@@ -376,6 +376,8 @@ impl OpenCADStudio {
.map(|p| p.display().to_string()),
autosave: crate::config::config_dir()
.map(|_| std::env::temp_dir().display().to_string()),
fonts: crate::io::font_repo::fonts_dir()
.map(|p| p.display().to_string()),
}
}
#[cfg(target_arch = "wasm32")]
@@ -391,6 +393,8 @@ impl OpenCADStudio {
&self.crosshair_color_input,
self.snap_marker_color,
&self.snap_marker_color_input,
self.command_text_color,
&self.command_text_color_input,
self.lineweight_display_scale,
&self.model_space,
&self.model_bg_input,
+1
View File
@@ -4894,6 +4894,7 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
"Load Linetypes" => Some(("common", "load-linetypes")),
"Requires two positive values (x,y) or one for both." => Some(("common", "requires-two-positive-values")),
"Snap marker color" => Some(("common", "snap-marker-color")),
"Command line text color" => Some(("common", "command-line-text-color")),
"{added} linetype(s) loaded." => Some(("common", "linetypes-loaded")),
"Geometric Center" => Some(("common", "geometric-center-snap")),
"No trim" => Some(("common", "no-trim-option")),
+45 -14
View File
@@ -801,12 +801,18 @@ impl CommandLine {
.on_input(Message::CommandInput)
.on_submit(Message::CommandSubmit);
}
let input = input.size(11).padding(Padding {
top: 4.0,
right: 30.0,
bottom: 4.0,
left: 6.0,
});
let input = input
.size(11)
.padding(Padding {
top: 4.0,
right: 30.0,
bottom: 4.0,
left: 6.0,
})
.style(|theme: &Theme, status| text_input::Style {
value: text_color(theme),
..text_input::default(theme, status)
});
// Autocomplete suggestions panel, shown above the input row
// when the user has typed a prefix that matches at least one
// command. Each row is a button — clicking it dispatches the
@@ -1159,18 +1165,43 @@ fn header_btn_style(theme: &Theme, status: button::Status) -> button::Style {
}
}
/// The user's command-line text colour, packed `0x01RRGGBB`; 0 keeps the
/// theme's. Global because the history highlighter takes a plain `fn`.
static TEXT_COLOR: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
pub fn set_text_color(rgb: Option<[u8; 3]>) {
let packed = rgb.map_or(0, |[r, g, b]| 1 << 24 | u32::from_be_bytes([0, r, g, b]));
TEXT_COLOR.store(packed, std::sync::atomic::Ordering::Relaxed);
}
fn user_text_color() -> Option<Color> {
match TEXT_COLOR.load(std::sync::atomic::Ordering::Relaxed) {
0 => None,
packed => {
let [_, r, g, b] = packed.to_be_bytes();
Some(Color::from_rgb8(r, g, b))
}
}
}
fn text_color(theme: &Theme) -> Color {
user_text_color().unwrap_or(theme.palette().background.base.text)
}
fn history_color(theme: &Theme, kind: &EntryKind) -> Color {
let palette = theme.palette();
match kind {
EntryKind::Command => palette.background.base.text,
EntryKind::Output => palette.background.base.text.scale_alpha(0.72),
EntryKind::Command => text_color(theme),
EntryKind::Output => text_color(theme).scale_alpha(0.72),
EntryKind::Error => palette.danger.base.color,
EntryKind::Info => accessible_accent_threshold(
palette.primary.base.color,
palette.background.base.color,
palette.background.base.text,
4.5,
),
EntryKind::Info => user_text_color().unwrap_or_else(|| {
accessible_accent_threshold(
palette.primary.base.color,
palette.background.base.color,
palette.background.base.text,
4.5,
)
}),
}
}
+37
View File
@@ -97,6 +97,9 @@ pub struct Folders {
pub plot_styles: Option<String>,
pub plugins: Option<String>,
pub autosave: Option<String>,
/// Where `.shx` / `.ttf` fonts dropped in by the user (or downloaded for
/// a drawing) are found.
pub fonts: Option<String>,
}
/// Values read from the current drawing's header rather than from preferences.
@@ -217,6 +220,8 @@ pub fn view_window<'a>(
crosshair_color_input: &'a str,
snap_marker_color: Option<[u8; 3]>,
snap_marker_color_input: &'a str,
command_text_color: Option<[u8; 3]>,
command_text_color_input: &'a str,
lineweight_display_scale: i32,
model_space: &'a crate::app::config::ModelSpaceThemeConfig,
model_bg_input: &'a str,
@@ -526,6 +531,24 @@ pub fn view_window<'a>(
..Default::default()
});
let command_rgb = command_text_color.unwrap_or([220, 220, 220]);
let command_swatch = container(Space::new())
.width(28)
.height(22)
.style(move |theme: &Theme| container::Style {
background: Some(Background::Color(iced::Color::from_rgb8(
command_rgb[0],
command_rgb[1],
command_rgb[2],
))),
border: Border {
color: theme.palette().background.strong.color,
width: 1.0,
radius: 3.0.into(),
},
..Default::default()
});
let snap_rgb = snap_marker_color.unwrap_or([255, 230, 26]);
let snap_swatch = container(Space::new())
.width(28)
@@ -803,6 +826,18 @@ pub fn view_window<'a>(
.spacing(10)
.align_y(iced::Center),
)
.push(Space::new().height(10))
.push(
row![
text(crate::t!("Command line text color")).size(12).width(140),
command_swatch,
text_input(crate::t!("#RRGGBB or blank").as_ref(), command_text_color_input)
.on_input(Message::CommandTextColorChanged)
.width(150),
]
.spacing(10)
.align_y(iced::Center),
)
.push(Space::new().height(6))
.push(
text(crate::t!("Leave the color blank to keep automatic viewport contrast."))
@@ -1700,6 +1735,8 @@ pub fn view_window<'a>(
folder_row(crate::t!("Plugins"), folders.plugins.clone()),
Space::new().height(12),
folder_row(crate::t!("Autosave files"), folders.autosave.clone()),
Space::new().height(12),
folder_row(crate::t!("Fonts"), folders.fonts.clone()),
Space::new().height(16),
text(crate::t!("Default template for new drawings")).size(12),
Space::new().height(4),