Cleanup: move space_console & space_info to C++
This commit is contained in:
@@ -22,11 +22,11 @@ set(INC_SYS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
console_draw.c
|
||||
console_ops.c
|
||||
space_console.c
|
||||
console_draw.cc
|
||||
console_ops.cc
|
||||
space_console.cc
|
||||
|
||||
console_intern.h
|
||||
console_intern.hh
|
||||
)
|
||||
|
||||
set(LIB
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* \ingroup spconsole
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_utildefines.h"
|
||||
@@ -22,18 +22,18 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "console_intern.h"
|
||||
#include "console_intern.hh"
|
||||
|
||||
#include "../space_info/textview.h"
|
||||
#include "../space_info/textview.hh"
|
||||
|
||||
static enum eTextViewContext_LineFlag console_line_data(TextViewContext *tvc,
|
||||
uchar fg[4],
|
||||
uchar UNUSED(bg[4]),
|
||||
int *UNUSED(icon),
|
||||
uchar UNUSED(icon_fg[4]),
|
||||
uchar UNUSED(icon_bg[4]))
|
||||
uchar /*bg*/[4],
|
||||
int * /*icon*/,
|
||||
uchar /*icon_fg*/[4],
|
||||
uchar /*icon_bg*/[4])
|
||||
{
|
||||
const ConsoleLine *cl_iter = tvc->iter;
|
||||
const ConsoleLine *cl_iter = static_cast<const ConsoleLine *>(tvc->iter);
|
||||
int fg_id = TH_TEXT;
|
||||
|
||||
switch (cl_iter->type) {
|
||||
@@ -58,13 +58,13 @@ static enum eTextViewContext_LineFlag console_line_data(TextViewContext *tvc,
|
||||
void console_scrollback_prompt_begin(SpaceConsole *sc, ConsoleLine *cl_dummy)
|
||||
{
|
||||
/* fake the edit line being in the scroll buffer */
|
||||
ConsoleLine *cl = sc->history.last;
|
||||
ConsoleLine *cl = static_cast<ConsoleLine *>(sc->history.last);
|
||||
int prompt_len = strlen(sc->prompt);
|
||||
|
||||
cl_dummy->type = CONSOLE_LINE_INPUT;
|
||||
cl_dummy->len = prompt_len + cl->len;
|
||||
cl_dummy->len_alloc = cl_dummy->len + 1;
|
||||
cl_dummy->line = MEM_mallocN(cl_dummy->len_alloc, "cl_dummy");
|
||||
cl_dummy->line = static_cast<char *>(MEM_mallocN(cl_dummy->len_alloc, "cl_dummy"));
|
||||
memcpy(cl_dummy->line, sc->prompt, prompt_len);
|
||||
memcpy(cl_dummy->line + prompt_len, cl->line, cl->len + 1);
|
||||
BLI_addtail(&sc->scrollback, cl_dummy);
|
||||
@@ -85,7 +85,7 @@ static int console_textview_begin(TextViewContext *tvc)
|
||||
/* iterator */
|
||||
tvc->iter = sc->scrollback.last;
|
||||
|
||||
return (tvc->iter != NULL);
|
||||
return (tvc->iter != nullptr);
|
||||
}
|
||||
|
||||
static void console_textview_end(TextViewContext *tvc)
|
||||
@@ -96,12 +96,12 @@ static void console_textview_end(TextViewContext *tvc)
|
||||
|
||||
static int console_textview_step(TextViewContext *tvc)
|
||||
{
|
||||
return ((tvc->iter = (void *)((Link *)tvc->iter)->prev) != NULL);
|
||||
return ((tvc->iter = (void *)((Link *)tvc->iter)->prev) != nullptr);
|
||||
}
|
||||
|
||||
static void console_textview_line_get(TextViewContext *tvc, const char **r_line, int *r_len)
|
||||
{
|
||||
const ConsoleLine *cl = tvc->iter;
|
||||
const ConsoleLine *cl = static_cast<const ConsoleLine *>(tvc->iter);
|
||||
*r_line = cl->line;
|
||||
*r_len = cl->len;
|
||||
// printf("'%s' %d\n", *line, cl->len);
|
||||
@@ -137,12 +137,12 @@ static void console_textview_draw_cursor(TextViewContext *tvc, int cwidth, int c
|
||||
const ConsoleLine *cl = (ConsoleLine *)sc->history.last;
|
||||
int offl = 0, offc = 0;
|
||||
|
||||
console_cursor_wrap_offset(sc->prompt, columns, &offl, &offc, NULL);
|
||||
console_cursor_wrap_offset(sc->prompt, columns, &offl, &offc, nullptr);
|
||||
console_cursor_wrap_offset(cl->line, columns, &offl, &offc, cl->line + cl->cursor);
|
||||
pen[0] = cwidth * offc;
|
||||
pen[1] = -tvc->lheight * offl;
|
||||
|
||||
console_cursor_wrap_offset(cl->line + cl->cursor, columns, &offl, &offc, NULL);
|
||||
console_cursor_wrap_offset(cl->line + cl->cursor, columns, &offl, &offc, nullptr);
|
||||
pen[1] += tvc->lheight * offl;
|
||||
|
||||
pen[0] += tvc->draw_rect.xmin;
|
||||
@@ -160,7 +160,7 @@ static void console_textview_draw_cursor(TextViewContext *tvc, int cwidth, int c
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
static void console_textview_const_colors(TextViewContext *UNUSED(tvc), uchar bg_sel[4])
|
||||
static void console_textview_const_colors(TextViewContext * /*tvc*/, uchar bg_sel[4])
|
||||
{
|
||||
UI_GetThemeColor4ubv(TH_CONSOLE_SELECT, bg_sel);
|
||||
}
|
||||
@@ -189,7 +189,7 @@ static int console_textview_main__internal(SpaceConsole *sc,
|
||||
void **r_mval_pick_item,
|
||||
int *r_mval_pick_offset)
|
||||
{
|
||||
ConsoleLine cl_dummy = {NULL};
|
||||
ConsoleLine cl_dummy = {nullptr};
|
||||
int ret = 0;
|
||||
|
||||
const View2D *v2d = ®ion->v2d;
|
||||
@@ -206,7 +206,7 @@ static int console_textview_main__internal(SpaceConsole *sc,
|
||||
tvc.const_colors = console_textview_const_colors;
|
||||
|
||||
tvc.arg1 = sc;
|
||||
tvc.arg2 = NULL;
|
||||
tvc.arg2 = nullptr;
|
||||
|
||||
/* view */
|
||||
tvc.sel_start = sc->sel_start;
|
||||
@@ -227,19 +227,19 @@ static int console_textview_main__internal(SpaceConsole *sc,
|
||||
void console_textview_main(SpaceConsole *sc, const ARegion *region)
|
||||
{
|
||||
const int mval[2] = {INT_MAX, INT_MAX};
|
||||
console_textview_main__internal(sc, region, true, mval, NULL, NULL);
|
||||
console_textview_main__internal(sc, region, true, mval, nullptr, nullptr);
|
||||
}
|
||||
|
||||
int console_textview_height(SpaceConsole *sc, const ARegion *region)
|
||||
{
|
||||
const int mval[2] = {INT_MAX, INT_MAX};
|
||||
return console_textview_main__internal(sc, region, false, mval, NULL, NULL);
|
||||
return console_textview_main__internal(sc, region, false, mval, nullptr, nullptr);
|
||||
}
|
||||
|
||||
int console_char_pick(SpaceConsole *sc, const ARegion *region, const int mval[2])
|
||||
{
|
||||
int r_mval_pick_offset = 0;
|
||||
void *mval_pick_item = NULL;
|
||||
void *mval_pick_item = nullptr;
|
||||
|
||||
console_textview_main__internal(sc, region, false, mval, &mval_pick_item, &r_mval_pick_offset);
|
||||
return r_mval_pick_offset;
|
||||
@@ -6,9 +6,9 @@
|
||||
* \ingroup spconsole
|
||||
*/
|
||||
|
||||
#include <ctype.h> /* #ispunct */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cctype> /* #ispunct */
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
|
||||
#include "console_intern.h"
|
||||
#include "console_intern.hh"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Utilities
|
||||
@@ -44,23 +44,23 @@
|
||||
static char *console_select_to_buffer(SpaceConsole *sc)
|
||||
{
|
||||
if (sc->sel_start == sc->sel_end) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ConsoleLine cl_dummy = {NULL};
|
||||
ConsoleLine cl_dummy = {nullptr};
|
||||
console_scrollback_prompt_begin(sc, &cl_dummy);
|
||||
|
||||
int offset = 0;
|
||||
for (ConsoleLine *cl = sc->scrollback.first; cl; cl = cl->next) {
|
||||
for (ConsoleLine *cl = static_cast<ConsoleLine *>(sc->scrollback.first); cl; cl = cl->next) {
|
||||
offset += cl->len + 1;
|
||||
}
|
||||
|
||||
char *buf_str = NULL;
|
||||
char *buf_str = nullptr;
|
||||
if (offset != 0) {
|
||||
offset -= 1;
|
||||
int sel[2] = {offset - sc->sel_end, offset - sc->sel_start};
|
||||
DynStr *buf_dyn = BLI_dynstr_new();
|
||||
for (ConsoleLine *cl = sc->scrollback.first; cl; cl = cl->next) {
|
||||
for (ConsoleLine *cl = static_cast<ConsoleLine *>(sc->scrollback.first); cl; cl = cl->next) {
|
||||
if (sel[0] <= cl->len && sel[1] >= 0) {
|
||||
int sta = max_ii(sel[0], 0);
|
||||
int end = min_ii(sel[1], cl->len);
|
||||
@@ -94,7 +94,7 @@ static void console_select_update_primary_clipboard(SpaceConsole *sc)
|
||||
return;
|
||||
}
|
||||
char *buf = console_select_to_buffer(sc);
|
||||
if (buf == NULL) {
|
||||
if (buf == nullptr) {
|
||||
return;
|
||||
}
|
||||
WM_clipboard_text_set(buf, true);
|
||||
@@ -108,7 +108,7 @@ static void console_scroll_bottom(ARegion *region)
|
||||
{
|
||||
View2D *v2d = ®ion->v2d;
|
||||
v2d->cur.ymin = 0.0;
|
||||
v2d->cur.ymax = (float)v2d->winy;
|
||||
v2d->cur.ymax = float(v2d->winy);
|
||||
}
|
||||
|
||||
void console_textview_update_rect(SpaceConsole *sc, ARegion *region)
|
||||
@@ -142,7 +142,7 @@ static void console_scrollback_limit(SpaceConsole *sc)
|
||||
int tot;
|
||||
|
||||
for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) {
|
||||
console_scrollback_free(sc, sc->scrollback.first);
|
||||
console_scrollback_free(sc, static_cast<ConsoleLine *>(sc->scrollback.first));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, Cons
|
||||
{
|
||||
ConsoleLine *cl;
|
||||
|
||||
for (cl = sc->history.last; cl; cl = cl->prev) {
|
||||
for (cl = static_cast<ConsoleLine *>(sc->history.last); cl; cl = cl->prev) {
|
||||
if (cl == cl_ignore) {
|
||||
continue;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, Cons
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* return 0 if no change made, clamps the range */
|
||||
@@ -208,7 +208,8 @@ static void console_history_debug(const bContext *C)
|
||||
|
||||
static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from)
|
||||
{
|
||||
ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
|
||||
ConsoleLine *ci = static_cast<ConsoleLine *>(
|
||||
MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"));
|
||||
|
||||
if (from) {
|
||||
BLI_assert(strlen(from->line) == from->len);
|
||||
@@ -218,7 +219,7 @@ static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from)
|
||||
ci->type = from->type;
|
||||
}
|
||||
else {
|
||||
ci->line = MEM_callocN(64, "console-in-line");
|
||||
ci->line = static_cast<char *>(MEM_callocN(64, "console-in-line"));
|
||||
ci->len_alloc = 64;
|
||||
ci->len = 0;
|
||||
}
|
||||
@@ -243,7 +244,8 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
|
||||
|
||||
static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, bool own)
|
||||
{
|
||||
ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
|
||||
ConsoleLine *ci = static_cast<ConsoleLine *>(
|
||||
MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"));
|
||||
if (own) {
|
||||
ci->line = str;
|
||||
}
|
||||
@@ -270,9 +272,9 @@ ConsoleLine *console_scrollback_add_str(SpaceConsole *sc, char *str, bool own)
|
||||
ConsoleLine *console_history_verify(const bContext *C)
|
||||
{
|
||||
SpaceConsole *sc = CTX_wm_space_console(C);
|
||||
ConsoleLine *ci = sc->history.last;
|
||||
if (ci == NULL) {
|
||||
ci = console_history_add(sc, NULL);
|
||||
ConsoleLine *ci = static_cast<ConsoleLine *>(sc->history.last);
|
||||
if (ci == nullptr) {
|
||||
ci = console_history_add(sc, nullptr);
|
||||
}
|
||||
|
||||
return ci;
|
||||
@@ -288,7 +290,7 @@ static void console_line_verify_length(ConsoleLine *ci, int len)
|
||||
#else
|
||||
int new_len = (len + 1) * 2;
|
||||
#endif
|
||||
ci->line = MEM_recallocN_id(ci->line, new_len, "console line");
|
||||
ci->line = static_cast<char *>(MEM_recallocN_id(ci->line, new_len, "console line"));
|
||||
ci->len_alloc = new_len;
|
||||
}
|
||||
}
|
||||
@@ -323,7 +325,7 @@ static bool console_line_column_from_index(
|
||||
ConsoleLine *cl;
|
||||
int offset = 0;
|
||||
|
||||
for (cl = sc->scrollback.last; cl; cl = cl->prev) {
|
||||
for (cl = static_cast<ConsoleLine *>(sc->scrollback.last); cl; cl = cl->prev) {
|
||||
offset += cl->len + 1;
|
||||
if (offset >= pos) {
|
||||
break;
|
||||
@@ -338,7 +340,7 @@ static bool console_line_column_from_index(
|
||||
return true;
|
||||
}
|
||||
|
||||
*r_cl = NULL;
|
||||
*r_cl = nullptr;
|
||||
*r_cl_offset = -1;
|
||||
*r_col = -1;
|
||||
return false;
|
||||
@@ -354,7 +356,7 @@ static const EnumPropertyItem console_move_type_items[] = {
|
||||
{NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
|
||||
{PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
|
||||
{NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static int console_move_exec(bContext *C, wmOperator *op)
|
||||
@@ -434,13 +436,13 @@ static int console_insert_exec(bContext *C, wmOperator *op)
|
||||
SpaceConsole *sc = CTX_wm_space_console(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
ConsoleLine *ci = console_history_verify(C);
|
||||
char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0, NULL);
|
||||
char *str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, nullptr);
|
||||
int len;
|
||||
|
||||
if (str[0] == '\t' && str[1] == '\0') {
|
||||
len = TAB_LENGTH;
|
||||
MEM_freeN(str);
|
||||
str = MEM_mallocN(len + 1, "insert_exec");
|
||||
str = static_cast<char *>(MEM_mallocN(len + 1, "insert_exec"));
|
||||
memset(str, ' ', len);
|
||||
str[len] = '\0';
|
||||
}
|
||||
@@ -518,7 +520,7 @@ void CONSOLE_OT_insert(wmOperatorType *ot)
|
||||
|
||||
/* properties */
|
||||
prop = RNA_def_string(
|
||||
ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position");
|
||||
ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
}
|
||||
|
||||
@@ -526,7 +528,7 @@ void CONSOLE_OT_insert(wmOperatorType *ot)
|
||||
/** \name Indent or Autocomplete Operator
|
||||
* \{ */
|
||||
|
||||
static int console_indent_or_autocomplete_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int console_indent_or_autocomplete_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
ConsoleLine *ci = console_history_verify(C);
|
||||
bool text_before_cursor = false;
|
||||
@@ -542,10 +544,10 @@ static int console_indent_or_autocomplete_exec(bContext *C, wmOperator *UNUSED(o
|
||||
}
|
||||
|
||||
if (text_before_cursor) {
|
||||
WM_operator_name_call(C, "CONSOLE_OT_autocomplete", WM_OP_INVOKE_DEFAULT, NULL, NULL);
|
||||
WM_operator_name_call(C, "CONSOLE_OT_autocomplete", WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
|
||||
}
|
||||
else {
|
||||
WM_operator_name_call(C, "CONSOLE_OT_indent", WM_OP_EXEC_DEFAULT, NULL, NULL);
|
||||
WM_operator_name_call(C, "CONSOLE_OT_indent", WM_OP_EXEC_DEFAULT, nullptr, nullptr);
|
||||
}
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -571,7 +573,7 @@ void CONSOLE_OT_indent_or_autocomplete(wmOperatorType *ot)
|
||||
/** \name Indent Operator
|
||||
* \{ */
|
||||
|
||||
static int console_indent_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int console_indent_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceConsole *sc = CTX_wm_space_console(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
@@ -618,7 +620,7 @@ void CONSOLE_OT_indent(wmOperatorType *ot)
|
||||
|
||||
/** \} */
|
||||
|
||||
static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int console_unindent_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceConsole *sc = CTX_wm_space_console(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
@@ -675,7 +677,7 @@ static const EnumPropertyItem console_delete_type_items[] = {
|
||||
{DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
|
||||
{DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
|
||||
{DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static int console_delete_exec(bContext *C, wmOperator *op)
|
||||
@@ -773,7 +775,7 @@ void CONSOLE_OT_delete(wmOperatorType *ot)
|
||||
"Which part of the text to delete");
|
||||
}
|
||||
|
||||
static int console_clear_line_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int console_clear_line_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceConsole *sc = CTX_wm_space_console(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
@@ -784,7 +786,7 @@ static int console_clear_line_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
}
|
||||
|
||||
console_history_add(sc, ci);
|
||||
console_history_add(sc, NULL);
|
||||
console_history_add(sc, nullptr);
|
||||
console_select_offset(sc, -ci->len);
|
||||
|
||||
console_textview_update_rect(sc, region);
|
||||
@@ -821,13 +823,13 @@ static int console_clear_exec(bContext *C, wmOperator *op)
|
||||
|
||||
if (scrollback) { /* Last item in history. */
|
||||
while (sc->scrollback.first) {
|
||||
console_scrollback_free(sc, sc->scrollback.first);
|
||||
console_scrollback_free(sc, static_cast<ConsoleLine *>(sc->scrollback.first));
|
||||
}
|
||||
}
|
||||
|
||||
if (history) {
|
||||
while (sc->history.first) {
|
||||
console_history_free(sc, sc->history.first);
|
||||
console_history_free(sc, static_cast<ConsoleLine *>(sc->history.first));
|
||||
}
|
||||
console_history_verify(C);
|
||||
}
|
||||
@@ -850,8 +852,8 @@ void CONSOLE_OT_clear(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_console_active;
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean(ot->srna, "scrollback", 1, "Scrollback", "Clear the scrollback history");
|
||||
RNA_def_boolean(ot->srna, "history", 0, "History", "Clear the command history");
|
||||
RNA_def_boolean(ot->srna, "scrollback", true, "Scrollback", "Clear the scrollback history");
|
||||
RNA_def_boolean(ot->srna, "history", false, "History", "Clear the command history");
|
||||
}
|
||||
|
||||
/* the python exec operator uses this */
|
||||
@@ -876,12 +878,12 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
if (reverse) { /* last item in history */
|
||||
ci = sc->history.last;
|
||||
ci = static_cast<ConsoleLine *>(sc->history.last);
|
||||
BLI_remlink(&sc->history, ci);
|
||||
BLI_addhead(&sc->history, ci);
|
||||
}
|
||||
else {
|
||||
ci = sc->history.first;
|
||||
ci = static_cast<ConsoleLine *>(sc->history.first);
|
||||
BLI_remlink(&sc->history, ci);
|
||||
BLI_addtail(&sc->history, ci);
|
||||
}
|
||||
@@ -895,7 +897,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op)
|
||||
console_history_add(sc, (ConsoleLine *)sc->history.last);
|
||||
}
|
||||
|
||||
ci = sc->history.last;
|
||||
ci = static_cast<ConsoleLine *>(sc->history.last);
|
||||
console_select_offset(sc, ci->len - prev_len);
|
||||
|
||||
/* could be wrapped so update scroll rect */
|
||||
@@ -919,7 +921,7 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_console_active;
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean(ot->srna, "reverse", 0, "Reverse", "Reverse cycle history");
|
||||
RNA_def_boolean(ot->srna, "reverse", false, "Reverse", "Reverse cycle history");
|
||||
}
|
||||
|
||||
/* the python exec operator uses this */
|
||||
@@ -930,7 +932,7 @@ static int console_history_append_exec(bContext *C, wmOperator *op)
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
ConsoleLine *ci = console_history_verify(C);
|
||||
/* own this text in the new line, don't free */
|
||||
char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0, NULL);
|
||||
char *str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, nullptr);
|
||||
int cursor = RNA_int_get(op->ptr, "current_character");
|
||||
const bool rem_dupes = RNA_boolean_get(op->ptr, "remove_duplicates");
|
||||
int prev_len = ci->len;
|
||||
@@ -948,7 +950,7 @@ static int console_history_append_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
ci = console_history_add_str(sc, str, 1); /* own the string */
|
||||
ci = console_history_add_str(sc, str, true); /* own the string */
|
||||
console_select_offset(sc, ci->len - prev_len);
|
||||
console_line_cursor_set(ci, cursor);
|
||||
|
||||
@@ -975,12 +977,12 @@ void CONSOLE_OT_history_append(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_console_active;
|
||||
|
||||
/* properties */
|
||||
RNA_def_string(ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position");
|
||||
RNA_def_string(ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
|
||||
RNA_def_int(
|
||||
ot->srna, "current_character", 0, 0, INT_MAX, "Cursor", "The index of the cursor", 0, 10000);
|
||||
RNA_def_boolean(ot->srna,
|
||||
"remove_duplicates",
|
||||
0,
|
||||
false,
|
||||
"Remove Duplicates",
|
||||
"Remove duplicate items in the history");
|
||||
}
|
||||
@@ -993,12 +995,12 @@ static int console_scrollback_append_exec(bContext *C, wmOperator *op)
|
||||
ConsoleLine *ci;
|
||||
|
||||
/* own this text in the new line, don't free */
|
||||
char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0, NULL);
|
||||
char *str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, nullptr);
|
||||
int type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
console_history_verify(C);
|
||||
|
||||
ci = console_scrollback_add_str(sc, str, 1); /* own the string */
|
||||
ci = console_scrollback_add_str(sc, str, true); /* own the string */
|
||||
ci->type = type;
|
||||
|
||||
console_scrollback_limit(sc);
|
||||
@@ -1022,7 +1024,7 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
|
||||
{CONSOLE_LINE_INPUT, "INPUT", 0, "Input", ""},
|
||||
{CONSOLE_LINE_INFO, "INFO", 0, "Information", ""},
|
||||
{CONSOLE_LINE_ERROR, "ERROR", 0, "Error", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
@@ -1035,7 +1037,7 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_console_active;
|
||||
|
||||
/* properties */
|
||||
RNA_def_string(ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position");
|
||||
RNA_def_string(ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
|
||||
RNA_def_enum(ot->srna,
|
||||
"type",
|
||||
console_line_type_items,
|
||||
@@ -1044,15 +1046,15 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
|
||||
"Console output type");
|
||||
}
|
||||
|
||||
static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int console_copy_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceConsole *sc = CTX_wm_space_console(C);
|
||||
char *buf = console_select_to_buffer(sc);
|
||||
if (buf == NULL) {
|
||||
if (buf == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
WM_clipboard_text_set(buf, 0);
|
||||
WM_clipboard_text_set(buf, false);
|
||||
MEM_freeN(buf);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1080,7 +1082,7 @@ static int console_paste_exec(bContext *C, wmOperator *op)
|
||||
int buf_str_len;
|
||||
|
||||
char *buf_str = WM_clipboard_text_get(selection, true, &buf_str_len);
|
||||
if (buf_str == NULL) {
|
||||
if (buf_str == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
if (*buf_str == '\0') {
|
||||
@@ -1093,7 +1095,7 @@ static int console_paste_exec(bContext *C, wmOperator *op)
|
||||
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);
|
||||
WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, nullptr, nullptr);
|
||||
ci = console_history_verify(C);
|
||||
}
|
||||
console_line_insert(ci, buf, buf_len);
|
||||
@@ -1125,20 +1127,20 @@ void CONSOLE_OT_paste(wmOperatorType *ot)
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_boolean(ot->srna,
|
||||
"selection",
|
||||
0,
|
||||
false,
|
||||
"Selection",
|
||||
"Paste text selected elsewhere rather than copied (X11/Wayland only)");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
}
|
||||
|
||||
typedef struct SetConsoleCursor {
|
||||
struct SetConsoleCursor {
|
||||
int sel_old[2];
|
||||
int sel_init;
|
||||
} SetConsoleCursor;
|
||||
};
|
||||
|
||||
/* TODO: cursor placement without selection. */
|
||||
static void console_cursor_set_to_pos(
|
||||
SpaceConsole *sc, ARegion *region, SetConsoleCursor *scu, const int mval[2], int UNUSED(sel))
|
||||
SpaceConsole *sc, ARegion *region, SetConsoleCursor *scu, const int mval[2], int /*sel*/)
|
||||
{
|
||||
int pos;
|
||||
pos = console_char_pick(sc, region, mval);
|
||||
@@ -1166,7 +1168,7 @@ static void console_modal_select_apply(bContext *C, wmOperator *op, const wmEven
|
||||
{
|
||||
SpaceConsole *sc = CTX_wm_space_console(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
SetConsoleCursor *scu = op->customdata;
|
||||
SetConsoleCursor *scu = static_cast<SetConsoleCursor *>(op->customdata);
|
||||
int mval[2];
|
||||
int sel_prev[2];
|
||||
|
||||
@@ -1187,7 +1189,7 @@ static void console_modal_select_apply(bContext *C, wmOperator *op, const wmEven
|
||||
static void console_cursor_set_exit(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceConsole *sc = CTX_wm_space_console(C);
|
||||
SetConsoleCursor *scu = op->customdata;
|
||||
SetConsoleCursor *scu = static_cast<SetConsoleCursor *>(op->customdata);
|
||||
|
||||
console_select_update_primary_clipboard(sc);
|
||||
|
||||
@@ -1201,7 +1203,7 @@ static int console_modal_select_invoke(bContext *C, wmOperator *op, const wmEven
|
||||
SetConsoleCursor *scu;
|
||||
|
||||
op->customdata = MEM_callocN(sizeof(SetConsoleCursor), "SetConsoleCursor");
|
||||
scu = op->customdata;
|
||||
scu = static_cast<SetConsoleCursor *>(op->customdata);
|
||||
|
||||
scu->sel_old[0] = sc->sel_start;
|
||||
scu->sel_old[1] = sc->sel_end;
|
||||
@@ -1253,12 +1255,12 @@ void CONSOLE_OT_select_set(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_console_active;
|
||||
}
|
||||
|
||||
static int console_selectword_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
||||
static int console_selectword_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||
{
|
||||
SpaceConsole *sc = CTX_wm_space_console(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
||||
ConsoleLine cl_dummy = {NULL};
|
||||
ConsoleLine cl_dummy = {nullptr};
|
||||
ConsoleLine *cl;
|
||||
int ret = OPERATOR_CANCELLED;
|
||||
int pos, offset, n;
|
||||
@@ -6,8 +6,8 @@
|
||||
* \ingroup spconsole
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -32,29 +32,29 @@
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "console_intern.h" /* own include */
|
||||
#include "console_intern.hh" /* own include */
|
||||
|
||||
/* ******************** default callbacks for console space ***************** */
|
||||
|
||||
static SpaceLink *console_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
|
||||
static SpaceLink *console_create(const ScrArea * /*area*/, const Scene * /*scene*/)
|
||||
{
|
||||
ARegion *region;
|
||||
SpaceConsole *sconsole;
|
||||
|
||||
sconsole = MEM_callocN(sizeof(SpaceConsole), "initconsole");
|
||||
sconsole = static_cast<SpaceConsole *>(MEM_callocN(sizeof(SpaceConsole), "initconsole"));
|
||||
sconsole->spacetype = SPACE_CONSOLE;
|
||||
|
||||
sconsole->lheight = 14;
|
||||
|
||||
/* header */
|
||||
region = MEM_callocN(sizeof(ARegion), "header for console");
|
||||
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "header for console"));
|
||||
|
||||
BLI_addtail(&sconsole->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_HEADER;
|
||||
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
||||
|
||||
/* main region */
|
||||
region = MEM_callocN(sizeof(ARegion), "main region for text");
|
||||
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "main region for text"));
|
||||
|
||||
BLI_addtail(&sconsole->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_WINDOW;
|
||||
@@ -79,20 +79,20 @@ static void console_free(SpaceLink *sl)
|
||||
SpaceConsole *sc = (SpaceConsole *)sl;
|
||||
|
||||
while (sc->scrollback.first) {
|
||||
console_scrollback_free(sc, sc->scrollback.first);
|
||||
console_scrollback_free(sc, static_cast<ConsoleLine *>(sc->scrollback.first));
|
||||
}
|
||||
|
||||
while (sc->history.first) {
|
||||
console_history_free(sc, sc->history.first);
|
||||
console_history_free(sc, static_cast<ConsoleLine *>(sc->history.first));
|
||||
}
|
||||
}
|
||||
|
||||
/* spacetype; init callback */
|
||||
static void console_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) {}
|
||||
static void console_init(wmWindowManager * /*wm*/, ScrArea * /*area*/) {}
|
||||
|
||||
static SpaceLink *console_duplicate(SpaceLink *sl)
|
||||
{
|
||||
SpaceConsole *sconsolen = MEM_dupallocN(sl);
|
||||
SpaceConsole *sconsolen = static_cast<SpaceConsole *>(MEM_dupallocN(sl));
|
||||
|
||||
/* clear or remove stuff from old */
|
||||
|
||||
@@ -138,7 +138,7 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *region)
|
||||
}
|
||||
|
||||
/* same as 'text_cursor' */
|
||||
static void console_cursor(wmWindow *win, ScrArea *UNUSED(area), ARegion *region)
|
||||
static void console_cursor(wmWindow *win, ScrArea * /*area*/, ARegion *region)
|
||||
{
|
||||
int wmcursor = WM_CURSOR_TEXT_EDIT;
|
||||
const wmEvent *event = win->eventstate;
|
||||
@@ -151,12 +151,12 @@ static void console_cursor(wmWindow *win, ScrArea *UNUSED(area), ARegion *region
|
||||
|
||||
/* ************* dropboxes ************* */
|
||||
|
||||
static bool id_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
|
||||
static bool id_drop_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/)
|
||||
{
|
||||
return WM_drag_get_local_ID(drag, 0) != NULL;
|
||||
return WM_drag_get_local_ID(drag, 0) != nullptr;
|
||||
}
|
||||
|
||||
static void id_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
|
||||
static void id_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
|
||||
{
|
||||
ID *id = WM_drag_get_local_ID(drag, 0);
|
||||
|
||||
@@ -166,12 +166,12 @@ static void id_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
|
||||
MEM_freeN(text);
|
||||
}
|
||||
|
||||
static bool path_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
|
||||
static bool path_drop_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/)
|
||||
{
|
||||
return (drag->type == WM_DRAG_PATH);
|
||||
}
|
||||
|
||||
static void path_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
|
||||
static void path_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
|
||||
{
|
||||
char pathname[FILE_MAX + 2];
|
||||
SNPRINTF(pathname, "\"%s\"", WM_drag_get_path(drag));
|
||||
@@ -179,12 +179,12 @@ static void path_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
|
||||
}
|
||||
|
||||
/* this region dropbox definition */
|
||||
static void console_dropboxes(void)
|
||||
static void console_dropboxes()
|
||||
{
|
||||
ListBase *lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
|
||||
|
||||
WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy, NULL, NULL);
|
||||
WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy, NULL, NULL);
|
||||
WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy, nullptr, nullptr);
|
||||
WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy, nullptr, nullptr);
|
||||
}
|
||||
|
||||
/* ************* end drop *********** */
|
||||
@@ -196,7 +196,8 @@ static void console_main_region_draw(const bContext *C, ARegion *region)
|
||||
View2D *v2d = ®ion->v2d;
|
||||
|
||||
if (BLI_listbase_is_empty(&sc->scrollback)) {
|
||||
WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL, NULL);
|
||||
WM_operator_name_call(
|
||||
(bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, nullptr, nullptr);
|
||||
}
|
||||
|
||||
/* clear and setup matrix */
|
||||
@@ -214,10 +215,10 @@ static void console_main_region_draw(const bContext *C, ARegion *region)
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers */
|
||||
UI_view2d_scrollers_draw(v2d, NULL);
|
||||
UI_view2d_scrollers_draw(v2d, nullptr);
|
||||
}
|
||||
|
||||
static void console_operatortypes(void)
|
||||
static void console_operatortypes()
|
||||
{
|
||||
/* console_ops.c */
|
||||
WM_operatortype_append(CONSOLE_OT_move);
|
||||
@@ -249,7 +250,7 @@ static void console_keymap(wmKeyConfig *keyconf)
|
||||
/****************** header region ******************/
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void console_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
|
||||
static void console_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
|
||||
{
|
||||
ED_region_header_init(region);
|
||||
}
|
||||
@@ -272,7 +273,7 @@ static void console_main_region_listener(const wmRegionListenerParams *params)
|
||||
if (wmn->action == NA_EDITED) {
|
||||
if ((wmn->reference && area) && (wmn->reference == area->spacedata.first)) {
|
||||
/* we've modified the geometry (font size), re-calculate rect */
|
||||
console_textview_update_rect(wmn->reference, region);
|
||||
console_textview_update_rect(static_cast<SpaceConsole *>(wmn->reference), region);
|
||||
ED_region_tag_redraw(region);
|
||||
}
|
||||
}
|
||||
@@ -316,14 +317,14 @@ static void console_space_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
|
||||
/* 'len_alloc' is invalid on write, set from 'len' on read */
|
||||
BLO_write_struct(writer, ConsoleLine, cl);
|
||||
BLO_write_raw(writer, (size_t)cl->len + 1, cl->line);
|
||||
BLO_write_raw(writer, size_t(cl->len) + 1, cl->line);
|
||||
}
|
||||
BLO_write_struct(writer, SpaceConsole, sl);
|
||||
}
|
||||
|
||||
void ED_spacetype_console(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype console");
|
||||
SpaceType *st = static_cast<SpaceType *>(MEM_callocN(sizeof(SpaceType), "spacetype console"));
|
||||
ARegionType *art;
|
||||
|
||||
st->spaceid = SPACE_CONSOLE;
|
||||
@@ -340,7 +341,7 @@ void ED_spacetype_console(void)
|
||||
st->blend_write = console_space_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype console region");
|
||||
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype console region"));
|
||||
art->regionid = RGN_TYPE_WINDOW;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
|
||||
|
||||
@@ -353,7 +354,7 @@ void ED_spacetype_console(void)
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: header */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype console region");
|
||||
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype console region"));
|
||||
art->regionid = RGN_TYPE_HEADER;
|
||||
art->prefsizey = HEADERY;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
|
||||
@@ -28,15 +28,15 @@ set(INC_SYS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
info_draw.c
|
||||
info_ops.c
|
||||
info_report.c
|
||||
info_draw.cc
|
||||
info_ops.cc
|
||||
info_report.cc
|
||||
info_stats.cc
|
||||
space_info.c
|
||||
textview.c
|
||||
space_info.cc
|
||||
textview.cc
|
||||
|
||||
info_intern.h
|
||||
textview.h
|
||||
info_intern.hh
|
||||
textview.hh
|
||||
)
|
||||
|
||||
set(LIB
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* \ingroup spinfo
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "info_intern.h"
|
||||
#include "textview.h"
|
||||
#include "info_intern.hh"
|
||||
#include "textview.hh"
|
||||
|
||||
static enum eTextViewContext_LineFlag report_line_data(TextViewContext *tvc,
|
||||
uchar fg[4],
|
||||
@@ -30,7 +30,7 @@ static enum eTextViewContext_LineFlag report_line_data(TextViewContext *tvc,
|
||||
uchar r_icon_fg[4],
|
||||
uchar r_icon_bg[4])
|
||||
{
|
||||
const Report *report = tvc->iter;
|
||||
const Report *report = static_cast<const Report *>(tvc->iter);
|
||||
|
||||
/* Same text color no matter what type of report. */
|
||||
UI_GetThemeColor4ubv((report->flag & SELECT) ? TH_INFO_SELECTED_TEXT : TH_TEXT, fg);
|
||||
@@ -65,7 +65,7 @@ static enum eTextViewContext_LineFlag report_line_data(TextViewContext *tvc,
|
||||
/* reports! */
|
||||
static void report_textview_init__internal(TextViewContext *tvc)
|
||||
{
|
||||
const Report *report = tvc->iter;
|
||||
const Report *report = static_cast<const Report *>(tvc->iter);
|
||||
const char *str = report->message;
|
||||
for (int i = tvc->iter_char_end - 1; i >= 0; i -= 1) {
|
||||
if (str[i] == '\n') {
|
||||
@@ -78,17 +78,17 @@ static void report_textview_init__internal(TextViewContext *tvc)
|
||||
|
||||
static int report_textview_skip__internal(TextViewContext *tvc)
|
||||
{
|
||||
const SpaceInfo *sinfo = tvc->arg1;
|
||||
const SpaceInfo *sinfo = static_cast<const SpaceInfo *>(tvc->arg1);
|
||||
const int report_mask = info_report_mask(sinfo);
|
||||
while (tvc->iter && (((const Report *)tvc->iter)->type & report_mask) == 0) {
|
||||
tvc->iter = (void *)((Link *)tvc->iter)->prev;
|
||||
}
|
||||
return (tvc->iter != NULL);
|
||||
return (tvc->iter != nullptr);
|
||||
}
|
||||
|
||||
static int report_textview_begin(TextViewContext *tvc)
|
||||
{
|
||||
const ReportList *reports = tvc->arg2;
|
||||
const ReportList *reports = static_cast<const ReportList *>(tvc->arg2);
|
||||
|
||||
tvc->sel_start = 0;
|
||||
tvc->sel_end = 0;
|
||||
@@ -101,7 +101,7 @@ static int report_textview_begin(TextViewContext *tvc)
|
||||
tvc->iter_tmp = 0;
|
||||
if (tvc->iter && report_textview_skip__internal(tvc)) {
|
||||
/* init the newline iterator */
|
||||
const Report *report = tvc->iter;
|
||||
const Report *report = static_cast<const Report *>(tvc->iter);
|
||||
tvc->iter_char_end = report->len;
|
||||
report_textview_init__internal(tvc);
|
||||
|
||||
@@ -111,7 +111,7 @@ static int report_textview_begin(TextViewContext *tvc)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void report_textview_end(TextViewContext *UNUSED(tvc))
|
||||
static void report_textview_end(TextViewContext * /*tvc*/)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
@@ -124,7 +124,7 @@ static int report_textview_step(TextViewContext *tvc)
|
||||
if (tvc->iter && report_textview_skip__internal(tvc)) {
|
||||
tvc->iter_tmp++;
|
||||
|
||||
const Report *report = tvc->iter;
|
||||
const Report *report = static_cast<const Report *>(tvc->iter);
|
||||
tvc->iter_char_end = report->len; /* reset start */
|
||||
report_textview_init__internal(tvc);
|
||||
|
||||
@@ -142,7 +142,7 @@ static int report_textview_step(TextViewContext *tvc)
|
||||
|
||||
static void report_textview_line_get(TextViewContext *tvc, const char **r_line, int *r_len)
|
||||
{
|
||||
const Report *report = tvc->iter;
|
||||
const Report *report = static_cast<const Report *>(tvc->iter);
|
||||
*r_line = report->message + tvc->iter_char_begin;
|
||||
*r_len = tvc->iter_char_end - tvc->iter_char_begin;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ static int info_textview_main__internal(const SpaceInfo *sinfo,
|
||||
tvc.step = report_textview_step;
|
||||
tvc.line_get = report_textview_line_get;
|
||||
tvc.line_data = report_line_data;
|
||||
tvc.const_colors = NULL;
|
||||
tvc.const_colors = nullptr;
|
||||
|
||||
tvc.arg1 = sinfo;
|
||||
tvc.arg2 = reports;
|
||||
@@ -208,21 +208,21 @@ void *info_text_pick(const SpaceInfo *sinfo,
|
||||
const ReportList *reports,
|
||||
int mouse_y)
|
||||
{
|
||||
void *mval_pick_item = NULL;
|
||||
void *mval_pick_item = nullptr;
|
||||
const int mval[2] = {0, mouse_y};
|
||||
|
||||
info_textview_main__internal(sinfo, region, reports, false, mval, &mval_pick_item, NULL);
|
||||
info_textview_main__internal(sinfo, region, reports, false, mval, &mval_pick_item, nullptr);
|
||||
return (void *)mval_pick_item;
|
||||
}
|
||||
|
||||
int info_textview_height(const SpaceInfo *sinfo, const ARegion *region, const ReportList *reports)
|
||||
{
|
||||
const int mval[2] = {INT_MAX, INT_MAX};
|
||||
return info_textview_main__internal(sinfo, region, reports, false, mval, NULL, NULL);
|
||||
return info_textview_main__internal(sinfo, region, reports, false, mval, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void info_textview_main(const SpaceInfo *sinfo, const ARegion *region, const ReportList *reports)
|
||||
{
|
||||
const int mval[2] = {INT_MAX, INT_MAX};
|
||||
info_textview_main__internal(sinfo, region, reports, true, mval, NULL, NULL);
|
||||
info_textview_main__internal(sinfo, region, reports, true, mval, nullptr, nullptr);
|
||||
}
|
||||
@@ -6,8 +6,8 @@
|
||||
* \ingroup spinfo
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
|
||||
#include "info_intern.h"
|
||||
#include "info_intern.hh"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Pack Blend File Libraries Operator
|
||||
@@ -87,7 +87,7 @@ static int unpack_libraries_exec(bContext *C, wmOperator *op)
|
||||
/** \name Unpack Blend File Libraries Operator
|
||||
* \{ */
|
||||
|
||||
static int unpack_libraries_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int unpack_libraries_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
return WM_operator_confirm_message(
|
||||
C, op, "Unpack Linked Libraries - creates directories, all new paths should work");
|
||||
@@ -158,13 +158,15 @@ static int pack_all_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Image *ima;
|
||||
|
||||
/* First check for dirty images. */
|
||||
for (ima = bmain->images.first; ima; ima = ima->id.next) {
|
||||
for (ima = static_cast<Image *>(bmain->images.first); ima;
|
||||
ima = static_cast<Image *>(ima->id.next))
|
||||
{
|
||||
if (BKE_image_is_dirty(ima)) {
|
||||
break;
|
||||
}
|
||||
@@ -219,13 +221,13 @@ static const EnumPropertyItem unpack_all_method_items[] = {
|
||||
{PF_KEEP, "KEEP", 0, "Disable auto-pack, keep all packed files", ""},
|
||||
{PF_REMOVE, "REMOVE", 0, "Remove Pack", ""},
|
||||
/* {PF_ASK, "ASK", 0, "Ask for each file", ""}, */
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static int unpack_all_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
int method = RNA_enum_get(op->ptr, "method");
|
||||
ePF_FileStatus method = ePF_FileStatus(RNA_enum_get(op->ptr, "method"));
|
||||
|
||||
if (method != PF_KEEP) {
|
||||
WM_cursor_wait(true);
|
||||
@@ -237,7 +239,7 @@ static int unpack_all_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
uiPopupMenu *pup;
|
||||
@@ -314,7 +316,7 @@ static const EnumPropertyItem unpack_item_method_items[] = {
|
||||
"Write file to original location (overwrite existing file)",
|
||||
""},
|
||||
/* {PF_ASK, "ASK", 0, "Ask for each file", ""}, */
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static int unpack_item_exec(bContext *C, wmOperator *op)
|
||||
@@ -323,12 +325,12 @@ static int unpack_item_exec(bContext *C, wmOperator *op)
|
||||
ID *id;
|
||||
char idname[MAX_ID_NAME - 2];
|
||||
int type = RNA_int_get(op->ptr, "id_type");
|
||||
int method = RNA_enum_get(op->ptr, "method");
|
||||
ePF_FileStatus method = ePF_FileStatus(RNA_enum_get(op->ptr, "method"));
|
||||
|
||||
RNA_string_get(op->ptr, "id_name", idname);
|
||||
id = BKE_libblock_find_name(bmain, type, idname);
|
||||
|
||||
if (id == NULL) {
|
||||
if (id == nullptr) {
|
||||
BKE_report(op->reports, RPT_WARNING, "No packed file");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -344,7 +346,7 @@ static int unpack_item_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int unpack_item_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int unpack_item_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
uiPopupMenu *pup;
|
||||
uiLayout *layout;
|
||||
@@ -353,7 +355,12 @@ static int unpack_item_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
|
||||
layout = UI_popup_menu_layout(pup);
|
||||
|
||||
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
|
||||
uiItemsFullEnumO(layout, op->type->idname, "method", op->ptr->data, WM_OP_EXEC_REGION_WIN, 0);
|
||||
uiItemsFullEnumO(layout,
|
||||
op->type->idname,
|
||||
"method",
|
||||
static_cast<IDProperty *>(op->ptr->data),
|
||||
WM_OP_EXEC_REGION_WIN,
|
||||
0);
|
||||
|
||||
UI_popup_menu_end(C, pup);
|
||||
|
||||
@@ -378,7 +385,7 @@ void FILE_OT_unpack_item(wmOperatorType *ot)
|
||||
RNA_def_enum(
|
||||
ot->srna, "method", unpack_item_method_items, PF_USE_LOCAL, "Method", "How to unpack");
|
||||
RNA_def_string(
|
||||
ot->srna, "id_name", NULL, BKE_ST_MAXNAME, "ID Name", "Name of ID block to unpack");
|
||||
ot->srna, "id_name", nullptr, BKE_ST_MAXNAME, "ID Name", "Name of ID block to unpack");
|
||||
RNA_def_int(ot->srna,
|
||||
"id_type",
|
||||
ID_IM,
|
||||
@@ -409,7 +416,7 @@ static int make_paths_relative_exec(bContext *C, wmOperator *op)
|
||||
BKE_bpath_relative_convert(bmain, blendfile_path, op->reports);
|
||||
|
||||
/* redraw everything so any changed paths register */
|
||||
WM_main_add_notifier(NC_WINDOW, NULL);
|
||||
WM_main_add_notifier(NC_WINDOW, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -447,7 +454,7 @@ static int make_paths_absolute_exec(bContext *C, wmOperator *op)
|
||||
BKE_bpath_absolute_convert(bmain, blendfile_path, op->reports);
|
||||
|
||||
/* redraw everything so any changed paths register */
|
||||
WM_main_add_notifier(NC_WINDOW, NULL);
|
||||
WM_main_add_notifier(NC_WINDOW, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -505,7 +512,7 @@ void FILE_OT_report_missing_files(wmOperatorType *ot)
|
||||
static int find_missing_files_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
const char *searchpath = RNA_string_get_alloc(op->ptr, "directory", NULL, 0, NULL);
|
||||
const char *searchpath = RNA_string_get_alloc(op->ptr, "directory", nullptr, 0, nullptr);
|
||||
const bool find_all = RNA_boolean_get(op->ptr, "find_all");
|
||||
|
||||
BKE_bpath_missing_files_find(bmain, searchpath, op->reports, find_all);
|
||||
@@ -514,7 +521,7 @@ static int find_missing_files_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int find_missing_files_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int find_missing_files_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
/* XXX file open button text "Find Missing Files" */
|
||||
WM_event_add_fileselect(C, op);
|
||||
@@ -568,7 +575,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
|
||||
#define FLASH_TIMEOUT 1.0f
|
||||
#define COLLAPSE_TIMEOUT 0.25f
|
||||
#define BRIGHTEN_AMOUNT 0.1f
|
||||
static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
||||
static int update_reports_display_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
@@ -580,8 +587,8 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co
|
||||
int send_note = 0;
|
||||
|
||||
/* escape if not our timer */
|
||||
if ((reports->reporttimer == NULL) || (reports->reporttimer != event->customdata) ||
|
||||
((report = BKE_reports_last_displayable(reports)) == NULL))
|
||||
if ((reports->reporttimer == nullptr) || (reports->reporttimer != event->customdata) ||
|
||||
((report = BKE_reports_last_displayable(reports)) == nullptr))
|
||||
{
|
||||
/* May have been deleted. */
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
@@ -592,11 +599,11 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co
|
||||
timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT;
|
||||
|
||||
/* clear the report display after timeout */
|
||||
if ((float)reports->reporttimer->duration > timeout) {
|
||||
WM_event_remove_timer(wm, NULL, reports->reporttimer);
|
||||
reports->reporttimer = NULL;
|
||||
if (float(reports->reporttimer->duration) > timeout) {
|
||||
WM_event_remove_timer(wm, nullptr, reports->reporttimer);
|
||||
reports->reporttimer = nullptr;
|
||||
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, nullptr);
|
||||
|
||||
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
|
||||
}
|
||||
@@ -617,8 +624,8 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co
|
||||
rti->widthfac = 1.0f;
|
||||
}
|
||||
|
||||
progress = powf((float)reports->reporttimer->duration / timeout, 2.0f);
|
||||
flash_progress = powf((float)reports->reporttimer->duration / flash_timeout, 2.0);
|
||||
progress = powf(float(reports->reporttimer->duration) / timeout, 2.0f);
|
||||
flash_progress = powf(float(reports->reporttimer->duration) / flash_timeout, 2.0);
|
||||
|
||||
/* save us from too many draws */
|
||||
if (flash_progress <= 1.0f) {
|
||||
@@ -636,7 +643,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co
|
||||
}
|
||||
|
||||
if (send_note) {
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, nullptr);
|
||||
}
|
||||
|
||||
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
|
||||
@@ -6,9 +6,9 @@
|
||||
* \ingroup spinfo
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -27,13 +27,15 @@
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
|
||||
#include "info_intern.h"
|
||||
#include "info_intern.hh"
|
||||
|
||||
static void reports_select_all(ReportList *reports, int report_mask, int action)
|
||||
{
|
||||
if (action == SEL_TOGGLE) {
|
||||
action = SEL_SELECT;
|
||||
for (Report *report = reports->list.last; report; report = report->prev) {
|
||||
for (const Report *report = static_cast<const Report *>(reports->list.last); report;
|
||||
report = report->prev)
|
||||
{
|
||||
if ((report->type & report_mask) && (report->flag & SELECT)) {
|
||||
action = SEL_DESELECT;
|
||||
break;
|
||||
@@ -41,7 +43,7 @@ static void reports_select_all(ReportList *reports, int report_mask, int action)
|
||||
}
|
||||
}
|
||||
|
||||
for (Report *report = reports->list.last; report; report = report->prev) {
|
||||
for (Report *report = static_cast<Report *>(reports->list.last); report; report = report->prev) {
|
||||
if (report->type & report_mask) {
|
||||
switch (action) {
|
||||
case SEL_SELECT:
|
||||
@@ -60,7 +62,7 @@ static void reports_select_all(ReportList *reports, int report_mask, int action)
|
||||
}
|
||||
}
|
||||
|
||||
int info_report_mask(const SpaceInfo *UNUSED(sinfo))
|
||||
int info_report_mask(const SpaceInfo * /*sinfo*/)
|
||||
{
|
||||
#if 0
|
||||
int report_mask = 0;
|
||||
@@ -88,7 +90,7 @@ int info_report_mask(const SpaceInfo *UNUSED(sinfo))
|
||||
RPT_ERROR_ALL;
|
||||
}
|
||||
|
||||
static int report_replay_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int report_replay_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
/* TODO: get this working again! */
|
||||
#if 0
|
||||
@@ -138,7 +140,7 @@ static int select_report_pick_exec(bContext *C, wmOperator *op)
|
||||
int report_index = RNA_int_get(op->ptr, "report_index");
|
||||
bool extend = RNA_boolean_get(op->ptr, "extend");
|
||||
|
||||
Report *report = BLI_findlink(&CTX_wm_reports(C)->list, report_index);
|
||||
Report *report = static_cast<Report *>(BLI_findlink(&CTX_wm_reports(C)->list, report_index));
|
||||
|
||||
SpaceInfo *sinfo = CTX_wm_space_info(C);
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
@@ -164,7 +166,7 @@ static int select_report_pick_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
Report *report;
|
||||
|
||||
report = info_text_pick(sinfo, region, reports, event->mval[1]);
|
||||
report = static_cast<Report *>(info_text_pick(sinfo, region, reports, event->mval[1]));
|
||||
|
||||
RNA_int_set(op->ptr, "report_index", BLI_findindex(&reports->list, report));
|
||||
|
||||
@@ -235,7 +237,7 @@ static int box_select_exec(bContext *C, wmOperator *op)
|
||||
|
||||
WM_operator_properties_border_to_rcti(op, &rect);
|
||||
|
||||
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
|
||||
const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
|
||||
const int select = (sel_op != SEL_OP_SUB);
|
||||
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
||||
LISTBASE_FOREACH (Report *, report, &reports->list) {
|
||||
@@ -246,11 +248,11 @@ static int box_select_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
report_min = info_text_pick(sinfo, region, reports, rect.ymax);
|
||||
report_max = info_text_pick(sinfo, region, reports, rect.ymin);
|
||||
report_min = static_cast<Report *>(info_text_pick(sinfo, region, reports, rect.ymax));
|
||||
report_max = static_cast<Report *>(info_text_pick(sinfo, region, reports, rect.ymin));
|
||||
|
||||
/* get the first report if none found */
|
||||
if (report_min == NULL) {
|
||||
if (report_min == nullptr) {
|
||||
// printf("find_min\n");
|
||||
LISTBASE_FOREACH (Report *, report, &reports->list) {
|
||||
if (report->type & report_mask) {
|
||||
@@ -260,9 +262,10 @@ static int box_select_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
if (report_max == NULL) {
|
||||
if (report_max == nullptr) {
|
||||
// printf("find_max\n");
|
||||
for (Report *report = reports->list.last; report; report = report->prev) {
|
||||
for (Report *report = static_cast<Report *>(reports->list.last); report; report = report->prev)
|
||||
{
|
||||
if (report->type & report_mask) {
|
||||
report_max = report;
|
||||
break;
|
||||
@@ -270,7 +273,7 @@ static int box_select_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
if (report_min == NULL || report_max == NULL) {
|
||||
if (report_min == nullptr || report_max == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
@@ -311,7 +314,7 @@ void INFO_OT_select_box(wmOperatorType *ot)
|
||||
WM_operator_properties_select_operation_simple(ot);
|
||||
}
|
||||
|
||||
static int report_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int report_delete_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceInfo *sinfo = CTX_wm_space_info(C);
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
@@ -319,8 +322,7 @@ static int report_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
Report *report, *report_next;
|
||||
|
||||
for (report = reports->list.first; report;) {
|
||||
|
||||
for (report = static_cast<Report *>(reports->list.first); report;) {
|
||||
report_next = report->next;
|
||||
|
||||
if ((report->type & report_mask) && (report->flag & SELECT)) {
|
||||
@@ -354,7 +356,7 @@ void INFO_OT_report_delete(wmOperatorType *ot)
|
||||
/* properties */
|
||||
}
|
||||
|
||||
static int report_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int report_copy_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceInfo *sinfo = CTX_wm_space_info(C);
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
@@ -365,7 +367,7 @@ static int report_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
DynStr *buf_dyn = BLI_dynstr_new();
|
||||
char *buf_str;
|
||||
|
||||
for (report = reports->list.first; report; report = report->next) {
|
||||
for (report = static_cast<Report *>(reports->list.first); report; report = report->next) {
|
||||
if ((report->type & report_mask) && (report->flag & SELECT)) {
|
||||
BLI_dynstr_append(buf_dyn, report->message);
|
||||
BLI_dynstr_append(buf_dyn, "\n");
|
||||
@@ -375,7 +377,7 @@ static int report_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
buf_str = BLI_dynstr_get_cstring(buf_dyn);
|
||||
BLI_dynstr_free(buf_dyn);
|
||||
|
||||
WM_clipboard_text_set(buf_str, 0);
|
||||
WM_clipboard_text_set(buf_str, false);
|
||||
|
||||
MEM_freeN(buf_str);
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -6,8 +6,8 @@
|
||||
* \ingroup spinfo
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -31,29 +31,29 @@
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "info_intern.h" /* own include */
|
||||
#include "info_intern.hh" /* own include */
|
||||
|
||||
/* ******************** default callbacks for info space ***************** */
|
||||
|
||||
static SpaceLink *info_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
|
||||
static SpaceLink *info_create(const ScrArea * /*area*/, const Scene * /*scene*/)
|
||||
{
|
||||
ARegion *region;
|
||||
SpaceInfo *sinfo;
|
||||
|
||||
sinfo = MEM_callocN(sizeof(SpaceInfo), "initinfo");
|
||||
sinfo = static_cast<SpaceInfo *>(MEM_callocN(sizeof(SpaceInfo), "initinfo"));
|
||||
sinfo->spacetype = SPACE_INFO;
|
||||
|
||||
sinfo->rpt_mask = INFO_RPT_OP;
|
||||
|
||||
/* header */
|
||||
region = MEM_callocN(sizeof(ARegion), "header for info");
|
||||
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "header for info"));
|
||||
|
||||
BLI_addtail(&sinfo->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_HEADER;
|
||||
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
||||
|
||||
/* main region */
|
||||
region = MEM_callocN(sizeof(ARegion), "main region for info");
|
||||
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "main region for info"));
|
||||
|
||||
BLI_addtail(&sinfo->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_WINDOW;
|
||||
@@ -73,17 +73,17 @@ static SpaceLink *info_create(const ScrArea *UNUSED(area), const Scene *UNUSED(s
|
||||
}
|
||||
|
||||
/* not spacelink itself */
|
||||
static void info_free(SpaceLink *UNUSED(sl))
|
||||
static void info_free(SpaceLink * /*sl*/)
|
||||
{
|
||||
// SpaceInfo *sinfo = (SpaceInfo *) sl;
|
||||
}
|
||||
|
||||
/* spacetype; init callback */
|
||||
static void info_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) {}
|
||||
static void info_init(wmWindowManager * /*wm*/, ScrArea * /*area*/) {}
|
||||
|
||||
static SpaceLink *info_duplicate(SpaceLink *sl)
|
||||
{
|
||||
SpaceInfo *sinfon = MEM_dupallocN(sl);
|
||||
SpaceInfo *sinfon = static_cast<SpaceInfo *>(MEM_dupallocN(sl));
|
||||
|
||||
/* clear or remove stuff from old */
|
||||
|
||||
@@ -139,10 +139,10 @@ static void info_main_region_draw(const bContext *C, ARegion *region)
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers */
|
||||
UI_view2d_scrollers_draw(v2d, NULL);
|
||||
UI_view2d_scrollers_draw(v2d, nullptr);
|
||||
}
|
||||
|
||||
static void info_operatortypes(void)
|
||||
static void info_operatortypes()
|
||||
{
|
||||
WM_operatortype_append(FILE_OT_autopack_toggle);
|
||||
WM_operatortype_append(FILE_OT_pack_all);
|
||||
@@ -174,7 +174,7 @@ static void info_keymap(wmKeyConfig *keyconf)
|
||||
}
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void info_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
|
||||
static void info_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
|
||||
{
|
||||
ED_region_header_init(region);
|
||||
}
|
||||
@@ -237,10 +237,10 @@ static void info_header_listener(const wmRegionListenerParams *params)
|
||||
|
||||
static void info_header_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
|
||||
{
|
||||
struct wmMsgBus *mbus = params->message_bus;
|
||||
wmMsgBus *mbus = params->message_bus;
|
||||
ARegion *region = params->region;
|
||||
|
||||
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {NULL};
|
||||
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {nullptr};
|
||||
msg_sub_value_region_tag_redraw.owner = region;
|
||||
msg_sub_value_region_tag_redraw.user_data = region;
|
||||
msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
|
||||
@@ -256,7 +256,7 @@ static void info_space_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
|
||||
void ED_spacetype_info(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype info");
|
||||
SpaceType *st = static_cast<SpaceType *>(MEM_callocN(sizeof(SpaceType), "spacetype info"));
|
||||
ARegionType *art;
|
||||
|
||||
st->spaceid = SPACE_INFO;
|
||||
@@ -271,7 +271,7 @@ void ED_spacetype_info(void)
|
||||
st->blend_write = info_space_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype info region");
|
||||
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype info region"));
|
||||
art->regionid = RGN_TYPE_WINDOW;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
|
||||
|
||||
@@ -282,7 +282,7 @@ void ED_spacetype_info(void)
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: header */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype info region");
|
||||
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype info region"));
|
||||
art->regionid = RGN_TYPE_HEADER;
|
||||
art->prefsizey = HEADERY;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "UI_interface.h"
|
||||
#include "UI_interface_icons.h"
|
||||
|
||||
#include "textview.h"
|
||||
#include "textview.hh"
|
||||
|
||||
static void textview_font_begin(const int font_id, const int lheight)
|
||||
{
|
||||
@@ -30,7 +30,7 @@ static void textview_font_begin(const int font_id, const int lheight)
|
||||
BLF_size(font_id, 0.8f * lheight);
|
||||
}
|
||||
|
||||
typedef struct TextViewDrawState {
|
||||
struct TextViewDrawState {
|
||||
int font_id;
|
||||
int cwidth;
|
||||
int lheight;
|
||||
@@ -50,7 +50,7 @@ typedef struct TextViewDrawState {
|
||||
int *mval_pick_offset;
|
||||
const int *mval; // [2]
|
||||
bool do_draw;
|
||||
} TextViewDrawState;
|
||||
};
|
||||
|
||||
BLI_INLINE void textview_step_sel(TextViewDrawState *tds, const int step)
|
||||
{
|
||||
@@ -99,10 +99,10 @@ static int textview_wrap_offsets(
|
||||
|
||||
*r_lines = 1;
|
||||
|
||||
*r_offsets = MEM_callocN(
|
||||
*r_offsets = static_cast<int *>(MEM_callocN(
|
||||
sizeof(**r_offsets) *
|
||||
(str_len * BLI_UTF8_WIDTH_MAX / MAX2(1, width - (BLI_UTF8_WIDTH_MAX - 1)) + 1),
|
||||
__func__);
|
||||
__func__));
|
||||
(*r_offsets)[0] = 0;
|
||||
|
||||
for (i = 0, end = width, j = 0; j < str_len && str[j]; j += BLI_str_utf8_size_safe(str + j)) {
|
||||
@@ -152,13 +152,13 @@ static bool textview_draw_string(TextViewDrawState *tds,
|
||||
|
||||
/* Wrap. */
|
||||
if (tot_lines > 1) {
|
||||
int iofs = (int)((float)(y_next - tds->mval[1]) / tds->lheight);
|
||||
int iofs = int(float(y_next - tds->mval[1]) / tds->lheight);
|
||||
ofs += offsets[MIN2(iofs, tot_lines - 1)];
|
||||
}
|
||||
|
||||
/* Last part. */
|
||||
ofs += BLI_str_utf8_offset_from_column(str + ofs,
|
||||
(int)floor((float)tds->mval[0] / tds->cwidth));
|
||||
int(floor(float(tds->mval[0]) / tds->cwidth)));
|
||||
|
||||
CLAMP(ofs, 0, str_len);
|
||||
*tds->mval_pick_offset += str_len - ofs;
|
||||
@@ -213,16 +213,14 @@ static bool textview_draw_string(TextViewDrawState *tds,
|
||||
|
||||
rgba_uchar_to_float(col, icon_bg);
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_4fv(
|
||||
&(const rctf){
|
||||
.xmin = hpadding,
|
||||
.xmax = bg_size + hpadding,
|
||||
.ymin = line_top - bg_size - vpadding,
|
||||
.ymax = line_top - vpadding,
|
||||
},
|
||||
true,
|
||||
4 * UI_SCALE_FAC,
|
||||
col);
|
||||
|
||||
rctf roundbox_rect;
|
||||
roundbox_rect.xmin = hpadding;
|
||||
roundbox_rect.xmax = bg_size + hpadding;
|
||||
roundbox_rect.ymin = line_top - bg_size - vpadding;
|
||||
roundbox_rect.ymax = line_top - vpadding;
|
||||
|
||||
UI_draw_roundbox_4fv(&roundbox_rect, true, 4 * UI_SCALE_FAC, col);
|
||||
}
|
||||
|
||||
if (icon) {
|
||||
@@ -325,13 +323,13 @@ int textview_draw(TextViewContext *tvc,
|
||||
CLAMPIS(mval_init[1], tvc->draw_rect.ymin, tvc->draw_rect.ymax) + tvc->scroll_ymin,
|
||||
};
|
||||
|
||||
if (r_mval_pick_offset != NULL) {
|
||||
if (r_mval_pick_offset != nullptr) {
|
||||
*r_mval_pick_offset = 0;
|
||||
}
|
||||
|
||||
/* Constants for the text-view context. */
|
||||
tds.font_id = font_id;
|
||||
tds.cwidth = (int)BLF_fixed_width(font_id);
|
||||
tds.cwidth = int(BLF_fixed_width(font_id));
|
||||
BLI_assert(tds.cwidth > 0);
|
||||
tds.lheight = tvc->lheight;
|
||||
tds.row_vpadding = tvc->row_vpadding;
|
||||
@@ -382,11 +380,11 @@ int textview_draw(TextViewContext *tvc,
|
||||
&tds,
|
||||
ext_line,
|
||||
ext_len,
|
||||
(data_flag & TVC_LINE_FG) ? fg : NULL,
|
||||
(data_flag & TVC_LINE_BG) ? bg : NULL,
|
||||
(data_flag & TVC_LINE_FG) ? fg : nullptr,
|
||||
(data_flag & TVC_LINE_BG) ? bg : nullptr,
|
||||
(data_flag & TVC_LINE_ICON) ? icon : 0,
|
||||
(data_flag & TVC_LINE_ICON_FG) ? icon_fg : NULL,
|
||||
(data_flag & TVC_LINE_ICON_BG) ? icon_bg : NULL,
|
||||
(data_flag & TVC_LINE_ICON_FG) ? icon_fg : nullptr,
|
||||
(data_flag & TVC_LINE_ICON_BG) ? icon_bg : nullptr,
|
||||
bg_sel);
|
||||
|
||||
if (do_draw) {
|
||||
@@ -15,6 +15,7 @@ enum eTextViewContext_LineFlag {
|
||||
TVC_LINE_ICON_FG = (1 << 3),
|
||||
TVC_LINE_ICON_BG = (1 << 4)
|
||||
};
|
||||
ENUM_OPERATORS(eTextViewContext_LineFlag, TVC_LINE_ICON_BG)
|
||||
|
||||
typedef struct TextViewContext {
|
||||
/** Font size scaled by the interface size. */
|
||||
Reference in New Issue
Block a user