diff options
author | swirl <swurl@swurl.xyz> | 2022-05-27 15:25:28 -0400 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2022-05-30 18:04:42 +0200 |
commit | 9a9a97868d0366408d7a310de3fa7158a294854e (patch) | |
tree | 74641d809f9f8f52b3d3507eb1fcc84b52c6c08a /src/ui | |
parent | cf83976b51dd103a17b75dd77f326f64166199bc (diff) | |
download | profani-tty-9a9a97868d0366408d7a310de3fa7158a294854e.tar.gz |
implement working OMEMO QR code
TODO: We need to find a way to switch the colors of the QR code, so that more QR readers can detect it, without "blending" the edges of the QR code with the surrounding terminal window. Signed-off-by: swirl <swurl@swurl.xyz>
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/console.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/ui/console.c b/src/ui/console.c index ae1f796d..e0b0fa4d 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -878,18 +878,16 @@ cons_show_omemo_qrcode(const char* const text) ProfWin* console = wins_get_console(); + char buf[(width * 4) + 1]; + memset(buf, 0, sizeof buf); for (size_t y = 0; y < width; y+=ZOOM_SIZE) { - //size_t y_index = y * width; for (size_t x = 0; x < width; x+=ZOOM_SIZE) { - if (x==0) { - win_print(console, THEME_DEFAULT, "", "%s", (*data & 1) ? "A" : "B"); - } else { - win_append(console, THEME_DEFAULT, "", "%s", (*data & 1) ? "A" : "B"); - } + strcat(buf, (*data & 1) ? "\u2588\u2588" : "\u2800\u2800"); data++; } - win_println(console, THEME_DEFAULT, "", ""); + win_println(console, THEME_DEFAULT, "", "%s", buf); + memset(buf, 0, sizeof buf); } QRcode_free(qrcode); @@ -2928,3 +2926,4 @@ cons_remove_alert(ProfWin* window) g_list_free_full(item, g_free); free(win_name); } + |