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 */
|
/* return 0 if no change made, clamps the range */
|
||||||
static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
|
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 */
|
const bool reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */
|
||||||
int prev_len = ci->len;
|
int prev_len = ci->len;
|
||||||
|
|
||||||
/* keep a copy of the line above so when history is cycled
|
int old_index = sc->history_index;
|
||||||
* this is the only function that needs to know about the double-up */
|
int new_index;
|
||||||
if (ci->prev) {
|
if (reverse) {
|
||||||
ConsoleLine *ci_prev = (ConsoleLine *)ci->prev;
|
if (old_index <= 0) {
|
||||||
|
new_index = 1;
|
||||||
if (STREQ(ci->line, ci_prev->line)) {
|
|
||||||
console_history_free(sc, ci_prev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reverse) { /* last item in history */
|
|
||||||
ci = static_cast<ConsoleLine *>(sc->history.last);
|
|
||||||
BLI_remlink(&sc->history, ci);
|
|
||||||
BLI_addhead(&sc->history, ci);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ci = static_cast<ConsoleLine *>(sc->history.first);
|
new_index = old_index + 1;
|
||||||
BLI_remlink(&sc->history, ci);
|
}
|
||||||
BLI_addtail(&sc->history, ci);
|
}
|
||||||
|
else {
|
||||||
|
if (old_index <= 0) { /* Down-arrow after exec. */
|
||||||
|
new_index = -old_index;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
new_index = old_index - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{ /* add a duplicate of the new arg and remove all other instances */
|
/* Find the history item. */
|
||||||
ConsoleLine *cl;
|
ConsoleLine *ci_prev = ci;
|
||||||
while ((cl = console_history_find(sc, ci->line, ci))) {
|
if (old_index > 0) {
|
||||||
console_history_free(sc, cl);
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
console_history_add(sc, (ConsoleLine *)sc->history.last);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
ci = static_cast<ConsoleLine *>(sc->history.last);
|
|
||||||
console_select_offset(sc, ci->len - prev_len);
|
console_select_offset(sc, ci->len - prev_len);
|
||||||
|
|
||||||
/* could be wrapped so update scroll rect */
|
/* 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");
|
const bool rem_dupes = RNA_boolean_get(op->ptr, "remove_duplicates");
|
||||||
int prev_len = ci->len;
|
int prev_len = ci->len;
|
||||||
|
|
||||||
if (rem_dupes) {
|
if (sc->history_index > 0) {
|
||||||
ConsoleLine *cl;
|
/* Keep the copy of history item, remove the saved "history 0". */
|
||||||
|
ConsoleLine *cl = ci->prev;
|
||||||
while ((cl = console_history_find(sc, ci->line, ci))) {
|
if (cl) {
|
||||||
console_history_free(sc, 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)) {
|
if (STREQ(str, ci->line)) {
|
||||||
MEM_freeN(str);
|
MEM_freeN(str);
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
|
|
|
@ -1699,9 +1699,7 @@ typedef struct SpaceConsole {
|
||||||
char _pad0[6];
|
char _pad0[6];
|
||||||
/* End 'SpaceLink' header. */
|
/* End 'SpaceLink' header. */
|
||||||
|
|
||||||
/* space vars */
|
/* Space variables. */
|
||||||
int lheight;
|
|
||||||
char _pad[4];
|
|
||||||
|
|
||||||
/** ConsoleLine; output. */
|
/** ConsoleLine; output. */
|
||||||
ListBase scrollback;
|
ListBase scrollback;
|
||||||
|
@ -1711,6 +1709,11 @@ typedef struct SpaceConsole {
|
||||||
/** Multiple consoles are possible, not just python. */
|
/** Multiple consoles are possible, not just python. */
|
||||||
char language[32];
|
char language[32];
|
||||||
|
|
||||||
|
int lheight;
|
||||||
|
|
||||||
|
/** Index into history of most recent up/down arrow keys. */
|
||||||
|
int history_index;
|
||||||
|
|
||||||
/** Selection offset in bytes. */
|
/** Selection offset in bytes. */
|
||||||
int sel_start;
|
int sel_start;
|
||||||
int sel_end;
|
int sel_end;
|
||||||
|
|
Loading…
Reference in New Issue