Skip to content

Commit

Permalink
Merge pull request mobile-shell#1143 from creaktive/master
Browse files Browse the repository at this point in the history
Use the wcwidth() implementation from the Fish shell instead of the one from libc
  • Loading branch information
jdrouhard committed May 20, 2023
2 parents 119086e + 29408c7 commit ec788d3
Show file tree
Hide file tree
Showing 3 changed files with 562 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/frontend/terminaloverlay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <limits.h>

#include "terminaloverlay.h"
#include "widechar_width.h"

using namespace Overlay;

Expand Down Expand Up @@ -261,7 +262,7 @@ void NotificationEngine::apply( Framebuffer &fb ) const
}

wchar_t ch = *i;
int chwidth = ch == L'\0' ? -1 : wcwidth( ch );
int chwidth = ch == L'\0' ? -1 : widechar_wcwidth( ch );
Cell *this_cell = 0;

switch ( chwidth ) {
Expand Down Expand Up @@ -743,7 +744,7 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
}
}
}
} else if ( (ch < 0x20) || (wcwidth( ch ) != 1) ) {
} else if ( (ch < 0x20) || (widechar_wcwidth( ch ) != 1) ) {
/* unknown print */
become_tentative();
// fprintf( stderr, "Unknown print 0x%x\n", ch );
Expand Down
3 changes: 2 additions & 1 deletion src/terminal/terminal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <typeinfo>

#include "terminal.h"
#include "widechar_width.h"

using namespace Terminal;

Expand Down Expand Up @@ -66,7 +67,7 @@ void Emulator::print( const Parser::Print *act )
* Check for printing ISO 8859-1 first, it's a cheap way to detect
* some common narrow characters.
*/
const int chwidth = ch == L'\0' ? -1 : ( Cell::isprint_iso8859_1( ch ) ? 1 : wcwidth( ch ));
const int chwidth = ch == L'\0' ? -1 : ( Cell::isprint_iso8859_1( ch ) ? 1 : widechar_wcwidth( ch ));

Cell *this_cell = fb.get_mutable_cell();

Expand Down
Loading

0 comments on commit ec788d3

Please sign in to comment.