Skip to content

Commit 2c6c5f3

Browse files
gilhooleydCQ Bot
authored andcommitted
[virtcon] Add and display ascii logo
It is difficult to see if the display is on when virtcon is showing an empty shell. Add a logo for fun. The existing terminal and logs are still available by hitting ctl-tab. Change-Id: I5b8dc804f8190337cda7b086060b4c13b295d7c2 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1195478 Reviewed-by: Aaron Wood <[email protected]> Reviewed-by: Craig Stout <[email protected]> Reviewed-by: Alice Neels <[email protected]> Commit-Queue: David Gilhooley <[email protected]>
1 parent 4913f36 commit 2c6c5f3

File tree

9 files changed

+146
-4
lines changed

9 files changed

+146
-4
lines changed

src/bringup/bin/virtcon/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ rustc_library("lib") {
7676
"src/colors.rs",
7777
"src/lib.rs",
7878
"src/log.rs",
79+
"src/logo.rs",
7980
"src/session_manager.rs",
8081
"src/terminal.rs",
8182
"src/text_grid.rs",

src/bringup/bin/virtcon/meta/virtual-console.cml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@
7171
max_size: 10,
7272
default: "16.0",
7373
},
74+
{
75+
config: "fuchsia.virtcon.ShowLogo",
76+
key: "show_logo",
77+
availability: "optional",
78+
type: "bool",
79+
default: false,
80+
},
7481
{
7582
config: "fuchsia.virtcon.KeepLogVisible",
7683
key: "keep_log_visible",

src/bringup/bin/virtcon/meta/virtual-console.shard.cml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"fuchsia.virtcon.KeyRepeat",
2424
"fuchsia.virtcon.RoundedCorners",
2525
"fuchsia.virtcon.ScrollbackRows",
26+
"fuchsia.virtcon.ShowLogo",
2627
],
2728
from: "parent",
2829
to: "#virtual_console",

src/bringup/bin/virtcon/src/app.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use crate::args::VirtualConsoleArgs;
66
use crate::colors::ColorScheme;
77
use crate::log::{Log, LogClient};
8+
use crate::logo::Logo;
89
use crate::session_manager::{SessionManager, SessionManagerClient};
910
use crate::terminal::Terminal;
1011
use crate::view::{ViewMessages, VirtualConsoleViewAssistant};
@@ -20,7 +21,8 @@ use std::collections::BTreeMap;
2021
use term_model::event::{Event, EventListener};
2122

2223
const DEBUGLOG_ID: u32 = 0;
23-
const FIRST_SESSION_ID: u32 = 1;
24+
const LOGO_ID: u32 = 1;
25+
const FIRST_SESSION_ID: u32 = 2;
2426

