mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Add q
keyboard shortcut to printvideo.com (#37)
This commit is contained in:
parent
4e56d89dcd
commit
28135b7a20
7 changed files with 33 additions and 24 deletions
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/likely.h"
|
||||
#include "libc/unicode/unicode.h"
|
||||
|
||||
extern const uint8_t kEastAsianWidth[];
|
||||
|
@ -26,15 +27,18 @@ extern const uint32_t kCombiningCharsBits;
|
|||
/**
|
||||
* Returns cell width of monospace character.
|
||||
*/
|
||||
int wcwidth(wchar_t ucs) {
|
||||
if (ucs == 0) return 0;
|
||||
if ((0 <= ucs && ucs < 32) || (0x7f <= ucs && ucs < 0xA0)) {
|
||||
return -1;
|
||||
} else if ((0 <= ucs && ucs < kCombiningCharsBits) &&
|
||||
!!(kCombiningChars[ucs >> 3] & (1 << (ucs & 7)))) {
|
||||
int wcwidth(wchar_t c) {
|
||||
if (LIKELY(32 <= c && c < 127)) {
|
||||
return 1;
|
||||
} else if (!c) {
|
||||
return 0;
|
||||
} else if (0 <= ucs && ucs < kEastAsianWidthBits) {
|
||||
return 1 + !!(kEastAsianWidth[ucs >> 3] & (1 << (ucs & 7)));
|
||||
} else if ((0 < c && c < 32) || (0x7f <= c && c < 0xA0)) {
|
||||
return -1;
|
||||
} else if ((0 <= c && c < kCombiningCharsBits) &&
|
||||
!!(kCombiningChars[c >> 3] & (1 << (c & 7)))) {
|
||||
return 0;
|
||||
} else if (0 <= c && c < kEastAsianWidthBits) {
|
||||
return 1 + !!(kEastAsianWidth[c >> 3] & (1 << (c & 7)));
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue