espterm / espterm-firmware

ESPTerm - ESP8266 terminal emulator. Branches: [master] patches, [work] next release
Mozilla Public License 2.0
127 stars 24 forks source link

Draw line drawing characters with lines or rects #180

Open MightyPork opened 7 years ago

MightyPork commented 7 years ago

maybe it would look nice, idk about the speed and also it'll be a pain cause there are over 100 of them

mind, we don't need all of them for sure (namely I don't care about the halflings and probably dont need bold ones if we have the thin ones that are more common)

        0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x2500  ─  ━  │  ┃  ┄  ┅  ┆  ┇  ┈  ┉  ┊  ┋  ┌  ┍  ┎  ┏
0x2510  ┐  ┑  ┒  ┓  └  ┕  ┖  ┗  ┘  ┙  ┚  ┛  ├  ┝  ┞  ┟
0x2520  ┠  ┡  ┢  ┣  ┤  ┥  ┦  ┧  ┨  ┩  ┪  ┫  ┬  ┭  ┮  ┯
0x2530  ┰  ┱  ┲  ┳  ┴  ┵  ┶  ┷  ┸  ┹  ┺  ┻  ┼  ┽  ┾  ┿
0x2540  ╀  ╁  ╂  ╃  ╄  ╅  ╆  ╇  ╈  ╉  ╊  ╋  ╌  ╍  ╎  ╏
0x2550  ═  ║  ╒  ╓  ╔  ╕  ╖  ╗  ╘  ╙  ╚  ╛  ╜  ╝  ╞  ╟
0x2560  ╠  ╡  ╢  ╣  ╤  ╥  ╦  ╧  ╨  ╩  ╪  ╫  ╬  ╭  ╮  ╯
0x2570  ╰  ╱  ╲  ╳  ╴  ╵  ╶  ╷  ╸  ╹  ╺  ╻  ╼  ╽  ╾  ╿
cpsdqs commented 7 years ago

Best case scenario:

cpsdqs commented 7 years ago

So I tried writing some code for this, and I have to ask: how big can it be? Because the amount of code to render all that is—while it does have a repeating pattern—a lot

MightyPork commented 7 years ago

if it's over say 50 kB minified, that wouldn't be ideal, but there is still space left.

I'd write it like

drawLines(top, right, bottom, left) { // <- eg. 0 - none, 1 - single, 2 - thicc, 3-double
  a bunch of horrible ifs
}

and then a switch that calls drawLines for each point ...

MightyPork commented 7 years ago

if you gzip the output folder (without the humongous sourcemap, .orig and other junk files), + around 240 kB of code, it should ideally fit in 500 kB

technically there is 1 MB available, but if I ever want to implement OTA update, only half can be used

cpsdqs commented 7 years ago

Added: https://github.com/espterm/espterm-front-end/commit/a79b08a16bfe5f3be7e97b78a3d39c05db247751

However, there's one remaining issue; the characters in the 0x2552–0x256C range are slightly wrong (right is unicode):

comparison screenshot
cpsdqs commented 7 years ago

...also, term_screen.js is now a whopping 1758 lines

MightyPork commented 7 years ago

it looks like trash in my chrome screenshot_20170917_184120

MightyPork commented 7 years ago

I'll try to move this onto a branch so I can make a release even if it's not finished

MightyPork commented 7 years ago

there, it's on branch box-drawing. also I force-pushed to work so pls update your ref

cpsdqs commented 7 years ago

Oh dear, @‌1x ruins everything

MightyPork commented 7 years ago

maybe adding +0.5 everywhere can fix that

cpsdqs commented 7 years ago

nope, then it'd just break if your system has a different font

MightyPork commented 7 years ago

i think i'll try to redo this using rects, they worked nicely for the block chars

cpsdqs commented 7 years ago

hm, maybe? You might want to round the center so that it’s on a whole-pixel value if the DPR is 1 or lower