2527
pub struct EventProxy {
2628
app_sender: AppSender,
@@ -90,7 +92,7 @@ impl LogClient for VirtualConsoleClient {
9092
type Listener = EventProxy;
9193

9294
fn create_terminal(&self, id: u32, title: String) -> Result<Terminal<Self::Listener>, Error> {
93-
VirtualConsoleClient::create_terminal(self, id, title, false, None)
95+
VirtualConsoleClient::create_terminal(self, id, title, true, None)
9496
}
9597

9698
fn request_update(&self, id: u32) {
@@ -132,7 +134,8 @@ impl VirtualConsoleAppAssistant {
132134
read_only_debuglog: Option<zx::DebugLog>,
133135
) -> Result<VirtualConsoleAppAssistant, Error> {
134136
let app_sender = app_sender.clone();
135-
let session_manager = SessionManager::new(args.keep_log_visible, FIRST_SESSION_ID);
137+
let session_manager =
138+
SessionManager::new(args.keep_log_visible || args.show_logo, FIRST_SESSION_ID);
136139
let terminals = BTreeMap::new();
137140

138141
Ok(VirtualConsoleAppAssistant {
@@ -153,6 +156,14 @@ impl VirtualConsoleAppAssistant {
153156
Log::start(read_only_debuglog, &client, DEBUGLOG_ID)
154157
}
155158

159+
fn start_logo(&self) {
160+
let app_sender = self.app_sender.clone();
161+
let color_scheme = self.args.color_scheme;
162+
let scrollback_rows = self.args.scrollback_rows;
163+
let client = VirtualConsoleClient { app_sender, color_scheme, scrollback_rows };
164+
Logo::start(&client, LOGO_ID).unwrap();
165+
}
166+
156167
#[cfg(test)]
157168
fn new_for_test() -> Result<VirtualConsoleAppAssistant, Error> {
158169
let app_sender = AppSender::new_for_testing_purposes_only();
@@ -165,6 +176,10 @@ impl AppAssistant for VirtualConsoleAppAssistant {
165176
if let Some(read_only_debuglog) = self.read_only_debuglog.take() {
166177
self.start_log(read_only_debuglog).expect("failed to start debuglog");
167178
}
179+
if self.args.show_logo {
180+
self.start_logo();
181+
}
182+
168183
Ok(())
169184
}
170185

src/bringup/bin/virtcon/src/args.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub const MAX_FONT_SIZE: f32 = 160.0;
1616
pub struct VirtualConsoleArgs {
1717
pub disable: bool,
1818
pub keep_log_visible: bool,
19+
pub show_logo: bool,
1920
pub keyrepeat: bool,
2021
pub rounded_corners: bool,
2122
pub boot_animation: bool,
@@ -43,6 +44,7 @@ impl TryFrom<Config> for VirtualConsoleArgs {
4344
Ok(VirtualConsoleArgs {
4445
disable: config.disable,
4546
keep_log_visible: config.keep_log_visible,
47+
show_logo: config.show_logo,
4648
keyrepeat: config.keyrepeat,
4749
rounded_corners: config.rounded_corners,
4850
boot_animation: config.boot_animation,
@@ -73,6 +75,7 @@ mod tests {
7375
dpi: vec![],
7476
font_size: "16.0".into(),
7577
keep_log_visible: false,
78+
show_logo: false,
7679
keyrepeat: false,
7780
key_map: "qwerty".into(),
7881
rounded_corners: false,
@@ -106,6 +109,19 @@ mod tests {
106109
Ok(())
107110
}
108111

112+
#[test]
113+
fn check_show_logo() -> Result<(), Error> {
114+
let config = Config { show_logo: true, ..new_config() };
115+
let args = VirtualConsoleArgs::try_from(config)?;
116+
assert_eq!(args.show_logo, true);
117+
118+
let config = Config { show_logo: false, ..new_config() };
119+
let args = VirtualConsoleArgs::try_from(config)?;
120+
assert_eq!(args.show_logo, false);
121+
122+
Ok(())
123+
}
124+
109125
#[test]
110126
fn check_keyrepeat() -> Result<(), Error> {
111127
let config = Config { keyrepeat: true, ..new_config() };

src/bringup/bin/virtcon/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod app;
88
mod args;
99
mod colors;
1010
mod log;
11+
mod logo;
1112
mod session_manager;
1213
mod terminal;
1314
mod text_grid;

src/bringup/bin/virtcon/src/logo.rs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Copyright 2025 The Fuchsia Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
use crate::log::LogClient;
6+
use anyhow::Error;
7+
use std::io::sink;
8+
use term_model::ansi::Processor;
9+
use term_model::event::EventListener;
10+
11+
const LOGO_TEXT: &str = "
12+
\r
13+
ff ff ff\r
14+
ff fffffffffff ff\r
15+
f ffffffffffffffff f\r
16+
ff ffffffffffffffffffff\r
17+
f fffffffff ffff\r
18+
f ffffffff ff\r
19+
f fffffff f\r
20+
ff fffffff\r
21+
f ffffff\r
22+
fffffffff f\r
23+
fffffff fff\r
24+
ffffffffffffffffffffffff ffffff\r
25+
ffffffffffffffffffffffffffffffffff\r
26+
ffffff fffffff ffffff\r
27+
fffff fff ffffffffff\r
28+
fffff ff fffffff f\r
29+
ffff fff fffffff ff\r
30+
fffff ff ffffffff f\r
31+
ffff fff ffffffff f\r
32+
ffff ffffffffffffffffff f\r
33+
ffff fffffffffffffff f\r
34+
fffff ffffffffff ff\r
35+
fffff fff\r
36+
fffffffffffff\r
37+
";
38+
39+
pub struct Logo;
40+
impl Logo {
41+
pub fn start<T: LogClient>(client: &T, id: u32) -> Result<(), Error>
42+
where
43+
<T as LogClient>::Listener: EventListener,
44+
{
45+
let client = client.clone();
46+
let terminal =
47+
client.create_terminal(id, "logo".to_string()).expect("failed to create terminal");
48+
let term = terminal.clone_term();
49+
50+
let mut sink = sink();
51+
let mut parser = Processor::new();
52+
{
53+
let mut term = term.borrow_mut();
54+
for byte in LOGO_TEXT.as_bytes() {
55+
parser.advance(&mut *term, *byte, &mut sink);
56+
}
57+
client.request_update(id);
58+
}
59+
Ok(())
60+
}
61+
}
62+
63+
#[cfg(test)]
64+
mod tests {
65+
use super::*;
66+
use crate::colors::ColorScheme;
67+
use crate::terminal::Terminal;
68+
use fuchsia_async as fasync;
69+
use term_model::event::Event;
70+
71+
#[derive(Default)]
72+
struct TestListener;
73+
74+
impl EventListener for TestListener {
75+
fn send_event(&self, _event: Event) {}
76+
}
77+
78+
#[derive(Default, Clone)]
79+
struct TestLogClient;
80+
81+
impl LogClient for TestLogClient {
82+
type Listener = TestListener;
83+
84+
fn create_terminal(
85+
&self,
86+
_id: u32,
87+
title: String,
88+
) -> Result<Terminal<Self::Listener>, Error> {
89+
Ok(Terminal::new(TestListener::default(), title, ColorScheme::default(), 1024, None))
90+
}
91+
fn request_update(&self, _id: u32) {}
92+
}
93+
94+
#[fasync::run_singlethreaded(test)]
95+
async fn can_start_logo() -> Result<(), Error> {
96+
let client = TestLogClient::default();
97+
let _ = Logo::start(&client, 0)?;
98+
Ok(())
99+
}
100+
}

src/lib/assembly/platform_configuration/src/subsystems/graphics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl DefineSubsystemConfiguration<GraphicsConfig> for GraphicsSubsystemConfig {
7474

7575
builder.set_config_capability("fuchsia.virtcon.FontSize", Config::new_void())?;
7676
builder.set_config_capability("fuchsia.virtcon.KeepLogVisible", Config::new_void())?;
77-
77+
builder.set_config_capability("fuchsia.virtcon.ShowLogo", Config::new_bool(true))?;
7878
if let Some(keymap) = &virtcon_config.keymap {
7979
builder.set_config_capability(
8080
"fuchsia.virtcon.KeyMap",

src/sys/root/root.cml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
"fuchsia.virtcon.KeyRepeat",
111111
"fuchsia.virtcon.RoundedCorners",
112112
"fuchsia.virtcon.ScrollbackRows",
113+
"fuchsia.virtcon.ShowLogo",
113114
],
114115
from: "#config",
115116
to: "#bootstrap",

0 commit comments

Comments
 (0)