aboutsummaryrefslogtreecommitdiffhomepage
path: root/output.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-11-05 00:05:42 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-11-05 00:05:42 -0800
commit21e83a881e59916cd4ad76c232e5857ef111be84 (patch)
treee2010898e25aae6929c90679abe6539033aa8143 /output.cpp
parent5ba1261285853e3448fc4397f1ca3a1e1733f6ba (diff)
Bring back ellipsis
Diffstat (limited to 'output.cpp')
-rw-r--r--output.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/output.cpp b/output.cpp
index 9ce7f7ab..b061693e 100644
--- a/output.cpp
+++ b/output.cpp
@@ -489,6 +489,43 @@ void writestr( const wchar_t *str )
delete[] buffer;
}
+
+void writestr_ellipsis( const wchar_t *str, int max_width )
+{
+ int written=0;
+ int tot;
+
+ CHECK( str, );
+
+ tot = my_wcswidth(str);
+
+ if( tot <= max_width )
+ {
+ writestr( str );
+ return;
+ }
+
+ while( *str != 0 )
+ {
+ int w = fish_wcwidth( *str );
+ if( written+w+fish_wcwidth( ellipsis_char )>max_width )
+ {
+ break;
+ }
+ written+=w;
+ writech( *(str++) );
+ }
+
+ written += fish_wcwidth( ellipsis_char );
+ writech( ellipsis_char );
+
+ while( written < max_width )
+ {
+ written++;
+ writestr( L" " );
+ }
+}
+
int write_escaped_str( const wchar_t *str, int max_len )
{
@@ -509,6 +546,8 @@ int write_escaped_str( const wchar_t *str, int max_len )
writech( out[i] );
written += fish_wcwidth( out[i] );
}
+ writech( ellipsis_char );
+ written += fish_wcwidth( ellipsis_char );
for( i=written; i<max_len; i++ )
{