forked from mobile-shell/mosh
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mobile-shell#1289 from zhaofengli/fish-wcwidth
- Loading branch information
Showing
6 changed files
with
1,563 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/util/widechar_width.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
* text=true | ||
src/util/widechar_width.h linguist-vendored=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef CHAR_UTILS_HPP | ||
#define CHAR_UTILS_HPP | ||
|
||
#include "widechar_width.h" | ||
|
||
static int mosh_wcwidth( uint32_t c ) | ||
{ | ||
int width = widechar_wcwidth( c ); | ||
if ( width >= 0 ) { | ||
return width; | ||
} | ||
|
||
/* https://github.com/ridiculousfish/widecharwidth/tree/master#c-usage */ | ||
switch ( width ) { | ||
case widechar_nonprint: | ||
return -1; | ||
case widechar_combining: | ||
return 0; | ||
case widechar_ambiguous: | ||
return 1; | ||
case widechar_private_use: | ||
return 1; | ||
case widechar_unassigned: | ||
return -1; | ||
case widechar_non_character: | ||
return -1; | ||
case widechar_widened_in_9: | ||
return 2; | ||
default: | ||
return -1; | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.