Added a history speed test

Profile driven caching of config directory
Style fixes
This commit is contained in:
ridiculousfish
2012-12-03 02:25:08 -08:00
parent 33fc5c99ea
commit b9283d48b5
7 changed files with 137 additions and 100 deletions

View File

@@ -170,10 +170,10 @@ struct prompt_layout_t
{
/* How many lines the prompt consumes */
size_t line_count;
/* Width of the longest line */
size_t max_line_width;
/* Width of the last line */
size_t last_line_width;
};
@@ -187,7 +187,7 @@ static prompt_layout_t calc_prompt_layout(const wchar_t *prompt)
{
size_t current_line_width = 0;
size_t j, k;
prompt_layout_t prompt_layout = {};
prompt_layout.line_count = 1;
@@ -741,52 +741,55 @@ static bool test_stuff(screen_t *scr)
{
data_buffer_t output;
scoped_buffer_t scoped_buffer(&output);
s_move(scr, &output, 0, 0);
int screen_width = common_get_width();
const wchar_t *left = L"left";
const wchar_t *right = L"right";
for (size_t idx = 0; left[idx]; idx++)
{
s_write_char(scr, &output, left[idx]);
}
s_move(scr, &output, screen_width - wcslen(right), 0);
for (size_t idx = 0; right[idx]; idx++)
{
s_write_char(scr, &output, right[idx]);
}
if (! output.empty())
{
write_loop(STDOUT_FILENO, &output.at(0), output.size());
output.clear();
}
sleep(5);
for (size_t i=0; i < 1; i++) {
for (size_t i=0; i < 1; i++)
{
writembs(cursor_left);
}
if (! output.empty())
{
write_loop(1, &output.at(0), output.size());
output.clear();
}
while (1) {
while (1)
{
int c = getchar();
if (c != EOF) break;
}
while (1) {
while (1)
{
int c = getchar();
if (c != EOF) break;
}
@@ -826,13 +829,13 @@ static void s_update(screen_t *scr, const wchar_t *left_prompt, const wchar_t *r
need_clear_screen = true;
s_move(scr, &output, 0, 0);
s_reset(scr, screen_reset_current_line_contents);
need_clear_lines = need_clear_lines || scr->need_clear_lines;
need_clear_screen = need_clear_screen || scr->need_clear_screen;
}
scr->actual_width = screen_width;
}
scr->need_clear_lines = false;
scr->need_clear_screen = false;
@@ -910,14 +913,14 @@ static void s_update(screen_t *scr, const wchar_t *left_prompt, const wchar_t *r
s_write_mbs(&output, clr_eos);
has_cleared_screen = true;
}
perform_any_impending_soft_wrap(scr, current_width, (int)i);
s_move(scr, &output, current_width, (int)i);
s_set_color(scr, &output, o_line.color_at(j));
s_write_char(scr, &output, o_line.char_at(j));
current_width += fish_wcwidth_min_0(o_line.char_at(j));
}
/* Clear the screen if we have not done so yet. */
if (should_clear_screen_this_line && ! has_cleared_screen)
{
@@ -960,12 +963,12 @@ static void s_update(screen_t *scr, const wchar_t *left_prompt, const wchar_t *r
s_set_color(scr, &output, 0xffffffff);
s_write_str(&output, right_prompt);
scr->actual.cursor.x += right_prompt_width;
/* We output in the last column. Some terms (Linux) push the cursor further right, past the window. Others make it "stick." Since we don't really know which is which, issue a cr so it goes back to the left.
/* We output in the last column. Some terms (Linux) push the cursor further right, past the window. Others make it "stick." Since we don't really know which is which, issue a cr so it goes back to the left.
However, if the user is resizing the window smaller, then it's possible the cursor wrapped. If so, then a cr will go to the beginning of the following line! So instead issue a bunch of "move left" commands to get back onto the line, and then jump to the front of it (!)
*/
s_move(scr, &output, scr->actual.cursor.x - (int)right_prompt_width, scr->actual.cursor.y);
s_write_str(&output, L"\r");
scr->actual.cursor.x = 0;
@@ -1051,7 +1054,7 @@ static screen_layout_t compute_layout(screen_t *s,
prompt_layout_t left_prompt_layout = calc_prompt_layout(left_prompt);
prompt_layout_t right_prompt_layout = calc_prompt_layout(right_prompt);
size_t left_prompt_width = left_prompt_layout.last_line_width;
size_t right_prompt_width = right_prompt_layout.last_line_width;
@@ -1122,9 +1125,9 @@ static screen_layout_t compute_layout(screen_t *s,
2. Left prompt visible, right prompt visible, command line visible, autosuggestion truncated (possibly to zero)
3. Left prompt visible, right prompt hidden, command line visible, autosuggestion hidden
4. Newline separator (left prompt visible, right prompt hidden, command line visible, autosuggestion visible)
A remark about layout #4: if we've pushed the command line to a new line, why can't we draw the right prompt? The issue is resizing: if you resize the window smaller, then the right prompt will wrap to the next line. This means that we can't go back to the line that we were on, and things turn to chaos very quickly.
*/
bool done = false;
@@ -1310,10 +1313,10 @@ void s_reset(screen_t *s, screen_reset_mode_t mode)
{
s->actual_lines_before_reset = maxi(s->actual_lines_before_reset, s->actual.line_count());
}
if (repaint_prompt && ! abandon_line)
{
/* If the prompt is multi-line, we need to move up to the prompt's initial line. We do this by lying to ourselves and claiming that we're really below what we consider "line 0" (which is the last line of the prompt). This will cause us to move up to try to get back to line 0, but really we're getting back to the initial line of the prompt. */
const size_t prompt_line_count = calc_prompt_lines(s->actual_left_prompt);
assert(prompt_line_count >= 1);
@@ -1336,7 +1339,7 @@ void s_reset(screen_t *s, screen_reset_mode_t mode)
int screen_width = common_get_width();
wcstring abandon_line_string;
abandon_line_string.reserve(screen_width);
int non_space_width = wcwidth(omitted_newline_char);
if (screen_width >= non_space_width)
{