-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Its useful if the README is correct. Reviewed By: lmvasquezg Differential Revision: D46436301 fbshipit-source-id: 55a0f58423444a6047347daa783e587c07fdfc16
- Loading branch information
1 parent
657b19b
commit 740a337
Showing
2 changed files
with
50 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under both the MIT license found in the | ||
* LICENSE-MIT file in the root directory of this source tree and the Apache | ||
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
* of this source tree. | ||
*/ | ||
|
||
// If this code needs fixing, make sure you fix the README.md too! | ||
|
||
use std::convert::TryInto; | ||
|
||
use superconsole::components::bordering::Bordered; | ||
use superconsole::components::bordering::BorderedSpec; | ||
use superconsole::Component; | ||
use superconsole::Dimensions; | ||
use superconsole::DrawMode; | ||
use superconsole::Lines; | ||
use superconsole::SuperConsole; | ||
|
||
#[derive(Debug)] | ||
struct HelloWorld; | ||
|
||
impl Component for HelloWorld { | ||
fn draw_unchecked(&self, _dimensions: Dimensions, _mode: DrawMode) -> anyhow::Result<Lines> { | ||
Ok(Lines(vec![ | ||
vec!["Hello world!".to_owned()].try_into().unwrap(), | ||
])) | ||
} | ||
} | ||
|
||
pub fn main() -> anyhow::Result<()> { | ||
let bordering = BorderedSpec::default(); | ||
let mut superconsole = SuperConsole::new().ok_or_else(|| anyhow::anyhow!("Not a TTY"))?; | ||
let component = Bordered::new(HelloWorld, bordering); | ||
superconsole.render(&component)?; | ||
superconsole.finalize(&component)?; | ||
Ok(()) | ||
} |