mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
parent
71019eccbd
commit
434783da4d
@ -26,6 +26,7 @@
|
||||
#include <model/capacity.h>
|
||||
#include <model/popup.h>
|
||||
#include <model/runtime_config.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace Sculpt { struct Graph; }
|
||||
|
||||
@ -127,6 +128,7 @@ struct Sculpt::Graph
|
||||
_runtime_config.for_each_component([&] (Component const &component) {
|
||||
|
||||
Start_name const name = component.name;
|
||||
Start_name const pretty_name { Pretty(name) };
|
||||
|
||||
/* omit sculpt's helpers from the graph */
|
||||
bool const blacklisted = (name == "runtime_view"
|
||||
@ -158,7 +160,7 @@ struct Sculpt::Graph
|
||||
xml.attribute("selected", "yes");
|
||||
|
||||
xml.node("label", [&] () {
|
||||
xml.attribute("text", name);
|
||||
xml.attribute("text", pretty_name);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -110,7 +110,7 @@ struct Sculpt::Route : List_model<Route>::Element
|
||||
{
|
||||
Genode::print(out, _pretty_name(required));
|
||||
if (required_label.valid())
|
||||
Genode::print(out, " (", required_label, ") ");
|
||||
Genode::print(out, " (", Pretty(required_label), ") ");
|
||||
}
|
||||
|
||||
void gen_xml(Xml_generator &xml) const
|
||||
|
@ -14,7 +14,7 @@
|
||||
#ifndef _MODEL__SERVICE_H_
|
||||
#define _MODEL__SERVICE_H_
|
||||
|
||||
#include "types.h"
|
||||
#include <string.h>
|
||||
|
||||
namespace Sculpt { struct Service; }
|
||||
|
||||
@ -67,7 +67,7 @@ struct Sculpt::Service
|
||||
* Constructor for child service
|
||||
*/
|
||||
Service(Start_name const &server, Type type, Label const &label)
|
||||
: server(server), type(type), label(label), info(server) { }
|
||||
: server(server), type(type), label(label), info(Subst("_", " ", server)) { }
|
||||
|
||||
/**
|
||||
* Constructor for parent service
|
||||
|
77
repos/gems/src/app/sculpt_manager/string.h
Normal file
77
repos/gems/src/app/sculpt_manager/string.h
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* \brief Utilities for string handling
|
||||
* \author Norman Feske
|
||||
* \date 2019-03-01
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2019 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _STRING_H_
|
||||
#define _STRING_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/string.h>
|
||||
#include <base/output.h>
|
||||
|
||||
/* local includes */
|
||||
#include "types.h"
|
||||
|
||||
namespace Sculpt {
|
||||
|
||||
class Subst;
|
||||
class Pretty;
|
||||
}
|
||||
|
||||
|
||||
class Sculpt::Subst
|
||||
{
|
||||
private:
|
||||
|
||||
char const * const _pattern;
|
||||
size_t const _pattern_len = strlen(_pattern);
|
||||
char const * const _replacement;
|
||||
char const * const _input;
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
* This utility is currently limited to strings. It should better
|
||||
* act as a filter that accepts any printable type as 'input'
|
||||
* argument. However the automatic deduction of class template
|
||||
* arguments from a constuctor calls is not suppored before C++17.
|
||||
*/
|
||||
|
||||
Subst(char const *pattern, char const *replacement, char const *input)
|
||||
: _pattern(pattern), _replacement(replacement), _input(input) { }
|
||||
|
||||
template <size_t N>
|
||||
Subst(char const *pattern, char const *replacement, String<N> const &input)
|
||||
: Subst(pattern, replacement, input.string()) { }
|
||||
|
||||
void print(Output &out) const
|
||||
{
|
||||
for (char const *curr = _input; *curr; ) {
|
||||
if (_pattern_len && strcmp(curr, _pattern, _pattern_len) == 0) {
|
||||
Genode::print(out, _replacement);
|
||||
curr += _pattern_len;
|
||||
} else {
|
||||
Genode::print(out, Char(*curr));
|
||||
curr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct Sculpt::Pretty : Subst
|
||||
{
|
||||
template <size_t N>
|
||||
Pretty(String<N> const &input) : Subst("_", " ", input) { }
|
||||
};
|
||||
|
||||
#endif /* _XML_H_ */
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <view/popup_dialog.h>
|
||||
#include <string.h>
|
||||
|
||||
using namespace Sculpt;
|
||||
|
||||
@ -32,7 +33,7 @@ void Popup_dialog::_gen_pkg_elements(Xml_generator &xml,
|
||||
{
|
||||
typedef Component::Info Info;
|
||||
|
||||
_gen_sub_menu_title(xml, "back", Menu::Name("Add ", _construction_name));
|
||||
_gen_sub_menu_title(xml, "back", Menu::Name("Add ", Pretty(_construction_name)));
|
||||
|
||||
_gen_pkg_info(xml, component);
|
||||
|
||||
@ -107,7 +108,7 @@ void Popup_dialog::_gen_menu_elements(Xml_generator &xml) const
|
||||
if (_runtime_info.present_in_runtime(info.path))
|
||||
return;
|
||||
|
||||
_gen_menu_entry(xml, info.path, info.path, false);
|
||||
_gen_menu_entry(xml, info.path, Pretty(info.path), false);
|
||||
});
|
||||
|
||||
_gen_menu_entry(xml, "depot", "Depot ...", false);
|
||||
@ -197,7 +198,7 @@ void Popup_dialog::_gen_menu_elements(Xml_generator &xml) const
|
||||
selected = true;
|
||||
});
|
||||
|
||||
String<100> const text(name, " " "(", version, ")",
|
||||
String<100> const text(Pretty(name), " " "(", version, ")",
|
||||
installing ? " installing... " : "...");
|
||||
|
||||
_gen_menu_entry(xml, id, text, selected);
|
||||
|
Loading…
Reference in New Issue
Block a user