Merge branch 'blender-v4.1-release'
This commit is contained in:
commit
6e497434ba
|
@ -183,21 +183,6 @@ static void console_scrollback_limit(SpaceConsole *sc)
|
|||
}
|
||||
}
|
||||
|
||||
static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore)
|
||||
{
|
||||
LISTBASE_FOREACH_BACKWARD (ConsoleLine *, cl, &sc->history) {
|
||||
if (cl == cl_ignore) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (STREQ(str, cl->line)) {
|
||||
return cl;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* return 0 if no change made, clamps the range */
|
||||
static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
|
||||
{
|
||||
|
@ -934,37 +919,54 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op)
|
|||
const bool reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */
|
||||
int prev_len = ci->len;
|
||||
|
||||
/* keep a copy of the line above so when history is cycled
|
||||
* this is the only function that needs to know about the double-up */
|
||||
if (ci->prev) {
|
||||
ConsoleLine *ci_prev = (ConsoleLine *)ci->prev;
|
||||
|
||||
if (STREQ(ci->line, ci_prev->line)) {
|
||||
console_history_free(sc, ci_prev);
|
||||
int old_index = sc->history_index;
|
||||
int new_index;
|
||||
if (reverse) {
|
||||
if (old_index <= 0) {
|
||||
new_index = 1;
|
||||
}
|
||||
else {
|
||||
new_index = old_index + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (reverse) { /* last item in history */
|
||||
ci = static_cast<ConsoleLine *>(sc->history.last);
|
||||
BLI_remlink(&sc->history, ci);
|
||||
BLI_addhead(&sc->history, ci);
|
||||
}
|
||||
else {
|
||||
ci = static_cast<ConsoleLine *>(sc->history.first);
|
||||
BLI_remlink(&sc->history, ci);
|
||||
BLI_addtail(&sc->history, ci);
|
||||
}
|
||||
|
||||
{ /* add a duplicate of the new arg and remove all other instances */
|
||||
ConsoleLine *cl;
|
||||
while ((cl = console_history_find(sc, ci->line, ci))) {
|
||||
console_history_free(sc, cl);
|
||||
if (old_index <= 0) { /* Down-arrow after exec. */
|
||||
new_index = -old_index;
|
||||
}
|
||||
else {
|
||||
new_index = old_index - 1;
|
||||
}
|
||||
|
||||
console_history_add(sc, (ConsoleLine *)sc->history.last);
|
||||
}
|
||||
|
||||
ci = static_cast<ConsoleLine *>(sc->history.last);
|
||||
/* Find the history item. */
|
||||
ConsoleLine *ci_prev = ci;
|
||||
if (old_index > 0) {
|
||||
/* Skip a previous copy of history item. */
|
||||
if (ci_prev->prev) {
|
||||
ci_prev = ci_prev->prev;
|
||||
}
|
||||
else { /* Just in case the duplicate item got deleted. */
|
||||
old_index = 0;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < new_index; i++) {
|
||||
if (!ci_prev->prev) {
|
||||
new_index = i;
|
||||
break;
|
||||
}
|
||||
ci_prev = ci_prev->prev;
|
||||
}
|
||||
|
||||
sc->history_index = new_index;
|
||||
|
||||
if (old_index > 0) { /* Remove old copy. */
|
||||
console_history_free(sc, ci);
|
||||
ci = ci_prev;
|
||||
}
|
||||
if (new_index > 0) { /* Copy history item to the end. */
|
||||
ci = console_history_add(sc, ci_prev);
|
||||
}
|
||||
|
||||
console_select_offset(sc, ci->len - prev_len);
|
||||
|
||||
/* could be wrapped so update scroll rect */
|
||||
|
@ -1005,13 +1007,23 @@ static int console_history_append_exec(bContext *C, wmOperator *op)
|
|||
const bool rem_dupes = RNA_boolean_get(op->ptr, "remove_duplicates");
|
||||
int prev_len = ci->len;
|
||||
|
||||
if (rem_dupes) {
|
||||
ConsoleLine *cl;
|
||||
|
||||
while ((cl = console_history_find(sc, ci->line, ci))) {
|
||||
if (sc->history_index > 0) {
|
||||
/* Keep the copy of history item, remove the saved "history 0". */
|
||||
ConsoleLine *cl = ci->prev;
|
||||
if (cl) {
|
||||
console_history_free(sc, cl);
|
||||
}
|
||||
/* Negative number makes down-arrow go to same item as before. */
|
||||
sc->history_index = -sc->history_index;
|
||||
}
|
||||
|
||||
if (rem_dupes) {
|
||||
/* Remove a repeated command. */
|
||||
ConsoleLine *cl = ci->prev;
|
||||
if (cl && STREQ(cl->line, ci->line)) {
|
||||
console_history_free(sc, cl);
|
||||
}
|
||||
/* Remove blank command. */
|
||||
if (STREQ(str, ci->line)) {
|
||||
MEM_freeN(str);
|
||||
return OPERATOR_FINISHED;
|
||||
|
|
|
@ -1699,9 +1699,7 @@ typedef struct SpaceConsole {
|
|||
char _pad0[6];
|
||||
/* End 'SpaceLink' header. */
|
||||
|
||||
/* space vars */
|
||||
int lheight;
|
||||
char _pad[4];
|
||||
/* Space variables. */
|
||||
|
||||
/** ConsoleLine; output. */
|
||||
ListBase scrollback;
|
||||
|
@ -1711,6 +1709,11 @@ typedef struct SpaceConsole {
|
|||
/** Multiple consoles are possible, not just python. */
|
||||
char language[32];
|
||||
|
||||
int lheight;
|
||||
|
||||
/** Index into history of most recent up/down arrow keys. */
|
||||
int history_index;
|
||||
|
||||
/** Selection offset in bytes. */
|
||||
int sel_start;
|
||||
int sel_end;
|
||||
|
|
Loading…
Reference in New Issue