From 7d8ebb4c8fc821d3119353eb46dfec126a6ac318 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 26 Jan 2021 22:05:14 +0100 Subject: [PATCH] Add ui.code(text): like ui.monospace() but also adds a background --- egui/src/ui.rs | 7 +++++++ egui/src/widgets/label.rs | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/egui/src/ui.rs b/egui/src/ui.rs index 23961fee..16c6b622 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -643,6 +643,13 @@ impl Ui { self.add(label.into().monospace()) } + /// Show text as monospace with a gray background. + /// + /// Shortcut for `add(Label::new(text).code())` + pub fn code(&mut self, label: impl Into