Exemplo n.º 1
0
static int line_start_callback(int count, int key) {
    reset_indent();
    int start = line_start(rl_point);
    int flush_left = rl_point == 0 || rl_point == start + prompt_length;
    rl_point = flush_left ? 0 : (!start ? start : start + prompt_length);
    return 0;
}
Exemplo n.º 2
0
static int line_end_callback(int count, int key) {
    reset_indent();
    int end = line_end(rl_point);
    int flush_right = rl_point == end;
    rl_point = flush_right ? rl_end : end;
    return 0;
}
Exemplo n.º 3
0
static int delete_callback(int count, int key) {
    reset_indent();
    int j = rl_point;
    j += (rl_line_buffer[j] == '\n') ? prompt_length+1 : 1;
    if (rl_end < j) j = rl_end;
    rl_delete_text(rl_point, j);
    return 0;
}
Exemplo n.º 4
0
static int right_callback(int count, int key) {
    reset_indent();
    do {
        rl_point += (rl_line_buffer[rl_point] == '\n') ? prompt_length+1 : 1;
    } while (locale_is_utf8 && !isutf(rl_line_buffer[rl_point]));
    if (rl_end < rl_point) rl_point = rl_end;
    return 0;
}
Exemplo n.º 5
0
static int left_callback(int count, int key) {
    reset_indent();
    if (rl_point > 0) {
        int i = line_start(rl_point);
        rl_point = (i == 0 || rl_point-i > prompt_length) ?
            rl_point-1 : i-1;
    }
    return 0;
}
Exemplo n.º 6
0
static int line_kill_callback(int count, int key) {
    reset_indent();
    int end = line_end(rl_point);
    int flush_right = rl_point == end;
    int kill = flush_right ? end + prompt_length + 1 : end;
    if (kill > rl_end) kill = rl_end;
    rl_kill_text(rl_point, kill);
    return 0;
}
Exemplo n.º 7
0
static int left_callback(int count, int key) {
    reset_indent();
    if (rl_point > 0) {
        int i = line_start(rl_point);
        do {
            rl_point = (i == 0 || rl_point-i > prompt_length) ? rl_point-1 : i-1;
        } while (locale_is_utf8 && !isutf(rl_line_buffer[rl_point]) && rl_point > i-1);
    }
    return 0;
}
Exemplo n.º 8
0
static int delete_callback(int count, int key) {
    reset_indent();
    int j = rl_point;
    do {
        j += (rl_line_buffer[j] == '\n') ? prompt_length+1 : 1;
    } while (locale_is_utf8 && !isutf(rl_line_buffer[j]));
    if (rl_end < j) j = rl_end;
    rl_delete_text(rl_point, j);
    return 0;
}
Exemplo n.º 9
0
static int return_callback(int count, int key) {
    add_history_temporary(rl_line_buffer);
    rl_ast = jl_parse_input_line(rl_line_buffer);
    rl_done = !rl_ast || !jl_is_expr(rl_ast) ||
        (((jl_expr_t*)rl_ast)->head != jl_continue_sym);
    if (!rl_done) {
        newline_callback(count, key);
    } else {
        reset_indent();
        rl_point = rl_end;
        rl_redisplay();
    }
    return 0;
}
Exemplo n.º 10
0
static int up_callback(int count, int key) {
    reset_indent();
    int i = line_start(rl_point);
    if (i > 0) {
        int j = line_start(i-1);
        if (j == 0) rl_point -= prompt_length;
        rl_point += j - i;
        if (rl_point >= i) rl_point = i - 1;
    } else {
        last_hist_offset = -1;
        rl_get_previous_history(count, key);
        rl_point = line_end(0);
    }
    return 0;
}
Exemplo n.º 11
0
static int down_callback(int count, int key) {
    reset_indent();
    int j = line_end(rl_point);
    if (j < rl_end) {
        int i = line_start(rl_point);
        if (i == 0) rl_point += prompt_length;
        rl_point += j - i + 1;
        int k = line_end(j+1);
        if (rl_point > k) rl_point = k;
        return 0;
    } else {
        if (last_hist_offset >= 0) {
            history_set_pos(last_hist_offset);
            last_hist_offset = -1;
        }
        return rl_get_next_history(count, key);
    }
}
Exemplo n.º 12
0
static int backspace_callback(int count, int key) {
    reset_indent();
    if (!rl_point) return 0;

    int i = line_start(rl_point), j = rl_point, k;
    if (!i || rl_point <= i + prompt_length) goto backspace;
    for (k = i; k < rl_point; k++)
        if (rl_line_buffer[k] != ' ') goto backspace;

//unindent:
    k = i + prompt_length;
    do { rl_point--; } while ((rl_point - k) % tab_width);
    goto finish;

backspace:
    rl_point = (i == 0 || rl_point-i > prompt_length) ? rl_point-1 : i-1;

finish:
    rl_delete_text(rl_point, j);
    return 0;
}
Exemplo n.º 13
0
static int return_callback(int count, int key) {
    static int consecutive_returns = 0;
    if (rl_point > prompt_length && rl_point == rl_end &&
        rl_line_buffer[rl_point-prompt_length-1] == '\n')
        consecutive_returns++;
    else
        consecutive_returns = 0;
    add_history_temporary(rl_line_buffer);
    rl_ast = jl_parse_input_line(rl_line_buffer);
    rl_done = !rl_ast || !jl_is_expr(rl_ast) ||
        (((jl_expr_t*)rl_ast)->head != jl_continue_sym) ||
        consecutive_returns > 1;
    if (!rl_done) {
        newline_callback(count, key);
    } else {
        reset_indent();
        rl_point = rl_end;
        rl_redisplay();
    }
    return 0;
}
Exemplo n.º 14
0
DLLEXPORT void jl_clear_input(void)
{
    //todo: how to do this better / the correct way / ???
    //move the cursor to a clean line:
    char *p = rl_line_buffer;
    int i;
    for (i = 0; *p != '\0'; p++, i++) {
        if (i >= rl_point && *p == '\n') {
            jl_putc('\n', jl_uv_stdout);
        }
    }
    jl_putc('\n', jl_uv_stdout);
    jl_putc('\n', jl_uv_stdout);
    //reset state:
    rl_reset_line_state();
    reset_indent();
    rl_initialize();
    //and redisplay prompt:
    rl_forced_update_display();
    rl_on_new_line_with_prompt();
#ifdef __WIN32__
    jl_write(jl_uv_stdout, "\e[4C", 4); //hack: try to fix cursor location
#endif
}
Exemplo n.º 15
0
/*
** 'list_if' deals with the 'LISTIF' command. It lists each line
** where there is at least one occurence of the string following
** the 'LISTIF' command.
*/
static void list_if(void) {
  byte *p, *tp;
  int32 targetlen, statelen;
  char first, *sp;
  boolean more;
  p = tp = get_srcaddr(basicvars.current);	/* Get address of string to search for */
  basicvars.current+=1+OFFSIZE;
  check_ateol();
  while (*p != NUL) p++;		/* Find the end of the string */
  targetlen = p-tp;		/* Number of characters in search string */
  if (targetlen == 0) return;	/* End if search string is empty */
  p = basicvars.start;
  more = TRUE;
  first = *tp;
  while (more && !AT_PROGEND(p)) {
    reset_indent();
    expand(p, basicvars.stringwork);
    sp = basicvars.stringwork;
    statelen = strlen(basicvars.stringwork);
    do {
      sp++;
      while (statelen>=targetlen && *sp != first) {
        statelen--;
        sp++;
      }
    } while(statelen>=targetlen && memcmp(sp, tp, targetlen) != 0);
    if (statelen>=targetlen) {	/* Can only be true if the string was found */
      if (basicvars.debug_flags.tokens)
        emulate_printf("%08p  %s\r\n", p, basicvars.stringwork);
      else {
        emulate_printf("%s\r\n", basicvars.stringwork);
      }
    }
    p+=GET_LINELEN(p);
  }
}
Exemplo n.º 16
0
static int right_callback(int count, int key) {
    reset_indent();
    rl_point += (rl_line_buffer[rl_point] == '\n') ? prompt_length+1 : 1;
    if (rl_end < rl_point) rl_point = rl_end;
    return 0;
}