• Completely overhaul prompt length calculation and
prompt display routines; make Emacs and Vi share code, permitting reducing of duplication and code removal as well as more consistent behaviour; put some common code into shared helper functions, too • New x_adjust() logic (Emacs mode): when determining what portion of a line to render use a much more sophisticated algorithm and try to fill up ⅔ of the total screen width (with line and prompt both) also as wished from Steffen Daode Nurpmeso
This commit is contained in:
30
lex.c
30
lex.c
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.186 2013/06/01 00:15:57 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.187 2013/07/26 20:33:38 tg Exp $");
|
||||
|
||||
/*
|
||||
* states while lexing word
|
||||
@@ -102,8 +102,6 @@ static void gethere(bool);
|
||||
static Lex_state *push_state_i(State_info *, Lex_state *);
|
||||
static Lex_state *pop_state_i(State_info *, Lex_state *);
|
||||
|
||||
static int dopprompt(const char *, int, bool);
|
||||
|
||||
static int backslash_skip;
|
||||
static int ignore_backslash_newline;
|
||||
|
||||
@@ -1520,8 +1518,8 @@ set_prompt(int to, Source *s)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
dopprompt(const char *cp, int ntruncate, bool doprint)
|
||||
int
|
||||
pprompt(const char *cp, int ntruncate)
|
||||
{
|
||||
int columns = 0, lines = 0;
|
||||
bool indelimit = false;
|
||||
@@ -1554,35 +1552,21 @@ dopprompt(const char *cp, int ntruncate, bool doprint)
|
||||
else if (UTFMODE && ((unsigned char)*cp > 0x7F)) {
|
||||
const char *cp2;
|
||||
columns += utf_widthadj(cp, &cp2);
|
||||
if (doprint && (indelimit ||
|
||||
(ntruncate < (x_cols * lines + columns))))
|
||||
if (indelimit ||
|
||||
(ntruncate < (x_cols * lines + columns)))
|
||||
shf_write(cp, cp2 - cp, shl_out);
|
||||
cp = cp2 - /* loop increment */ 1;
|
||||
continue;
|
||||
} else
|
||||
columns++;
|
||||
if (doprint && (*cp != delimiter) &&
|
||||
if ((*cp != delimiter) &&
|
||||
(indelimit || (ntruncate < (x_cols * lines + columns))))
|
||||
shf_putc(*cp, shl_out);
|
||||
}
|
||||
if (doprint)
|
||||
shf_flush(shl_out);
|
||||
shf_flush(shl_out);
|
||||
return (x_cols * lines + columns);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pprompt(const char *cp, int ntruncate)
|
||||
{
|
||||
dopprompt(cp, ntruncate, true);
|
||||
}
|
||||
|
||||
int
|
||||
promptlen(const char *cp)
|
||||
{
|
||||
return (dopprompt(cp, 0, false));
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the variable part of a ${...} expression (i.e. up to but not
|
||||
* including the :[-+?=#%] or close-brace).
|
||||
|
Reference in New Issue
Block a user