Skip to content
Snippets Groups Projects
Verified Commit 46b1f32f authored by Benny Baumann's avatar Benny Baumann
Browse files

Basic key input tester

parent a24a33e6
No related branches found
No related tags found
No related merge requests found
Pipeline #1604 failed
...@@ -16,6 +16,7 @@ msgstr "" ...@@ -16,6 +16,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/app/rmrf.cpp:24 #: src/app/rmrf.cpp:27
msgid "Hello World!\n" #, c-format
msgstr "Hallo Welt!\n" msgid "Detected key: %8x (ct=%i)"
msgstr "Erkannte Taste: %8x (ct=%i)"
...@@ -16,6 +16,7 @@ msgstr "" ...@@ -16,6 +16,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/app/rmrf.cpp:24 #: src/app/rmrf.cpp:27
msgid "Hello World!\n" #, c-format
msgstr "Hello World!\n" msgid "Detected key: %8x (ct=%i)"
msgstr "Detected key: %8x (ct=%i)"
...@@ -14,8 +14,8 @@ msgstr "Project-Id-Version: rmrf 0.1\n" ...@@ -14,8 +14,8 @@ msgstr "Project-Id-Version: rmrf 0.1\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
#: src/app/rmrf.cpp:24 #: src/app/rmrf.cpp:27
msgid "Hello World!\n" #, c-format
msgid "Detected key: %8x (ct=%i)"
msgstr "" msgstr ""
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "lib/gettext/translations.hpp" #include "lib/gettext/translations.hpp"
#include "lib/ncurses/ncurses.hpp"
#include "ui/view.hpp" #include "ui/view.hpp"
int main() { int main() {
...@@ -13,9 +15,16 @@ int main() { ...@@ -13,9 +15,16 @@ int main() {
auto h_nc = std::make_shared<display>(); auto h_nc = std::make_shared<display>();
h_nc->sync([](const display::ptr_type &) { h_nc->clear();
std::cout << _("Hello World!\n") << std::flush;
}); for(size_t x = 0; x < 16; x++) {
wint_t unichar{0};
int ct = get_wch(&unichar); /* read character */
h_nc->sync([x, ct, unichar](const display::ptr_type &) {
mvprintw((int)x, 0, _("Detected key: %8x (ct=%i)"), unichar, ct);
});
}
return 0; return 0;
} }
...@@ -8,10 +8,20 @@ namespace rmrf::ui { ...@@ -8,10 +8,20 @@ namespace rmrf::ui {
display::display() : m{} { display::display() : m{} {
initscr(); initscr();
raw();
cbreak();
noecho();
keypad(stdscr, TRUE);
} }
display::~display() { display::~display() {
endwin(); endwin();
} }
void display::clear() {
this->sync([](const display::ptr_type &) {
::clear();
});
}
} }
...@@ -36,6 +36,10 @@ public: ...@@ -36,6 +36,10 @@ public:
return std::forward<F>(f)(shared_from_this(), std::forward<Args>(args)...); return std::forward<F>(f)(shared_from_this(), std::forward<Args>(args)...);
} }
public:
void clear();
}; };
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment