aboutsummaryrefslogtreecommitdiffhomepage
path: root/screen.c
diff options
context:
space:
mode:
authorGravatar liljencrantz <liljencrantz@gmail.com>2007-09-24 18:56:02 +1000
committerGravatar liljencrantz <liljencrantz@gmail.com>2007-09-24 18:56:02 +1000
commitd44dd73682dd08fd5c26e20666c18414798d7a73 (patch)
treeab47685a14d2c5f0b5ebdceeababc22822bc9441 /screen.c
parent5938a930188b44b0c57969ff65aa13e7034aac21 (diff)
Improve documentation in screen handling code
darcs-hash:20070924085602-75c98-0a60a87de51e0dbf7e64221b0382401e72745465.gz
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/screen.c b/screen.c
index 5b4c1fcd..98061c6a 100644
--- a/screen.c
+++ b/screen.c
@@ -779,12 +779,19 @@ void s_write( screen_t *s,
int prompt_width;
int screen_width;
+ int max_line_width = 0;
+ int current_line_width = 0;
+
CHECK( s, );
CHECK( prompt, );
CHECK( b, );
CHECK( c, );
CHECK( indent, );
+ /*
+ If we are using a dumb terminal, don't try any fancy stuff,
+ just print out the text.
+ */
if( is_dumb() )
{
char *prompt_narrow = wcs2str( prompt );
@@ -798,17 +805,19 @@ void s_write( screen_t *s,
free( buffer_narrow );
return;
-
}
-
prompt_width = calc_prompt_width( prompt );
screen_width = common_get_width();
s_check_status( s );
/*
- Ignore huge prompts on small screens - only print a two character placeholder...
+ Ignore prompts wider than the screen - only print a two
+ character placeholder...
+
+ It would be cool to truncate the prompt, but because it can
+ contain escape sequences, this is harder than you'd think.
*/
if( prompt_width >= screen_width )
{
@@ -817,16 +826,17 @@ void s_write( screen_t *s,
}
/*
- Ignore impossibly small screens
+ Completely ignore impossibly small screens
*/
if( screen_width < 4 )
{
return;
}
- int max_line_width = 0;
- int current_line_width = 0;
-
+ /*
+ Check if we are overflowing
+ */
+
for( i=0; b[i]; i++ )
{
if( b[i] == L'\n' )
@@ -847,7 +857,8 @@ void s_write( screen_t *s,
s->desired_cursor[0] = s->desired_cursor[1] = 0;
/*
- Check if we are overflowing. If so, give the prompt its own line to improve the situation.
+ If overflowing, give the prompt its own line to improve the
+ situation.
*/
if( max_line_width + prompt_width >= screen_width )
{
@@ -883,7 +894,7 @@ void s_write( screen_t *s,
if( i== cursor && s->desired_cursor[1] != cursor_arr[1] && b[i] != L'\n' )
{
- /**
+ /*
Ugh. We are placed exactly at the wrapping point of a
wrapped line, move cursor to the line below so the
cursor won't be on the ellipsis which looks