mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-23 14:24:18 -04:00
Add Notepad app (#1010)
* easier 'now', start adding text editor * Adding scrolling to notepad * Better scrolling * Better scrolling, off-by-1 bugs * MVP fit and finish * Add tiny font and use in Notepad * Font tweaking, tiny font cursor * Fix warning * Format changed files --------- Co-authored-by: kallanreed <kallanreed@outlook.com>
This commit is contained in:
parent
693d7864e4
commit
02811b9967
21 changed files with 1316 additions and 56 deletions
|
@ -45,22 +45,6 @@ std::string truncate(const fs::path& path, size_t max_length) {
|
|||
return ::truncate(path.string(), max_length);
|
||||
}
|
||||
|
||||
// Gets a human readable file size string.
|
||||
std::string get_pretty_size(uint32_t file_size) {
|
||||
static const std::string suffix[5] = {"B", "kB", "MB", "GB", "??"};
|
||||
size_t suffix_index = 0;
|
||||
|
||||
while (file_size >= 1024) {
|
||||
file_size /= 1024;
|
||||
suffix_index++;
|
||||
}
|
||||
|
||||
if (suffix_index > 4)
|
||||
suffix_index = 4;
|
||||
|
||||
return to_string_dec_uint(file_size) + suffix[suffix_index];
|
||||
}
|
||||
|
||||
// Case insensitive path equality on underlying "native" string.
|
||||
bool iequal(
|
||||
const fs::path& lhs,
|
||||
|
@ -272,25 +256,27 @@ void FileManBaseView::refresh_list() {
|
|||
auto entry_name = truncate(entry.path, 20);
|
||||
|
||||
if (entry.is_directory) {
|
||||
menu_view.add_item({entry_name,
|
||||
ui::Color::yellow(),
|
||||
&bitmap_icon_dir,
|
||||
[this](KeyEvent key) {
|
||||
if (on_select_entry)
|
||||
on_select_entry(key);
|
||||
}});
|
||||
menu_view.add_item(
|
||||
{entry_name,
|
||||
ui::Color::yellow(),
|
||||
&bitmap_icon_dir,
|
||||
[this](KeyEvent key) {
|
||||
if (on_select_entry)
|
||||
on_select_entry(key);
|
||||
}});
|
||||
|
||||
} else {
|
||||
const auto& assoc = get_assoc(entry.path.extension());
|
||||
auto size_str = get_pretty_size(entry.size);
|
||||
auto size_str = to_string_file_size(entry.size);
|
||||
|
||||
menu_view.add_item({entry_name + std::string(21 - entry_name.length(), ' ') + size_str,
|
||||
assoc.color,
|
||||
assoc.icon,
|
||||
[this](KeyEvent key) {
|
||||
if (on_select_entry)
|
||||
on_select_entry(key);
|
||||
}});
|
||||
menu_view.add_item(
|
||||
{entry_name + std::string(21 - entry_name.length(), ' ') + size_str,
|
||||
assoc.color,
|
||||
assoc.icon,
|
||||
[this](KeyEvent key) {
|
||||
if (on_select_entry)
|
||||
on_select_entry(key);
|
||||
}});
|
||||
}
|
||||
|
||||
// HACK: Should page menu items instead of limiting the number.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue