WIP: Vulkan: Workbench #107886
|
@ -1137,10 +1137,6 @@ void DRW_draw_region_engine_info(int xoffset, int *yoffset, int line_height)
|
|||
{
|
||||
DRW_ENABLED_ENGINE_ITER (DST.view_data_active, engine, data) {
|
||||
if (data->info[0] != '\0') {
|
||||
char *chr_current = data->info;
|
||||
char *chr_start = chr_current;
|
||||
int line_len = 0;
|
||||
|
||||
const int font_id = BLF_default();
|
||||
UI_FontThemeColor(font_id, TH_TEXT_HI);
|
||||
|
||||
|
@ -1148,24 +1144,14 @@ void DRW_draw_region_engine_info(int xoffset, int *yoffset, int line_height)
|
|||
BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f});
|
||||
BLF_shadow_offset(font_id, 1, -1);
|
||||
|
||||
while (*chr_current++ != '\0') {
|
||||
line_len++;
|
||||
if (*chr_current == '\n') {
|
||||
char info[GPU_INFO_SIZE];
|
||||
BLI_strncpy(info, chr_start, line_len + 1);
|
||||
*yoffset -= line_height;
|
||||
BLF_draw_default(xoffset, *yoffset, 0.0f, info, sizeof(info));
|
||||
|
||||
/* Re-start counting. */
|
||||
chr_start = chr_current + 1;
|
||||
line_len = -1;
|
||||
}
|
||||
}
|
||||
|
||||
char info[GPU_INFO_SIZE];
|
||||
BLI_strncpy(info, chr_start, line_len + 1);
|
||||
*yoffset -= line_height;
|
||||
BLF_draw_default(xoffset, *yoffset, 0.0f, info, sizeof(info));
|
||||
const char *buf_step = data->info;
|
||||
do {
|
||||
const char *buf = buf_step;
|
||||
buf_step = BLI_strchr_or_end(buf, '\n');
|
||||
const int buf_len = buf_step - buf;
|
||||
*yoffset -= line_height;
|
||||
BLF_draw_default(xoffset, *yoffset, 0.0f, buf, buf_len);
|
||||
} while (*buf_step ? ((void)buf_step++, true) : false);
|
||||
|
||||
BLF_disable(font_id, BLF_SHADOW);
|
||||
}
|
||||
|
|
|
@ -596,12 +596,8 @@ size_t ui_but_tip_len_only_first_line(const uiBut *but)
|
|||
if (but->tip == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *str_sep = strchr(but->tip, '\n');
|
||||
if (str_sep != nullptr) {
|
||||
return (str_sep - but->tip);
|
||||
}
|
||||
return strlen(but->tip);
|
||||
const char *str_sep = BLI_strchr_or_end(but->tip, '\n');
|
||||
return (str_sep - but->tip);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
@ -304,19 +305,16 @@ static void console_line_verify_length(ConsoleLine *ci, int len)
|
|||
}
|
||||
}
|
||||
|
||||
static int console_line_insert(ConsoleLine *ci, char *str)
|
||||
static void console_line_insert(ConsoleLine *ci, const char *str, int len)
|
||||
{
|
||||
int len = strlen(str);
|
||||
|
||||
if (len > 0 && str[len - 1] == '\n') { /* stop new lines being pasted at the end of lines */
|
||||
str[len - 1] = '\0';
|
||||
len--;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
BLI_assert(len <= strlen(str));
|
||||
/* The caller must delimit new-lines. */
|
||||
BLI_assert(str[len - 1] != '\n');
|
||||
|
||||
console_line_verify_length(ci, len + ci->len);
|
||||
|
||||
memmove(ci->line + ci->cursor + len, ci->line + ci->cursor, (ci->len - ci->cursor) + 1);
|
||||
|
@ -324,8 +322,6 @@ static int console_line_insert(ConsoleLine *ci, char *str)
|
|||
|
||||
ci->len += len;
|
||||
ci->cursor += len;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -460,8 +456,25 @@ static int console_insert_exec(bContext *C, wmOperator *op)
|
|||
memset(str, ' ', len);
|
||||
str[len] = '\0';
|
||||
}
|
||||
else {
|
||||
len = strlen(str);
|
||||
}
|
||||
|
||||
len = console_line_insert(ci, str);
|
||||
/* Allow trailing newlines (but strip them). */
|
||||
while (len > 0 && str[len - 1] == '\n') {
|
||||
len--;
|
||||
str[len] = '\0';
|
||||
}
|
||||
|
||||
if (strchr(str, '\n')) {
|
||||
BKE_report(op->reports, RPT_ERROR, "New lines unsupported, call this operator multiple times");
|
||||
/* Force cancel. */
|
||||
len = 0;
|
||||
}
|
||||
|
||||
if (len != 0) {
|
||||
console_line_insert(ci, str, len);
|
||||
}
|
||||
|
||||
MEM_freeN(str);
|
||||
|
||||
|
@ -1076,31 +1089,28 @@ static int console_paste_exec(bContext *C, wmOperator *op)
|
|||
SpaceConsole *sc = CTX_wm_space_console(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
ConsoleLine *ci = console_history_verify(C);
|
||||
int buf_len;
|
||||
|
||||
char *buf_str = WM_clipboard_text_get(selection, true, &buf_len);
|
||||
char *buf_step, *buf_next;
|
||||
int buf_str_len;
|
||||
|
||||
char *buf_str = WM_clipboard_text_get(selection, true, &buf_str_len);
|
||||
if (buf_str == NULL) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
buf_step = buf_str;
|
||||
|
||||
while ((buf_next = buf_step) && buf_next[0] != '\0') {
|
||||
buf_step = strchr(buf_next, '\n');
|
||||
if (buf_step) {
|
||||
*buf_step = '\0';
|
||||
buf_step++;
|
||||
}
|
||||
|
||||
if (buf_next != buf_str) {
|
||||
if (*buf_str == '\0') {
|
||||
MEM_freeN(buf_str);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
const char *buf_step = buf_str;
|
||||
do {
|
||||
const char *buf = buf_step;
|
||||
buf_step = (char *)BLI_strchr_or_end(buf, '\n');
|
||||
const int buf_len = buf_step - buf;
|
||||
if (buf != buf_str) {
|
||||
WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL, NULL);
|
||||
ci = console_history_verify(C);
|
||||
}
|
||||
|
||||
console_select_offset(sc, console_line_insert(ci, buf_next));
|
||||
}
|
||||
console_line_insert(ci, buf, buf_len);
|
||||
console_select_offset(sc, buf_len);
|
||||
} while (*buf_step ? ((void)buf_step++, true) : false);
|
||||
|
||||
MEM_freeN(buf_str);
|
||||
|
||||
|
|
Loading…
Reference in New Issue