Cleanup: move text editor files to C++
A workaround for over 128 else-if's in a row was needed for MSVC as it caused error C1061.
This commit is contained in:
@@ -23,21 +23,21 @@ set(INC_SYS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
space_text.c
|
||||
text_autocomplete.c
|
||||
text_draw.c
|
||||
text_format.c
|
||||
text_format_lua.c
|
||||
text_format_osl.c
|
||||
text_format_pov.c
|
||||
text_format_pov_ini.c
|
||||
text_format_py.c
|
||||
text_header.c
|
||||
text_ops.c
|
||||
space_text.cc
|
||||
text_autocomplete.cc
|
||||
text_draw.cc
|
||||
text_format.cc
|
||||
text_format_lua.cc
|
||||
text_format_osl.cc
|
||||
text_format_pov.cc
|
||||
text_format_pov_ini.cc
|
||||
text_format_py.cc
|
||||
text_header.cc
|
||||
text_ops.cc
|
||||
text_undo.cc
|
||||
|
||||
text_format.h
|
||||
text_intern.h
|
||||
text_format.hh
|
||||
text_intern.hh
|
||||
)
|
||||
|
||||
set(LIB
|
||||
|
||||
@@ -35,17 +35,17 @@
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_path.h"
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_intern.h" /* own include */
|
||||
#include "text_format.hh"
|
||||
#include "text_intern.hh" /* own include */
|
||||
|
||||
/* ******************** default callbacks for text space ***************** */
|
||||
|
||||
static SpaceLink *text_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
|
||||
static SpaceLink *text_create(const ScrArea * /*area*/, const Scene * /*scene*/)
|
||||
{
|
||||
ARegion *region;
|
||||
SpaceText *stext;
|
||||
|
||||
stext = MEM_callocN(sizeof(SpaceText), "inittext");
|
||||
stext = static_cast<SpaceText *>(MEM_callocN(sizeof(SpaceText), "inittext"));
|
||||
stext->spacetype = SPACE_TEXT;
|
||||
|
||||
stext->lheight = 12;
|
||||
@@ -55,20 +55,20 @@ static SpaceLink *text_create(const ScrArea *UNUSED(area), const Scene *UNUSED(s
|
||||
stext->showlinenrs = true;
|
||||
|
||||
/* header */
|
||||
region = MEM_callocN(sizeof(ARegion), "header for text");
|
||||
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "header for text"));
|
||||
|
||||
BLI_addtail(&stext->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_HEADER;
|
||||
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
||||
|
||||
/* footer */
|
||||
region = MEM_callocN(sizeof(ARegion), "footer for text");
|
||||
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "footer for text"));
|
||||
BLI_addtail(&stext->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_FOOTER;
|
||||
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
|
||||
|
||||
/* properties region */
|
||||
region = MEM_callocN(sizeof(ARegion), "properties region for text");
|
||||
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "properties region for text"));
|
||||
|
||||
BLI_addtail(&stext->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_UI;
|
||||
@@ -76,7 +76,7 @@ static SpaceLink *text_create(const ScrArea *UNUSED(area), const Scene *UNUSED(s
|
||||
region->flag = RGN_FLAG_HIDDEN;
|
||||
|
||||
/* 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(&stext->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_WINDOW;
|
||||
@@ -89,20 +89,20 @@ static void text_free(SpaceLink *sl)
|
||||
{
|
||||
SpaceText *stext = (SpaceText *)sl;
|
||||
|
||||
stext->text = NULL;
|
||||
stext->text = nullptr;
|
||||
text_free_caches(stext);
|
||||
}
|
||||
|
||||
/* spacetype; init callback */
|
||||
static void text_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) {}
|
||||
static void text_init(wmWindowManager * /*wm*/, ScrArea * /*area*/) {}
|
||||
|
||||
static SpaceLink *text_duplicate(SpaceLink *sl)
|
||||
{
|
||||
SpaceText *stextn = MEM_dupallocN(sl);
|
||||
SpaceText *stextn = static_cast<SpaceText *>(MEM_dupallocN(sl));
|
||||
|
||||
/* clear or remove stuff from old */
|
||||
|
||||
stextn->runtime.drawcache = NULL; /* space need its own cache */
|
||||
stextn->runtime.drawcache = nullptr; /* space need its own cache */
|
||||
|
||||
return (SpaceLink *)stextn;
|
||||
}
|
||||
@@ -111,13 +111,13 @@ static void text_listener(const wmSpaceTypeListenerParams *params)
|
||||
{
|
||||
ScrArea *area = params->area;
|
||||
const wmNotifier *wmn = params->notifier;
|
||||
SpaceText *st = area->spacedata.first;
|
||||
SpaceText *st = static_cast<SpaceText *>(area->spacedata.first);
|
||||
|
||||
/* context changes */
|
||||
switch (wmn->category) {
|
||||
case NC_TEXT:
|
||||
/* check if active text was changed, no need to redraw if text isn't active
|
||||
* (reference == NULL) means text was unlinked, should update anyway for this
|
||||
* (reference == nullptr) means text was unlinked, should update anyway for this
|
||||
* case -- no way to know was text active before unlinking or not */
|
||||
if (wmn->reference && wmn->reference != st->text) {
|
||||
break;
|
||||
@@ -220,7 +220,7 @@ static void text_keymap(wmKeyConfig *keyconf)
|
||||
WM_keymap_ensure(keyconf, "Text", SPACE_TEXT, 0);
|
||||
}
|
||||
|
||||
const char *text_context_dir[] = {"edit_text", NULL};
|
||||
const char *text_context_dir[] = {"edit_text", nullptr};
|
||||
|
||||
static int /*eContextResult*/ text_context(const bContext *C,
|
||||
const char *member,
|
||||
@@ -233,7 +233,7 @@ static int /*eContextResult*/ text_context(const bContext *C,
|
||||
return CTX_RESULT_OK;
|
||||
}
|
||||
if (CTX_data_equals(member, "edit_text")) {
|
||||
if (st->text != NULL) {
|
||||
if (st->text != nullptr) {
|
||||
CTX_data_id_pointer_set(result, &st->text->id);
|
||||
}
|
||||
return CTX_RESULT_OK;
|
||||
@@ -286,7 +286,7 @@ static void text_main_region_draw(const bContext *C, ARegion *region)
|
||||
|
||||
static void text_cursor(wmWindow *win, ScrArea *area, ARegion *region)
|
||||
{
|
||||
SpaceText *st = area->spacedata.first;
|
||||
SpaceText *st = static_cast<SpaceText *>(area->spacedata.first);
|
||||
int wmcursor = WM_CURSOR_TEXT_EDIT;
|
||||
|
||||
if (st->text && BLI_rcti_isect_pt(&st->runtime.scroll_region_handle,
|
||||
@@ -301,10 +301,10 @@ static void text_cursor(wmWindow *win, ScrArea *area, ARegion *region)
|
||||
|
||||
/* ************* dropboxes ************* */
|
||||
|
||||
static bool text_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
|
||||
static bool text_drop_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/)
|
||||
{
|
||||
if (drag->type == WM_DRAG_PATH) {
|
||||
const eFileSel_File_Types file_type = WM_drag_get_path_file_type(drag);
|
||||
const eFileSel_File_Types file_type = eFileSel_File_Types(WM_drag_get_path_file_type(drag));
|
||||
if (ELEM(file_type, 0, FILE_TYPE_PYSCRIPT, FILE_TYPE_TEXT)) {
|
||||
return true;
|
||||
}
|
||||
@@ -312,18 +312,18 @@ static bool text_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNU
|
||||
return false;
|
||||
}
|
||||
|
||||
static void text_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
|
||||
static void text_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
|
||||
{
|
||||
/* copy drag path to properties */
|
||||
RNA_string_set(drop->ptr, "filepath", WM_drag_get_path(drag));
|
||||
}
|
||||
|
||||
static bool text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
|
||||
static bool text_drop_paste_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/)
|
||||
{
|
||||
return (drag->type == WM_DRAG_ID);
|
||||
}
|
||||
|
||||
static void text_drop_paste(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
|
||||
static void text_drop_paste(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
|
||||
{
|
||||
char *text;
|
||||
ID *id = WM_drag_get_local_ID(drag, 0);
|
||||
@@ -339,8 +339,8 @@ static void text_dropboxes(void)
|
||||
{
|
||||
ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
|
||||
|
||||
WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy, NULL, NULL);
|
||||
WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste, NULL, NULL);
|
||||
WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy, nullptr, nullptr);
|
||||
WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste, nullptr, nullptr);
|
||||
}
|
||||
|
||||
/* ************* end drop *********** */
|
||||
@@ -348,7 +348,7 @@ static void text_dropboxes(void)
|
||||
/****************** header region ******************/
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void text_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
|
||||
static void text_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
|
||||
{
|
||||
ED_region_header_init(region);
|
||||
}
|
||||
@@ -390,15 +390,13 @@ static void text_properties_region_draw(const bContext *C, ARegion *region)
|
||||
}
|
||||
}
|
||||
|
||||
static void text_id_remap(ScrArea *UNUSED(area),
|
||||
SpaceLink *slink,
|
||||
const struct IDRemapper *mappings)
|
||||
static void text_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings)
|
||||
{
|
||||
SpaceText *stext = (SpaceText *)slink;
|
||||
BKE_id_remapper_apply(mappings, (ID **)&stext->text, ID_REMAP_APPLY_ENSURE_REAL);
|
||||
}
|
||||
|
||||
static void text_space_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
|
||||
static void text_space_blend_read_data(BlendDataReader * /*reader*/, SpaceLink *sl)
|
||||
{
|
||||
SpaceText *st = (SpaceText *)sl;
|
||||
memset(&st->runtime, 0x0, sizeof(st->runtime));
|
||||
@@ -419,7 +417,7 @@ static void text_space_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
|
||||
void ED_spacetype_text(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype text");
|
||||
SpaceType *st = static_cast<SpaceType *>(MEM_callocN(sizeof(SpaceType), "spacetype text"));
|
||||
ARegionType *art;
|
||||
|
||||
st->spaceid = SPACE_TEXT;
|
||||
@@ -440,7 +438,7 @@ void ED_spacetype_text(void)
|
||||
st->blend_write = text_space_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
||||
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype text region"));
|
||||
art->regionid = RGN_TYPE_WINDOW;
|
||||
art->init = text_main_region_init;
|
||||
art->draw = text_main_region_draw;
|
||||
@@ -450,7 +448,7 @@ void ED_spacetype_text(void)
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: properties */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
||||
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype text region"));
|
||||
art->regionid = RGN_TYPE_UI;
|
||||
art->prefsizex = UI_COMPACT_PANEL_WIDTH;
|
||||
art->keymapflag = ED_KEYMAP_UI;
|
||||
@@ -460,7 +458,7 @@ void ED_spacetype_text(void)
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: header */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
||||
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype text region"));
|
||||
art->regionid = RGN_TYPE_HEADER;
|
||||
art->prefsizey = HEADERY;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
|
||||
@@ -470,7 +468,7 @@ void ED_spacetype_text(void)
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: footer */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
||||
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype text region"));
|
||||
art->regionid = RGN_TYPE_FOOTER;
|
||||
art->prefsizey = HEADERY;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER;
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
#include "UI_interface.h"
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_intern.h" /* own include */
|
||||
#include "text_format.hh"
|
||||
#include "text_intern.hh" /* own include */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Public API
|
||||
@@ -155,7 +155,7 @@ static GHash *text_autocomplete_build(Text *text)
|
||||
|
||||
gh = BLI_ghash_str_new(__func__);
|
||||
|
||||
for (linep = text->lines.first; linep; linep = linep->next) {
|
||||
for (linep = static_cast<TextLine *>(text->lines.first); linep; linep = linep->next) {
|
||||
size_t i_start = 0;
|
||||
size_t i_end = 0;
|
||||
size_t i_pos = 0;
|
||||
@@ -217,7 +217,7 @@ static GHash *text_autocomplete_build(Text *text)
|
||||
tft = ED_text_format_get(text);
|
||||
|
||||
GHASH_ITER (gh_iter, gh) {
|
||||
const char *s = BLI_ghashIterator_getValue(&gh_iter);
|
||||
const char *s = static_cast<char *>(BLI_ghashIterator_getValue(&gh_iter));
|
||||
texttool_suggest_add(s, tft->format_identifier(s));
|
||||
}
|
||||
}
|
||||
@@ -288,7 +288,7 @@ static void confirm_suggestion(Text *text)
|
||||
/** \name Auto Complete Operator
|
||||
* \{ */
|
||||
|
||||
static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
@@ -588,10 +588,10 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
|
||||
|
||||
static void text_autocomplete_free(bContext *C, wmOperator *op)
|
||||
{
|
||||
GHash *gh = op->customdata;
|
||||
GHash *gh = static_cast<GHash *>(op->customdata);
|
||||
if (gh) {
|
||||
BLI_ghash_free(gh, NULL, MEM_freeN);
|
||||
op->customdata = NULL;
|
||||
BLI_ghash_free(gh, nullptr, MEM_freeN);
|
||||
op->customdata = nullptr;
|
||||
}
|
||||
|
||||
/* other stuff */
|
||||
@@ -31,8 +31,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_intern.h"
|
||||
#include "text_format.hh"
|
||||
#include "text_intern.hh"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
@@ -41,12 +41,12 @@
|
||||
/** \name Text Font Drawing
|
||||
* \{ */
|
||||
|
||||
typedef struct TextDrawContext {
|
||||
struct TextDrawContext {
|
||||
int font_id;
|
||||
int cwidth_px;
|
||||
int lheight_px;
|
||||
bool syntax_highlight;
|
||||
} TextDrawContext;
|
||||
};
|
||||
|
||||
static void text_draw_context_init(const SpaceText *st, TextDrawContext *tdc)
|
||||
{
|
||||
@@ -58,10 +58,10 @@ static void text_draw_context_init(const SpaceText *st, TextDrawContext *tdc)
|
||||
|
||||
static void text_font_begin(const TextDrawContext *tdc)
|
||||
{
|
||||
BLF_size(tdc->font_id, (float)tdc->lheight_px);
|
||||
BLF_size(tdc->font_id, float(tdc->lheight_px));
|
||||
}
|
||||
|
||||
static void text_font_end(const TextDrawContext *UNUSED(tdc)) {}
|
||||
static void text_font_end(const TextDrawContext * /*tdc*/) {}
|
||||
|
||||
static int text_font_draw(const TextDrawContext *tdc, int x, int y, const char *str)
|
||||
{
|
||||
@@ -207,7 +207,7 @@ void wrap_offset(
|
||||
text = st->text;
|
||||
|
||||
/* Move pointer to first visible line (top) */
|
||||
linep = text->lines.first;
|
||||
linep = static_cast<TextLine *>(text->lines.first);
|
||||
i = st->top;
|
||||
while (i > 0 && linep) {
|
||||
int lines = text_get_visible_lines(st, region, linep->line);
|
||||
@@ -416,7 +416,7 @@ static int text_draw_wrapped(const SpaceText *st,
|
||||
int mi, ma, mstart, mend; /* mem */
|
||||
char fmt_prev = 0xff;
|
||||
/* don't draw lines below this */
|
||||
const int clip_min_y = -(int)(st->runtime.lheight_px - 1);
|
||||
const int clip_min_y = -int(st->runtime.lheight_px - 1);
|
||||
|
||||
flatten_string(st, &fs, str);
|
||||
str = fs.buf;
|
||||
@@ -509,7 +509,7 @@ static void text_draw(const SpaceText *st,
|
||||
const bool use_syntax = (tdc->syntax_highlight && format);
|
||||
FlattenString fs;
|
||||
int columns, size, n, w = 0, padding, amount = 0;
|
||||
const char *in = NULL;
|
||||
const char *in = nullptr;
|
||||
|
||||
for (n = flatten_string(st, &fs, str), str = fs.buf; n > 0; n--) {
|
||||
columns = BLI_str_utf8_char_width_safe(str);
|
||||
@@ -567,7 +567,7 @@ static void text_draw(const SpaceText *st,
|
||||
/** \name Cache Utilities
|
||||
* \{ */
|
||||
|
||||
typedef struct DrawCache {
|
||||
struct DrawCache {
|
||||
int *line_height;
|
||||
int total_lines, nlines;
|
||||
|
||||
@@ -580,11 +580,12 @@ typedef struct DrawCache {
|
||||
/* for partial lines recalculation */
|
||||
short update_flag;
|
||||
int valid_head, valid_tail; /* amount of unchanged lines */
|
||||
} DrawCache;
|
||||
};
|
||||
|
||||
static void text_drawcache_init(SpaceText *st)
|
||||
{
|
||||
DrawCache *drawcache = MEM_callocN(sizeof(DrawCache), "text draw cache");
|
||||
DrawCache *drawcache = static_cast<DrawCache *>(
|
||||
MEM_callocN(sizeof(DrawCache), "text draw cache"));
|
||||
|
||||
drawcache->winx = -1;
|
||||
drawcache->nlines = BLI_listbase_count(&st->text->lines);
|
||||
@@ -599,13 +600,13 @@ static void text_update_drawcache(SpaceText *st, ARegion *region)
|
||||
int full_update = 0, nlines = 0;
|
||||
Text *txt = st->text;
|
||||
|
||||
if (st->runtime.drawcache == NULL) {
|
||||
if (st->runtime.drawcache == nullptr) {
|
||||
text_drawcache_init(st);
|
||||
}
|
||||
|
||||
text_update_character_width(st);
|
||||
|
||||
drawcache = st->runtime.drawcache;
|
||||
drawcache = static_cast<DrawCache *>(st->runtime.drawcache);
|
||||
nlines = drawcache->nlines;
|
||||
|
||||
/* check if full cache update is needed */
|
||||
@@ -634,7 +635,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *region)
|
||||
}
|
||||
|
||||
if (drawcache->update_flag) {
|
||||
TextLine *line = st->text->lines.first;
|
||||
TextLine *line = static_cast<TextLine *>(st->text->lines.first);
|
||||
int lineno = 0, size, lines_count;
|
||||
int *fp = drawcache->line_height, *new_tail, *old_tail;
|
||||
|
||||
@@ -642,10 +643,10 @@ static void text_update_drawcache(SpaceText *st, ARegion *region)
|
||||
size = sizeof(int) * nlines;
|
||||
|
||||
if (fp) {
|
||||
fp = MEM_reallocN(fp, size);
|
||||
fp = static_cast<int *>(MEM_reallocN(fp, size));
|
||||
}
|
||||
else {
|
||||
fp = MEM_callocN(size, "text drawcache line_height");
|
||||
fp = static_cast<int *>(MEM_callocN(size, "text drawcache line_height"));
|
||||
}
|
||||
|
||||
drawcache->valid_tail = drawcache->valid_head = 0;
|
||||
@@ -716,12 +717,12 @@ static void text_update_drawcache(SpaceText *st, ARegion *region)
|
||||
void text_drawcache_tag_update(SpaceText *st, const bool full)
|
||||
{
|
||||
/* This happens if text editor ops are called from Python. */
|
||||
if (st == NULL) {
|
||||
if (st == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (st->runtime.drawcache != NULL) {
|
||||
DrawCache *drawcache = st->runtime.drawcache;
|
||||
if (st->runtime.drawcache != nullptr) {
|
||||
DrawCache *drawcache = static_cast<DrawCache *>(st->runtime.drawcache);
|
||||
Text *txt = st->text;
|
||||
|
||||
if (drawcache->update_flag) {
|
||||
@@ -764,7 +765,7 @@ void text_drawcache_tag_update(SpaceText *st, const bool full)
|
||||
|
||||
void text_free_caches(SpaceText *st)
|
||||
{
|
||||
DrawCache *drawcache = st->runtime.drawcache;
|
||||
DrawCache *drawcache = static_cast<DrawCache *>(st->runtime.drawcache);
|
||||
|
||||
if (drawcache) {
|
||||
if (drawcache->line_height) {
|
||||
@@ -784,7 +785,7 @@ void text_free_caches(SpaceText *st)
|
||||
/* cache should be updated in caller */
|
||||
static int text_get_visible_lines_no(const SpaceText *st, int lineno)
|
||||
{
|
||||
const DrawCache *drawcache = st->runtime.drawcache;
|
||||
const DrawCache *drawcache = static_cast<const DrawCache *>(st->runtime.drawcache);
|
||||
|
||||
return drawcache->line_height[lineno];
|
||||
}
|
||||
@@ -853,7 +854,7 @@ int text_get_total_lines(SpaceText *st, ARegion *region)
|
||||
DrawCache *drawcache;
|
||||
|
||||
text_update_drawcache(st, region);
|
||||
drawcache = st->runtime.drawcache;
|
||||
drawcache = static_cast<DrawCache *>(st->runtime.drawcache);
|
||||
|
||||
return drawcache->total_lines;
|
||||
}
|
||||
@@ -910,13 +911,15 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *scroll, rcti *b
|
||||
CLAMP(st->runtime.scroll_region_handle.ymin, pix_bottom_margin, region->winy - pix_top_margin);
|
||||
CLAMP(st->runtime.scroll_region_handle.ymax, pix_bottom_margin, region->winy - pix_top_margin);
|
||||
|
||||
st->runtime.scroll_px_per_line = (pix_available > 0) ? (float)ltexth / pix_available : 0;
|
||||
st->runtime.scroll_px_per_line = (pix_available > 0) ? float(ltexth) / pix_available : 0;
|
||||
if (st->runtime.scroll_px_per_line < 0.1f) {
|
||||
st->runtime.scroll_px_per_line = 0.1f;
|
||||
}
|
||||
|
||||
curl_off = text_get_span_wrap(st, region, st->text->lines.first, st->text->curl);
|
||||
sell_off = text_get_span_wrap(st, region, st->text->lines.first, st->text->sell);
|
||||
curl_off = text_get_span_wrap(
|
||||
st, region, static_cast<TextLine *>(st->text->lines.first), st->text->curl);
|
||||
sell_off = text_get_span_wrap(
|
||||
st, region, static_cast<TextLine *>(st->text->lines.first), st->text->sell);
|
||||
lhlstart = MIN2(curl_off, sell_off);
|
||||
lhlend = MAX2(curl_off, sell_off);
|
||||
|
||||
@@ -1013,16 +1016,13 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back)
|
||||
BLI_rcti_size_y(&st->runtime.scroll_region_select));
|
||||
UI_GetThemeColor3fv(TH_HILITE, col);
|
||||
col[3] = 0.18f;
|
||||
UI_draw_roundbox_aa(
|
||||
&(const rctf){
|
||||
.xmin = st->runtime.scroll_region_select.xmin + 1,
|
||||
.xmax = st->runtime.scroll_region_select.xmax - 1,
|
||||
.ymin = st->runtime.scroll_region_select.ymin,
|
||||
.ymax = st->runtime.scroll_region_select.ymax,
|
||||
},
|
||||
true,
|
||||
rad,
|
||||
col);
|
||||
|
||||
rctf rect;
|
||||
rect.xmin = st->runtime.scroll_region_select.xmin + 1;
|
||||
rect.xmax = st->runtime.scroll_region_select.xmax - 1;
|
||||
rect.ymin = st->runtime.scroll_region_select.ymin;
|
||||
rect.ymax = st->runtime.scroll_region_select.ymax;
|
||||
UI_draw_roundbox_aa(&rect, true, rad, col);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -1117,7 +1117,7 @@ static void draw_documentation(const SpaceText *st, ARegion *region)
|
||||
buf[i] = '\0';
|
||||
if (lines >= 0) {
|
||||
y -= st->runtime.lheight_px;
|
||||
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, NULL);
|
||||
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, nullptr);
|
||||
}
|
||||
i = 0;
|
||||
br = DOC_WIDTH;
|
||||
@@ -1128,7 +1128,7 @@ static void draw_documentation(const SpaceText *st, ARegion *region)
|
||||
buf[br] = '\0';
|
||||
if (lines >= 0) {
|
||||
y -= st->runtime.lheight_px;
|
||||
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, NULL);
|
||||
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, nullptr);
|
||||
}
|
||||
p -= i - br - 1; /* Rewind pointer to last break */
|
||||
i = 0;
|
||||
@@ -1177,7 +1177,8 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
|
||||
top = texttool_suggest_top();
|
||||
|
||||
wrap_offset(st, region, st->text->curl, st->text->curc, &offl, &offc);
|
||||
vcurl = txt_get_span(st->text->lines.first, st->text->curl) - st->top + offl;
|
||||
vcurl = txt_get_span(static_cast<TextLine *>(st->text->lines.first), st->text->curl) - st->top +
|
||||
offl;
|
||||
vcurc = text_get_char_pos(st, st->text->curl->line, st->text->curc) - st->left + offc;
|
||||
|
||||
x = TXT_BODY_LEFT(st) + (vcurc * st->runtime.cwidth_px);
|
||||
@@ -1196,14 +1197,14 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
|
||||
}
|
||||
|
||||
/* not needed but stands out nicer */
|
||||
UI_draw_box_shadow(
|
||||
&(const rctf){
|
||||
.xmin = x,
|
||||
.xmax = x + boxw,
|
||||
.ymin = y - boxh,
|
||||
.ymax = y,
|
||||
},
|
||||
220);
|
||||
{
|
||||
rctf rect;
|
||||
rect.xmin = x;
|
||||
rect.xmax = x + boxw;
|
||||
rect.ymin = y - boxh;
|
||||
rect.ymax = y;
|
||||
UI_draw_box_shadow(&rect, 220);
|
||||
}
|
||||
|
||||
uint pos = GPU_vertformat_attr_add(
|
||||
immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
||||
@@ -1222,7 +1223,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
|
||||
}
|
||||
|
||||
for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) {
|
||||
int len = txt_utf8_forward_columns(item->name, SUGG_LIST_WIDTH, NULL) - item->name;
|
||||
int len = txt_utf8_forward_columns(item->name, SUGG_LIST_WIDTH, nullptr) - item->name;
|
||||
|
||||
y -= lheight;
|
||||
|
||||
@@ -1242,7 +1243,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
|
||||
}
|
||||
|
||||
format_draw_color(tdc, item->type);
|
||||
text_draw(st, tdc, str, 0, 0, x + margin_x, y - 1, NULL);
|
||||
text_draw(st, tdc, str, 0, 0, x + margin_x, y - 1, nullptr);
|
||||
|
||||
if (item == last) {
|
||||
break;
|
||||
@@ -1266,7 +1267,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *region)
|
||||
|
||||
/* Convert to view space character coordinates to determine if cursor is hidden */
|
||||
wrap_offset(st, region, text->sell, text->selc, &offl, &offc);
|
||||
vsell = txt_get_span(text->lines.first, text->sell) - st->top + offl;
|
||||
vsell = txt_get_span(static_cast<TextLine *>(text->lines.first), text->sell) - st->top + offl;
|
||||
vselc = text_get_char_pos(st, text->sell->line, text->selc) - st->left + offc;
|
||||
|
||||
if (vselc < 0) {
|
||||
@@ -1287,7 +1288,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *region)
|
||||
if (text->curl != text->sell || text->curc != text->selc) {
|
||||
/* Convert all to view space character coordinates */
|
||||
wrap_offset(st, region, text->curl, text->curc, &offl, &offc);
|
||||
vcurl = txt_get_span(text->lines.first, text->curl) - st->top + offl;
|
||||
vcurl = txt_get_span(static_cast<TextLine *>(text->lines.first), text->curl) - st->top + offl;
|
||||
vcurc = text_get_char_pos(st, text->curl->line, text->curc) - st->left + offc;
|
||||
|
||||
if (vcurc < 0) {
|
||||
@@ -1449,7 +1450,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
|
||||
linep = startl;
|
||||
c = startc;
|
||||
fc = BLI_str_utf8_offset_to_index(linep->line, startc);
|
||||
endl = NULL;
|
||||
endl = nullptr;
|
||||
endc = -1;
|
||||
find = -b;
|
||||
stack = 0;
|
||||
@@ -1559,7 +1560,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
|
||||
viewc = text_get_char_pos(st, startl->line, startc) - st->left + offc;
|
||||
|
||||
if (viewc >= 0) {
|
||||
viewl = txt_get_span(text->lines.first, startl) - st->top + offl;
|
||||
viewl = txt_get_span(static_cast<TextLine *>(text->lines.first), startl) - st->top + offl;
|
||||
|
||||
text_font_draw_character(
|
||||
tdc, x + viewc * st->runtime.cwidth_px, y - viewl * TXT_LINE_HEIGHT(st), ch);
|
||||
@@ -1573,7 +1574,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
|
||||
viewc = text_get_char_pos(st, endl->line, endc) - st->left + offc;
|
||||
|
||||
if (viewc >= 0) {
|
||||
viewl = txt_get_span(text->lines.first, endl) - st->top + offl;
|
||||
viewl = txt_get_span(static_cast<TextLine *>(text->lines.first), endl) - st->top + offl;
|
||||
|
||||
text_font_draw_character(
|
||||
tdc, x + viewc * st->runtime.cwidth_px, y - viewl * TXT_LINE_HEIGHT(st), ch);
|
||||
@@ -1609,10 +1610,10 @@ void draw_text_main(SpaceText *st, ARegion *region)
|
||||
st->runtime.lheight_px = (U.widget_unit * st->lheight) / 20;
|
||||
|
||||
/* don't draw lines below this */
|
||||
const int clip_min_y = -(int)(st->runtime.lheight_px - 1);
|
||||
const int clip_min_y = -int(st->runtime.lheight_px - 1);
|
||||
|
||||
st->runtime.viewlines = (st->runtime.lheight_px) ?
|
||||
(int)(region->winy - clip_min_y) / TXT_LINE_HEIGHT(st) :
|
||||
int(region->winy - clip_min_y) / TXT_LINE_HEIGHT(st) :
|
||||
0;
|
||||
|
||||
text_draw_context_init(st, &tdc);
|
||||
@@ -1629,7 +1630,7 @@ void draw_text_main(SpaceText *st, ARegion *region)
|
||||
|
||||
/* update syntax formatting if needed */
|
||||
tft = ED_text_format_get(text);
|
||||
tmp = text->lines.first;
|
||||
tmp = static_cast<TextLine *>(text->lines.first);
|
||||
lineno = 0;
|
||||
for (i = 0; i < st->top && tmp; i++) {
|
||||
if (tdc.syntax_highlight && !tmp->format) {
|
||||
@@ -1658,7 +1659,7 @@ void draw_text_main(SpaceText *st, ARegion *region)
|
||||
|
||||
text_font_begin(&tdc);
|
||||
|
||||
tdc.cwidth_px = max_ii((int)BLF_fixed_width(tdc.font_id), 1);
|
||||
tdc.cwidth_px = max_ii(int(BLF_fixed_width(tdc.font_id)), 1);
|
||||
st->runtime.cwidth_px = tdc.cwidth_px;
|
||||
|
||||
/* draw line numbers background */
|
||||
@@ -1759,7 +1760,7 @@ void text_update_character_width(SpaceText *st)
|
||||
|
||||
text_font_begin(&tdc);
|
||||
st->runtime.cwidth_px = BLF_fixed_width(tdc.font_id);
|
||||
st->runtime.cwidth_px = MAX2(st->runtime.cwidth_px, (char)1);
|
||||
st->runtime.cwidth_px = MAX2(st->runtime.cwidth_px, char(1));
|
||||
text_font_end(&tdc);
|
||||
}
|
||||
|
||||
@@ -1767,7 +1768,7 @@ bool ED_text_activate_in_screen(bContext *C, Text *text)
|
||||
{
|
||||
ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
|
||||
if (area) {
|
||||
SpaceText *st = area->spacedata.first;
|
||||
SpaceText *st = static_cast<SpaceText *>(area->spacedata.first);
|
||||
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
|
||||
st->text = text;
|
||||
if (region) {
|
||||
@@ -1785,7 +1786,7 @@ void ED_text_scroll_to_cursor(SpaceText *st, ARegion *region, const bool center)
|
||||
Text *text;
|
||||
int i, x, winx = region->winx;
|
||||
|
||||
if (ELEM(NULL, st, st->text, st->text->curl)) {
|
||||
if (ELEM(nullptr, st, st->text, st->text->curl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1793,7 +1794,7 @@ void ED_text_scroll_to_cursor(SpaceText *st, ARegion *region, const bool center)
|
||||
|
||||
text_update_character_width(st);
|
||||
|
||||
i = txt_get_span(text->lines.first, text->sell);
|
||||
i = txt_get_span(static_cast<TextLine *>(text->lines.first), text->sell);
|
||||
if (st->wordwrap) {
|
||||
int offl, offc;
|
||||
wrap_offset(st, region, text->sell, text->selc, &offl, &offc);
|
||||
@@ -1851,7 +1852,7 @@ void text_scroll_to_cursor__area(SpaceText *st, ScrArea *area, const bool center
|
||||
{
|
||||
ARegion *region;
|
||||
|
||||
if (ELEM(NULL, st, st->text, st->text->curl)) {
|
||||
if (ELEM(nullptr, st, st->text, st->text->curl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1875,13 +1876,13 @@ bool ED_text_region_location_from_cursor(SpaceText *st,
|
||||
const int cursor_co[2],
|
||||
int r_pixel_co[2])
|
||||
{
|
||||
TextLine *line = NULL;
|
||||
TextLine *line = nullptr;
|
||||
|
||||
if (!st->text) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
line = BLI_findlink(&st->text->lines, cursor_co[0]);
|
||||
line = static_cast<TextLine *>(BLI_findlink(&st->text->lines, cursor_co[0]));
|
||||
if (!line || (cursor_co[1] < 0) || (cursor_co[1] > line->len)) {
|
||||
goto error;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
* \ingroup sptext
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "ED_text.h"
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_format.hh"
|
||||
|
||||
/****************** flatten string **********************/
|
||||
|
||||
@@ -31,8 +31,8 @@ static void flatten_string_append(FlattenString *fs, const char *c, int accum, i
|
||||
int *naccum;
|
||||
fs->len *= 2;
|
||||
|
||||
nbuf = MEM_callocN(sizeof(*fs->buf) * fs->len, "fs->buf");
|
||||
naccum = MEM_callocN(sizeof(*fs->accum) * fs->len, "fs->accum");
|
||||
nbuf = static_cast<char *>(MEM_callocN(sizeof(*fs->buf) * fs->len, "fs->buf"));
|
||||
naccum = static_cast<int *>(MEM_callocN(sizeof(*fs->accum) * fs->len, "fs->accum"));
|
||||
|
||||
memcpy(nbuf, fs->buf, fs->pos * sizeof(*fs->buf));
|
||||
memcpy(naccum, fs->accum, fs->pos * sizeof(*fs->accum));
|
||||
@@ -99,7 +99,7 @@ void flatten_string_free(FlattenString *fs)
|
||||
|
||||
int flatten_string_strlen(FlattenString *fs, const char *str)
|
||||
{
|
||||
const int len = (fs->pos - (int)(str - fs->buf)) - 1;
|
||||
const int len = (fs->pos - int(str - fs->buf)) - 1;
|
||||
BLI_assert(strlen(str) == len);
|
||||
return len;
|
||||
}
|
||||
@@ -109,14 +109,14 @@ int text_check_format_len(TextLine *line, uint len)
|
||||
if (line->format) {
|
||||
if (strlen(line->format) < len) {
|
||||
MEM_freeN(line->format);
|
||||
line->format = MEM_mallocN(len + 2, "SyntaxFormat");
|
||||
line->format = static_cast<char *>(MEM_mallocN(len + 2, "SyntaxFormat"));
|
||||
if (!line->format) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
line->format = MEM_mallocN(len + 2, "SyntaxFormat");
|
||||
line->format = static_cast<char *>(MEM_mallocN(len + 2, "SyntaxFormat"));
|
||||
if (!line->format) {
|
||||
return 0;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ void text_format_fill_ascii(const char **str_p, char **fmt_p, const char type, c
|
||||
}
|
||||
|
||||
/* *** Registration *** */
|
||||
static ListBase tft_lb = {NULL, NULL};
|
||||
static ListBase tft_lb = {nullptr, nullptr};
|
||||
void ED_text_format_register(TextFormatType *tft)
|
||||
{
|
||||
BLI_addtail(&tft_lb, tft);
|
||||
@@ -179,7 +179,7 @@ TextFormatType *ED_text_format_get(Text *text)
|
||||
if (text_ext) {
|
||||
text_ext++; /* skip the '.' */
|
||||
/* Check all text formats in the static list */
|
||||
for (tft = tft_lb.first; tft; tft = tft->next) {
|
||||
for (tft = static_cast<TextFormatType *>(tft_lb.first); tft; tft = tft->next) {
|
||||
/* All formats should have an ext, but just in case */
|
||||
const char **ext;
|
||||
for (ext = tft->ext; *ext; ext++) {
|
||||
@@ -193,11 +193,11 @@ TextFormatType *ED_text_format_get(Text *text)
|
||||
|
||||
/* If we make it here we never found an extension that worked - return
|
||||
* the "default" text format */
|
||||
return tft_lb.first;
|
||||
return static_cast<TextFormatType *>(tft_lb.first);
|
||||
}
|
||||
|
||||
/* Return the "default" text format */
|
||||
return tft_lb.first;
|
||||
return static_cast<TextFormatType *>(tft_lb.first);
|
||||
}
|
||||
|
||||
const char *ED_text_format_comment_line_prefix(Text *text)
|
||||
@@ -208,14 +208,14 @@ const char *ED_text_format_comment_line_prefix(Text *text)
|
||||
|
||||
bool ED_text_is_syntax_highlight_supported(Text *text)
|
||||
{
|
||||
if (text == NULL) {
|
||||
if (text == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TextFormatType *tft;
|
||||
|
||||
const char *text_ext = BLI_path_extension(text->id.name + 2);
|
||||
if (text_ext == NULL) {
|
||||
if (text_ext == nullptr) {
|
||||
/* Extensionless data-blocks are considered highlightable as Python. */
|
||||
return true;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ bool ED_text_is_syntax_highlight_supported(Text *text)
|
||||
}
|
||||
|
||||
/* Check all text formats in the static list */
|
||||
for (tft = tft_lb.first; tft; tft = tft->next) {
|
||||
for (tft = static_cast<TextFormatType *>(tft_lb.first); tft; tft = tft->next) {
|
||||
/* All formats should have an ext, but just in case */
|
||||
const char **ext;
|
||||
for (ext = tft->ext; *ext; ext++) {
|
||||
@@ -8,18 +8,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
struct Text;
|
||||
|
||||
/* *** Flatten String *** */
|
||||
typedef struct FlattenString {
|
||||
struct FlattenString {
|
||||
char fixedbuf[256];
|
||||
int fixedaccum[256];
|
||||
|
||||
char *buf;
|
||||
int *accum;
|
||||
int pos, len;
|
||||
} FlattenString;
|
||||
};
|
||||
|
||||
/**
|
||||
* Format continuation flags (stored just after the NULL terminator).
|
||||
* Format continuation flags (stored just after the null terminator).
|
||||
*/
|
||||
enum {
|
||||
FMT_CONT_NOP = 0, /* no continuation */
|
||||
@@ -75,7 +77,7 @@ typedef struct TextFormatType {
|
||||
*/
|
||||
void (*format_line)(SpaceText *st, TextLine *line, bool do_next);
|
||||
|
||||
const char **ext; /* NULL terminated extensions */
|
||||
const char **ext; /* Null terminated extensions. */
|
||||
|
||||
/** The prefix of a single-line line comment (without trailing space). */
|
||||
const char *comment_line;
|
||||
@@ -104,15 +106,34 @@ enum {
|
||||
FMT_TYPE_DEFAULT = 'q',
|
||||
};
|
||||
|
||||
TextFormatType *ED_text_format_get(Text *text);
|
||||
TextFormatType *ED_text_format_get(struct Text *text);
|
||||
void ED_text_format_register(TextFormatType *tft);
|
||||
|
||||
/* formatters */
|
||||
void ED_text_format_register_py(void);
|
||||
void ED_text_format_register_osl(void);
|
||||
void ED_text_format_register_lua(void);
|
||||
void ED_text_format_register_pov(void);
|
||||
void ED_text_format_register_pov_ini(void);
|
||||
void ED_text_format_register_py();
|
||||
void ED_text_format_register_osl();
|
||||
void ED_text_format_register_lua();
|
||||
void ED_text_format_register_pov();
|
||||
void ED_text_format_register_pov_ini();
|
||||
|
||||
#define STR_LITERAL_STARTSWITH(str, str_literal, len_var) \
|
||||
(strncmp(str, str_literal, len_var = (sizeof(str_literal) - 1)) == 0)
|
||||
|
||||
/* Workaround `C1061` with MSVC (looks like a bug),
|
||||
* this can be removed if the issue is resolved.
|
||||
*
|
||||
* Add #MSVC_WORKAROUND_BREAK to break up else-if's blocks to be under 128.
|
||||
* `_keep_me` just ensures #MSVC_WORKAROUND_BREAK follows an #MSVC_WORKAROUND_INIT. */
|
||||
#ifdef _MSC_VER
|
||||
# define MSVC_WORKAROUND_INIT(i) \
|
||||
char _keep_me = 0; \
|
||||
i = -1; \
|
||||
((void)0)
|
||||
# define MSVC_WORKAROUND_BREAK(i) \
|
||||
} \
|
||||
((void)_keep_me); \
|
||||
if (i != -1) {
|
||||
#else
|
||||
# define MSVC_WORKAROUND_INIT(i) ((void)0)
|
||||
# define MSVC_WORKAROUND_BREAK(i)
|
||||
#endif
|
||||
@@ -6,7 +6,7 @@
|
||||
* \ingroup sptext
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "BKE_text.h"
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_format.hh"
|
||||
|
||||
/* *** Lua Keywords (for format_line) *** */
|
||||
|
||||
@@ -173,7 +173,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
int len, i;
|
||||
|
||||
/* Get continuation from previous line */
|
||||
if (line->prev && line->prev->format != NULL) {
|
||||
if (line->prev && line->prev->format != nullptr) {
|
||||
fmt = line->prev->format;
|
||||
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
||||
@@ -183,7 +183,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
}
|
||||
|
||||
/* Get original continuation from this line */
|
||||
if (line->format != NULL) {
|
||||
if (line->format != nullptr) {
|
||||
fmt = line->format;
|
||||
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
||||
@@ -258,7 +258,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
}
|
||||
/* Single line comment */
|
||||
else if (*str == '-' && *(str + 1) == '-') {
|
||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
|
||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
|
||||
}
|
||||
else if (ELEM(*str, '"', '\'')) {
|
||||
/* Strings */
|
||||
@@ -336,10 +336,10 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
flatten_string_free(&fs);
|
||||
}
|
||||
|
||||
void ED_text_format_register_lua(void)
|
||||
void ED_text_format_register_lua()
|
||||
{
|
||||
static TextFormatType tft = {NULL};
|
||||
static const char *ext[] = {"lua", NULL};
|
||||
static TextFormatType tft = {nullptr};
|
||||
static const char *ext[] = {"lua", nullptr};
|
||||
|
||||
tft.format_identifier = txtfmt_lua_format_identifier;
|
||||
tft.format_line = txtfmt_lua_format_line;
|
||||
@@ -6,7 +6,7 @@
|
||||
* \ingroup sptext
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "BKE_text.h"
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_format.hh"
|
||||
|
||||
/* *** Local Functions (for format_line) *** */
|
||||
|
||||
@@ -199,7 +199,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
int len, i;
|
||||
|
||||
/* Get continuation from previous line */
|
||||
if (line->prev && line->prev->format != NULL) {
|
||||
if (line->prev && line->prev->format != nullptr) {
|
||||
fmt = line->prev->format;
|
||||
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
||||
@@ -209,7 +209,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
}
|
||||
|
||||
/* Get original continuation from this line */
|
||||
if (line->format != NULL) {
|
||||
if (line->format != nullptr) {
|
||||
fmt = line->format;
|
||||
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
||||
@@ -271,7 +271,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
/* Deal with comments first */
|
||||
if (*str == '/' && *(str + 1) == '/') {
|
||||
/* fill the remaining line */
|
||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
|
||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
|
||||
}
|
||||
/* C-Style (multi-line) comments */
|
||||
else if (*str == '/' && *(str + 1) == '*') {
|
||||
@@ -354,10 +354,10 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
flatten_string_free(&fs);
|
||||
}
|
||||
|
||||
void ED_text_format_register_osl(void)
|
||||
void ED_text_format_register_osl()
|
||||
{
|
||||
static TextFormatType tft = {NULL};
|
||||
static const char *ext[] = {"osl", NULL};
|
||||
static TextFormatType tft = {nullptr};
|
||||
static const char *ext[] = {"osl", nullptr};
|
||||
|
||||
tft.format_identifier = txtfmt_osl_format_identifier;
|
||||
tft.format_line = txtfmt_osl_format_line;
|
||||
@@ -6,7 +6,7 @@
|
||||
* \ingroup sptext
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "BKE_text.h"
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_format.hh"
|
||||
|
||||
/* *** POV Keywords (for format_line) *** */
|
||||
|
||||
@@ -88,6 +88,7 @@ static int txtfmt_pov_find_reserved_keywords(const char *string)
|
||||
|
||||
/* Keep aligned args for readability. */
|
||||
/* clang-format off */
|
||||
MSVC_WORKAROUND_INIT(i);
|
||||
|
||||
/* Float Functions */
|
||||
if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) { i = len;
|
||||
@@ -185,6 +186,7 @@ static int txtfmt_pov_find_reserved_keywords(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "sky", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "up", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "ln", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
/* Color Identifiers */
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "filter", len)) { i = len;
|
||||
@@ -248,6 +250,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||
|
||||
/* Keep aligned args for readability. */
|
||||
/* clang-format off */
|
||||
MSVC_WORKAROUND_INIT(i);
|
||||
|
||||
/* Language Keywords */
|
||||
if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) { i = len;
|
||||
@@ -319,6 +322,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "now", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "pot", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "type", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
/* Animation Options */
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) { i = len;
|
||||
@@ -332,6 +336,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "clock", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
/* Spline Identifiers */
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "extended_x_spline", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "general_x_spline", len)) { i = len;
|
||||
@@ -347,6 +352,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
/* Patterns */
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) { i = len;
|
||||
@@ -399,6 +405,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "wood", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "agate", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
/* Objects */
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "bicubic_patch", len)) { i = len;
|
||||
@@ -467,13 +474,12 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||
} else { i = 0;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
/* clang-format on */
|
||||
|
||||
/* If next source char is an identifier (eg. 'i' in "definite") no match */
|
||||
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks the specified source string for a POV modifiers. This
|
||||
* name must start at the beginning of the source string and must be followed
|
||||
@@ -488,6 +494,11 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||
static int txtfmt_pov_find_specialvar(const char *string)
|
||||
{
|
||||
int i, len;
|
||||
|
||||
/* Keep aligned args for readability. */
|
||||
/* clang-format off */
|
||||
MSVC_WORKAROUND_INIT(i);
|
||||
|
||||
/* Modifiers */
|
||||
if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) { i = len;
|
||||
@@ -579,6 +590,7 @@ static int txtfmt_pov_find_specialvar(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "distance", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) { i = len;
|
||||
@@ -633,6 +645,7 @@ static int txtfmt_pov_find_specialvar(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "open", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "ior", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
/* Light Types and options. */
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) { i = len;
|
||||
@@ -643,6 +656,7 @@ static int txtfmt_pov_find_specialvar(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "radius", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
/* Camera Types and options. */
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "omni_directional_stereo", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "lambert_cylindrical", len)) { i = len;
|
||||
@@ -687,6 +701,8 @@ static int txtfmt_pov_find_specialvar(const char *string)
|
||||
} else { i = 0;
|
||||
}
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
/* If next source char is an identifier (eg. 'i' in "definite") no match */
|
||||
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
|
||||
}
|
||||
@@ -772,7 +788,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
int len, i;
|
||||
|
||||
/* Get continuation from previous line */
|
||||
if (line->prev && line->prev->format != NULL) {
|
||||
if (line->prev && line->prev->format != nullptr) {
|
||||
fmt = line->prev->format;
|
||||
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
||||
@@ -782,7 +798,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
}
|
||||
|
||||
/* Get original continuation from this line */
|
||||
if (line->format != NULL) {
|
||||
if (line->format != nullptr) {
|
||||
fmt = line->format;
|
||||
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
||||
@@ -851,7 +867,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
}
|
||||
/* Single line comment */
|
||||
else if (*str == '/' && *(str + 1) == '/') {
|
||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
|
||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
|
||||
}
|
||||
else if (ELEM(*str, '"', '\'')) {
|
||||
/* Strings */
|
||||
@@ -931,10 +947,10 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||
flatten_string_free(&fs);
|
||||
}
|
||||
|
||||
void ED_text_format_register_pov(void)
|
||||
void ED_text_format_register_pov()
|
||||
{
|
||||
static TextFormatType tft = {NULL};
|
||||
static const char *ext[] = {"pov", "inc", "mcr", "mac", NULL};
|
||||
static TextFormatType tft = {nullptr};
|
||||
static const char *ext[] = {"pov", "inc", "mcr", "mac", nullptr};
|
||||
|
||||
tft.format_identifier = txtfmt_pov_format_identifier;
|
||||
tft.format_line = txtfmt_pov_format_line;
|
||||
@@ -6,7 +6,7 @@
|
||||
* \ingroup sptext
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "BKE_text.h"
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_format.hh"
|
||||
|
||||
/* *** POV INI Keywords (for format_line) *** */
|
||||
|
||||
@@ -95,7 +95,7 @@ static int txtfmt_ini_find_reserved(const char *string)
|
||||
|
||||
/* Keep aligned args for readability. */
|
||||
/* clang-format off */
|
||||
|
||||
MSVC_WORKAROUND_INIT(i);
|
||||
/* POV-Ray Built-in INI Variables
|
||||
* list is from...
|
||||
* http://www.povray.org/documentation/view/3.7.0/212/
|
||||
@@ -158,6 +158,7 @@ static int txtfmt_ini_find_reserved(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "Create_Ini", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "Display_Gamma", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "Display", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "Version", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "Pause_When_Done", len)) { i = len;
|
||||
@@ -208,6 +209,7 @@ static int txtfmt_ini_find_reserved(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "WarningColour", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "ErrorColour", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "BackgroundColour", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "DropToEditor", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "LastRenderName", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "LastRenderPath", len)) { i = len;
|
||||
@@ -268,6 +270,7 @@ static int txtfmt_ini_find_reserved(const char *string)
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "Font", len)) { i = len;
|
||||
MSVC_WORKAROUND_BREAK(i)
|
||||
/* File-types. */
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "df3", len)) { i = len;
|
||||
} else if (STR_LITERAL_STARTSWITH(string, "exr", len)) { i = len;
|
||||
@@ -357,7 +360,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
|
||||
int len, i;
|
||||
|
||||
/* Get continuation from previous line */
|
||||
if (line->prev && line->prev->format != NULL) {
|
||||
if (line->prev && line->prev->format != nullptr) {
|
||||
fmt = line->prev->format;
|
||||
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
||||
@@ -367,7 +370,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
|
||||
}
|
||||
|
||||
/* Get original continuation from this line */
|
||||
if (line->format != NULL) {
|
||||
if (line->format != nullptr) {
|
||||
fmt = line->format;
|
||||
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
||||
@@ -429,7 +432,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
|
||||
/* Multi-line comments not supported */
|
||||
/* Single line comment */
|
||||
if (*str == ';') {
|
||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
|
||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
|
||||
}
|
||||
else if (ELEM(*str, '"', '\'')) {
|
||||
/* Strings */
|
||||
@@ -507,10 +510,10 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
|
||||
flatten_string_free(&fs);
|
||||
}
|
||||
|
||||
void ED_text_format_register_pov_ini(void)
|
||||
void ED_text_format_register_pov_ini()
|
||||
{
|
||||
static TextFormatType tft = {NULL};
|
||||
static const char *ext[] = {"ini", NULL};
|
||||
static TextFormatType tft = {nullptr};
|
||||
static const char *ext[] = {"ini", nullptr};
|
||||
|
||||
tft.format_identifier = txtfmt_pov_ini_format_identifier;
|
||||
tft.format_line = txtfmt_pov_ini_format_line;
|
||||
@@ -6,7 +6,7 @@
|
||||
* \ingroup sptext
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "BKE_text.h"
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_format.hh"
|
||||
|
||||
/* *** Local Functions (for format_line) *** */
|
||||
|
||||
@@ -239,7 +239,7 @@ static uint txtfmt_py_numeral_string_count_zeros(const char *string)
|
||||
|
||||
static int txtfmt_py_find_numeral_inner(const char *string)
|
||||
{
|
||||
if (string == NULL || *string == '\0') {
|
||||
if (string == nullptr || *string == '\0') {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ static int txtfmt_py_find_numeral_inner(const char *string)
|
||||
|
||||
static int txtfmt_py_literal_numeral(const char *string, char prev_fmt)
|
||||
{
|
||||
if (string == NULL || *string == '\0') {
|
||||
if (string == nullptr || *string == '\0') {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
|
||||
int len, i;
|
||||
|
||||
/* Get continuation from previous line */
|
||||
if (line->prev && line->prev->format != NULL) {
|
||||
if (line->prev && line->prev->format != nullptr) {
|
||||
fmt = line->prev->format;
|
||||
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
||||
@@ -349,7 +349,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
|
||||
}
|
||||
|
||||
/* Get original continuation from this line */
|
||||
if (line->format != NULL) {
|
||||
if (line->format != nullptr) {
|
||||
fmt = line->format;
|
||||
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
||||
@@ -411,7 +411,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
|
||||
/* Deal with comments first */
|
||||
if (*str == '#') {
|
||||
/* fill the remaining line */
|
||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
|
||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
|
||||
}
|
||||
else if (ELEM(*str, '"', '\'')) {
|
||||
/* Strings */
|
||||
@@ -546,10 +546,10 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
|
||||
flatten_string_free(&fs);
|
||||
}
|
||||
|
||||
void ED_text_format_register_py(void)
|
||||
void ED_text_format_register_py()
|
||||
{
|
||||
static TextFormatType tft = {NULL};
|
||||
static const char *ext[] = {"py", NULL};
|
||||
static TextFormatType tft = {nullptr};
|
||||
static const char *ext[] = {"py", nullptr};
|
||||
|
||||
tft.format_identifier = txtfmt_py_format_identifier;
|
||||
tft.format_line = txtfmt_py_format_line;
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "UI_interface.h"
|
||||
|
||||
#include "text_intern.h"
|
||||
#include "text_intern.hh"
|
||||
|
||||
/* ************************ header area region *********************** */
|
||||
|
||||
@@ -40,11 +40,11 @@ static ARegion *text_has_properties_region(ScrArea *area)
|
||||
region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
|
||||
|
||||
/* is error! */
|
||||
if (region == NULL) {
|
||||
return NULL;
|
||||
if (region == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
arnew = MEM_callocN(sizeof(ARegion), "properties region");
|
||||
arnew = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "properties region"));
|
||||
|
||||
BLI_insertlinkafter(&area->regionbase, region, arnew);
|
||||
arnew->regiontype = RGN_TYPE_UI;
|
||||
@@ -57,10 +57,10 @@ static ARegion *text_has_properties_region(ScrArea *area)
|
||||
|
||||
static bool text_properties_poll(bContext *C)
|
||||
{
|
||||
return (CTX_wm_space_text(C) != NULL);
|
||||
return (CTX_wm_space_text(C) != nullptr);
|
||||
}
|
||||
|
||||
static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_text_search_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
ARegion *region = text_has_properties_region(area);
|
||||
@@ -6,8 +6,8 @@
|
||||
* \ingroup sptext
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
# include "BPY_extern_run.h"
|
||||
#endif
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_intern.h"
|
||||
#include "text_format.hh"
|
||||
#include "text_intern.hh"
|
||||
|
||||
static void txt_screen_clamp(SpaceText *st, ARegion *region);
|
||||
|
||||
@@ -118,7 +118,7 @@ static char *buf_tabs_to_spaces(const char *in_buf, const int tab_size, int *r_o
|
||||
|
||||
/* Allocate output before with extra space for expanded tabs. */
|
||||
const int out_size = strlen(in_buf) + num_tabs * (tab_size - 1) + 1;
|
||||
char *out_buf = MEM_mallocN(out_size * sizeof(char), __func__);
|
||||
char *out_buf = static_cast<char *>(MEM_mallocN(out_size * sizeof(char), __func__));
|
||||
|
||||
/* Fill output buffer. */
|
||||
int spaces_until_tab = 0;
|
||||
@@ -169,8 +169,8 @@ static void text_select_update_primary_clipboard(const Text *text)
|
||||
if (!txt_has_sel(text)) {
|
||||
return;
|
||||
}
|
||||
char *buf = txt_sel_to_buf(text, NULL);
|
||||
if (buf == NULL) {
|
||||
char *buf = txt_sel_to_buf(text, nullptr);
|
||||
if (buf == nullptr) {
|
||||
return;
|
||||
}
|
||||
WM_clipboard_text_set(buf, true);
|
||||
@@ -183,7 +183,7 @@ static void text_select_update_primary_clipboard(const Text *text)
|
||||
/** \name Operator Poll
|
||||
* \{ */
|
||||
|
||||
static bool text_new_poll(bContext *UNUSED(C))
|
||||
static bool text_new_poll(bContext * /*C*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -272,7 +272,7 @@ void text_update_edited(Text *text)
|
||||
{
|
||||
TextLine *line;
|
||||
|
||||
for (line = text->lines.first; line; line = line->next) {
|
||||
for (line = static_cast<TextLine *>(text->lines.first); line; line = line->next) {
|
||||
text_update_line_edited(line);
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ void text_update_edited(Text *text)
|
||||
/** \name New Operator
|
||||
* \{ */
|
||||
|
||||
static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_new_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
@@ -298,7 +298,7 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
if (prop) {
|
||||
RNA_id_pointer_create(&text->id, &idptr);
|
||||
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
|
||||
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
|
||||
RNA_property_update(C, &ptr, prop);
|
||||
}
|
||||
else if (st) {
|
||||
@@ -338,13 +338,14 @@ void TEXT_OT_new(wmOperatorType *ot)
|
||||
|
||||
static void text_open_init(bContext *C, wmOperator *op)
|
||||
{
|
||||
PropertyPointerRNA *pprop;
|
||||
PropertyPointerRNA *pprop = static_cast<PropertyPointerRNA *>(
|
||||
MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"));
|
||||
|
||||
op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
|
||||
op->customdata = pprop;
|
||||
UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop);
|
||||
}
|
||||
|
||||
static void text_open_cancel(bContext *UNUSED(C), wmOperator *op)
|
||||
static void text_open_cancel(bContext * /*C*/, wmOperator *op)
|
||||
{
|
||||
MEM_freeN(op->customdata);
|
||||
}
|
||||
@@ -375,11 +376,11 @@ static int text_open_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* hook into UI */
|
||||
pprop = op->customdata;
|
||||
pprop = static_cast<PropertyPointerRNA *>(op->customdata);
|
||||
|
||||
if (pprop->prop) {
|
||||
RNA_id_pointer_create(&text->id, &idptr);
|
||||
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr, NULL);
|
||||
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr, nullptr);
|
||||
RNA_property_update(C, &pprop->ptr, pprop->prop);
|
||||
}
|
||||
else if (st) {
|
||||
@@ -398,7 +399,7 @@ static int text_open_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
@@ -440,7 +441,7 @@ void TEXT_OT_open(wmOperatorType *ot)
|
||||
FILE_DEFAULTDISPLAY,
|
||||
FILE_SORT_DEFAULT); /* TODO: relative_path. */
|
||||
RNA_def_boolean(
|
||||
ot->srna, "internal", 0, "Make Internal", "Make text file internal after loading");
|
||||
ot->srna, "internal", false, "Make Internal", "Make text file internal after loading");
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -462,7 +463,7 @@ static int text_reload_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* Don't make this part of 'poll', since 'Alt-R' will type 'R',
|
||||
* if poll checks for the filename. */
|
||||
if (text->filepath == NULL) {
|
||||
if (text->filepath == nullptr) {
|
||||
BKE_report(op->reports, RPT_ERROR, "This text has not been saved");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -516,10 +517,10 @@ void TEXT_OT_reload(wmOperatorType *ot)
|
||||
static bool text_unlink_poll(bContext *C)
|
||||
{
|
||||
/* it should be possible to unlink texts if they're lib-linked in... */
|
||||
return CTX_data_edit_text(C) != NULL;
|
||||
return CTX_data_edit_text(C) != nullptr;
|
||||
}
|
||||
|
||||
static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_unlink_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
@@ -528,11 +529,11 @@ static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
/* make the previous text active, if its not there make the next text active */
|
||||
if (st) {
|
||||
if (text->id.prev) {
|
||||
st->text = text->id.prev;
|
||||
st->text = static_cast<Text *>(text->id.prev);
|
||||
text_update_cursor_moved(C);
|
||||
}
|
||||
else if (text->id.next) {
|
||||
st->text = text->id.next;
|
||||
st->text = static_cast<Text *>(text->id.next);
|
||||
text_update_cursor_moved(C);
|
||||
}
|
||||
}
|
||||
@@ -540,7 +541,7 @@ static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
BKE_id_delete(bmain, text);
|
||||
|
||||
text_drawcache_tag_update(st, true);
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_REMOVED, NULL);
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_REMOVED, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -567,7 +568,7 @@ void TEXT_OT_unlink(wmOperatorType *ot)
|
||||
/** \name Make Internal Operator
|
||||
* \{ */
|
||||
|
||||
static int text_make_internal_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_make_internal_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
@@ -620,7 +621,7 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
|
||||
}
|
||||
|
||||
fp = BLI_fopen(filepath, "w");
|
||||
if (fp == NULL) {
|
||||
if (fp == nullptr) {
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
"Unable to save '%s': %s",
|
||||
@@ -629,7 +630,7 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
|
||||
return;
|
||||
}
|
||||
|
||||
for (tmp = text->lines.first; tmp; tmp = tmp->next) {
|
||||
for (tmp = static_cast<TextLine *>(text->lines.first); tmp; tmp = tmp->next) {
|
||||
fputs(tmp->line, fp);
|
||||
if (tmp->next) {
|
||||
fputc('\n', fp);
|
||||
@@ -674,8 +675,8 @@ static int text_save_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
/* Internal and texts without a filepath will go to "Save As". */
|
||||
if (text->filepath == NULL || (text->flags & TXT_ISMEM)) {
|
||||
WM_operator_name_call(C, "TEXT_OT_save_as", WM_OP_INVOKE_DEFAULT, NULL, event);
|
||||
if (text->filepath == nullptr || (text->flags & TXT_ISMEM)) {
|
||||
WM_operator_name_call(C, "TEXT_OT_save_as", WM_OP_INVOKE_DEFAULT, nullptr, event);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
return text_save_exec(C, op);
|
||||
@@ -726,7 +727,7 @@ static int text_save_as_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
@@ -784,7 +785,7 @@ static int text_run_script(bContext *C, ReportList *reports)
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
const bool is_live = (reports == NULL);
|
||||
const bool is_live = (reports == nullptr);
|
||||
|
||||
/* only for comparison */
|
||||
void *curl_prev = text->curl;
|
||||
@@ -793,7 +794,7 @@ static int text_run_script(bContext *C, ReportList *reports)
|
||||
if (BPY_run_text(C, text, reports, !is_live)) {
|
||||
if (is_live) {
|
||||
/* for nice live updates */
|
||||
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, nullptr);
|
||||
}
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -852,7 +853,7 @@ void TEXT_OT_run_script(wmOperatorType *ot)
|
||||
/** \name Refresh Pyconstraints Operator
|
||||
* \{ */
|
||||
|
||||
static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
static int text_refresh_pyconstraints_exec(bContext * /*C*/, wmOperator * /*op*/)
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
# if 0
|
||||
@@ -955,7 +956,7 @@ static int text_paste_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if (st->live_edit) {
|
||||
text_run_script(C, NULL);
|
||||
text_run_script(C, nullptr);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -979,7 +980,7 @@ void TEXT_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);
|
||||
@@ -991,7 +992,7 @@ void TEXT_OT_paste(wmOperatorType *ot)
|
||||
/** \name Duplicate Operator
|
||||
* \{ */
|
||||
|
||||
static int text_duplicate_line_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_duplicate_line_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
@@ -1003,7 +1004,7 @@ static int text_duplicate_line_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if (CTX_wm_space_text(C)->live_edit) {
|
||||
text_run_script(C, NULL);
|
||||
text_run_script(C, nullptr);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -1038,15 +1039,15 @@ static void txt_copy_clipboard(Text *text)
|
||||
return;
|
||||
}
|
||||
|
||||
buf = txt_sel_to_buf(text, NULL);
|
||||
buf = txt_sel_to_buf(text, nullptr);
|
||||
|
||||
if (buf) {
|
||||
WM_clipboard_text_set(buf, 0);
|
||||
WM_clipboard_text_set(buf, false);
|
||||
MEM_freeN(buf);
|
||||
}
|
||||
}
|
||||
|
||||
static int text_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_copy_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
@@ -1073,7 +1074,7 @@ void TEXT_OT_copy(wmOperatorType *ot)
|
||||
/** \name Cut Operator
|
||||
* \{ */
|
||||
|
||||
static int text_cut_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_cut_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
@@ -1090,7 +1091,7 @@ static int text_cut_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if (st->live_edit) {
|
||||
text_run_script(C, NULL);
|
||||
text_run_script(C, nullptr);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -1117,16 +1118,16 @@ void TEXT_OT_cut(wmOperatorType *ot)
|
||||
/** \name Indent or Autocomplete Operator
|
||||
* \{ */
|
||||
|
||||
static int text_indent_or_autocomplete_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_indent_or_autocomplete_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
TextLine *line = text->curl;
|
||||
bool text_before_cursor = text->curc != 0 && !ELEM(line->line[text->curc - 1], ' ', '\t');
|
||||
if (text_before_cursor && (txt_has_sel(text) == false)) {
|
||||
WM_operator_name_call(C, "TEXT_OT_autocomplete", WM_OP_INVOKE_DEFAULT, NULL, NULL);
|
||||
WM_operator_name_call(C, "TEXT_OT_autocomplete", WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
|
||||
}
|
||||
else {
|
||||
WM_operator_name_call(C, "TEXT_OT_indent", WM_OP_EXEC_DEFAULT, NULL, NULL);
|
||||
WM_operator_name_call(C, "TEXT_OT_indent", WM_OP_EXEC_DEFAULT, nullptr, nullptr);
|
||||
}
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1152,7 +1153,7 @@ void TEXT_OT_indent_or_autocomplete(wmOperatorType *ot)
|
||||
/** \name Indent Operator
|
||||
* \{ */
|
||||
|
||||
static int text_indent_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_indent_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
@@ -1198,7 +1199,7 @@ void TEXT_OT_indent(wmOperatorType *ot)
|
||||
/** \name Unindent Operator
|
||||
* \{ */
|
||||
|
||||
static int text_unindent_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_unindent_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
@@ -1239,7 +1240,7 @@ void TEXT_OT_unindent(wmOperatorType *ot)
|
||||
/** \name Line Break Operator
|
||||
* \{ */
|
||||
|
||||
static int text_line_break_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_line_break_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
@@ -1336,10 +1337,10 @@ static int text_comment_exec(bContext *C, wmOperator *op)
|
||||
void TEXT_OT_comment_toggle(wmOperatorType *ot)
|
||||
{
|
||||
static const EnumPropertyItem comment_items[] = {
|
||||
{0, "TOGGLE", 0, "Toggle Comments", NULL},
|
||||
{1, "COMMENT", 0, "Comment", NULL},
|
||||
{-1, "UNCOMMENT", 0, "Un-Comment", NULL},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, "TOGGLE", 0, "Toggle Comments", nullptr},
|
||||
{1, "COMMENT", 0, "Comment", nullptr},
|
||||
{-1, "UNCOMMENT", 0, "Un-Comment", nullptr},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
@@ -1356,7 +1357,7 @@ void TEXT_OT_comment_toggle(wmOperatorType *ot)
|
||||
/* properties */
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_enum(ot->srna, "type", comment_items, 0, "Type", "Add or remove comments");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -1367,9 +1368,9 @@ void TEXT_OT_comment_toggle(wmOperatorType *ot)
|
||||
|
||||
enum { TO_SPACES, TO_TABS };
|
||||
static const EnumPropertyItem whitespace_type_items[] = {
|
||||
{TO_SPACES, "SPACES", 0, "To Spaces", NULL},
|
||||
{TO_TABS, "TABS", 0, "To Tabs", NULL},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{TO_SPACES, "SPACES", 0, "To Spaces", nullptr},
|
||||
{TO_TABS, "TABS", 0, "To Tabs", nullptr},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
|
||||
@@ -1383,7 +1384,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* first convert to all space, this make it a lot easier to convert to tabs
|
||||
* because there is no mixtures of ' ' && '\t' */
|
||||
for (tmp = text->lines.first; tmp; tmp = tmp->next) {
|
||||
for (tmp = static_cast<TextLine *>(text->lines.first); tmp; tmp = tmp->next) {
|
||||
char *new_line;
|
||||
|
||||
BLI_assert(tmp->line);
|
||||
@@ -1400,16 +1401,16 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
|
||||
/* Put new_line in the tmp->line spot still need to try and set the curc correctly. */
|
||||
tmp->line = new_line;
|
||||
tmp->len = strlen(new_line);
|
||||
tmp->format = NULL;
|
||||
tmp->format = nullptr;
|
||||
if (tmp->len > max_len) {
|
||||
max_len = tmp->len;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == TO_TABS) {
|
||||
char *tmp_line = MEM_mallocN(sizeof(*tmp_line) * (max_len + 1), __func__);
|
||||
char *tmp_line = static_cast<char *>(MEM_mallocN(sizeof(*tmp_line) * (max_len + 1), __func__));
|
||||
|
||||
for (tmp = text->lines.first; tmp; tmp = tmp->next) {
|
||||
for (tmp = static_cast<TextLine *>(text->lines.first); tmp; tmp = tmp->next) {
|
||||
const char *text_check_line = tmp->line;
|
||||
const int text_check_line_len = tmp->len;
|
||||
char *tmp_line_cur = tmp_line;
|
||||
@@ -1476,7 +1477,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
|
||||
* still need to try and set the curc correctly. */
|
||||
tmp->line = BLI_strdup(tmp_line);
|
||||
tmp->len = strlen(tmp_line);
|
||||
tmp->format = NULL;
|
||||
tmp->format = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1520,7 +1521,7 @@ void TEXT_OT_convert_whitespace(wmOperatorType *ot)
|
||||
/** \name Select All Operator
|
||||
* \{ */
|
||||
|
||||
static int text_select_all_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_select_all_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
@@ -1552,7 +1553,7 @@ void TEXT_OT_select_all(wmOperatorType *ot)
|
||||
/** \name Select Line Operator
|
||||
* \{ */
|
||||
|
||||
static int text_select_line_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_select_line_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
@@ -1584,7 +1585,7 @@ void TEXT_OT_select_line(wmOperatorType *ot)
|
||||
/** \name Select Word Operator
|
||||
* \{ */
|
||||
|
||||
static int text_select_word_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_select_word_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
@@ -1631,7 +1632,7 @@ static int move_lines_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if (CTX_wm_space_text(C)->live_edit) {
|
||||
text_run_script(C, NULL);
|
||||
text_run_script(C, nullptr);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -1642,7 +1643,7 @@ void TEXT_OT_move_lines(wmOperatorType *ot)
|
||||
static const EnumPropertyItem direction_items[] = {
|
||||
{TXT_MOVE_LINE_UP, "UP", 0, "Up", ""},
|
||||
{TXT_MOVE_LINE_DOWN, "DOWN", 0, "Down", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
@@ -1680,7 +1681,7 @@ static const EnumPropertyItem move_type_items[] = {
|
||||
{NEXT_LINE, "NEXT_LINE", 0, "Next Line", ""},
|
||||
{PREV_PAGE, "PREVIOUS_PAGE", 0, "Previous Page", ""},
|
||||
{NEXT_PAGE, "NEXT_PAGE", 0, "Next Page", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
/* get cursor position in line by relative wrapped line and column positions */
|
||||
@@ -2170,7 +2171,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
|
||||
|
||||
/* ensure we have the right region, it's optional */
|
||||
if (region && region->regiontype != RGN_TYPE_WINDOW) {
|
||||
region = NULL;
|
||||
region = nullptr;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
@@ -2263,7 +2264,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
|
||||
cursor_skip(st, region, st->text, -st->runtime.viewlines, select);
|
||||
}
|
||||
else {
|
||||
cursor_skip(NULL, NULL, text, -10, select);
|
||||
cursor_skip(nullptr, nullptr, text, -10, select);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2272,7 +2273,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
|
||||
cursor_skip(st, region, st->text, st->runtime.viewlines, select);
|
||||
}
|
||||
else {
|
||||
cursor_skip(NULL, NULL, text, 10, select);
|
||||
cursor_skip(nullptr, nullptr, text, 10, select);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2291,7 +2292,7 @@ static int text_move_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
int type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
return text_move_cursor(C, type, 0);
|
||||
return text_move_cursor(C, type, false);
|
||||
}
|
||||
|
||||
void TEXT_OT_move(wmOperatorType *ot)
|
||||
@@ -2319,7 +2320,7 @@ static int text_move_select_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
int type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
return text_move_cursor(C, type, 1);
|
||||
return text_move_cursor(C, type, true);
|
||||
}
|
||||
|
||||
void TEXT_OT_move_select(wmOperatorType *ot)
|
||||
@@ -2352,16 +2353,18 @@ static int text_jump_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
int line = RNA_int_get(op->ptr, "line");
|
||||
short nlines = txt_get_span(text->lines.first, text->lines.last) + 1;
|
||||
short nlines = txt_get_span(static_cast<TextLine *>(text->lines.first),
|
||||
static_cast<TextLine *>(text->lines.last)) +
|
||||
1;
|
||||
|
||||
if (line < 1) {
|
||||
txt_move_toline(text, 1, 0);
|
||||
txt_move_toline(text, 1, false);
|
||||
}
|
||||
else if (line > nlines) {
|
||||
txt_move_toline(text, nlines - 1, 0);
|
||||
txt_move_toline(text, nlines - 1, false);
|
||||
}
|
||||
else {
|
||||
txt_move_toline(text, line - 1, 0);
|
||||
txt_move_toline(text, line - 1, false);
|
||||
}
|
||||
|
||||
text_update_cursor_moved(C);
|
||||
@@ -2370,7 +2373,7 @@ static int text_jump_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int text_jump_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int text_jump_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
return WM_operator_props_dialog_popup(C, op, 200);
|
||||
}
|
||||
@@ -2405,7 +2408,7 @@ static const EnumPropertyItem 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 text_delete_exec(bContext *C, wmOperator *op)
|
||||
@@ -2492,7 +2495,7 @@ static int text_delete_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if (st->live_edit) {
|
||||
text_run_script(C, NULL);
|
||||
text_run_script(C, nullptr);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -2520,7 +2523,7 @@ void TEXT_OT_delete(wmOperatorType *ot)
|
||||
DEL_NEXT_CHAR,
|
||||
"Type",
|
||||
"Which part of the text to delete");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -2529,7 +2532,7 @@ void TEXT_OT_delete(wmOperatorType *ot)
|
||||
/** \name Toggle Overwrite Operator
|
||||
* \{ */
|
||||
|
||||
static int text_toggle_overwrite_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_toggle_overwrite_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
|
||||
@@ -2588,7 +2591,7 @@ enum eScrollZone {
|
||||
SCROLLHANDLE_MAX_OUTSIDE,
|
||||
};
|
||||
|
||||
typedef struct TextScroll {
|
||||
struct TextScroll {
|
||||
int mval_prev[2];
|
||||
int mval_delta[2];
|
||||
|
||||
@@ -2605,7 +2608,7 @@ typedef struct TextScroll {
|
||||
} state;
|
||||
int ofs_delta[2];
|
||||
int ofs_delta_px[2];
|
||||
} TextScroll;
|
||||
};
|
||||
|
||||
static void text_scroll_state_init(TextScroll *tsc, SpaceText *st, ARegion *region)
|
||||
{
|
||||
@@ -2624,7 +2627,7 @@ static bool text_scroll_poll(bContext *C)
|
||||
{
|
||||
/* it should be possible to still scroll linked texts to read them,
|
||||
* even if they can't be edited... */
|
||||
return CTX_data_edit_text(C) != NULL;
|
||||
return CTX_data_edit_text(C) != nullptr;
|
||||
}
|
||||
|
||||
static int text_scroll_exec(bContext *C, wmOperator *op)
|
||||
@@ -2648,7 +2651,7 @@ static int text_scroll_exec(bContext *C, wmOperator *op)
|
||||
static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
TextScroll *tsc = op->customdata;
|
||||
TextScroll *tsc = static_cast<TextScroll *>(op->customdata);
|
||||
const int mval[2] = {event->xy[0], event->xy[1]};
|
||||
|
||||
text_update_character_width(st);
|
||||
@@ -2737,7 +2740,7 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
static void scroll_exit(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
TextScroll *tsc = op->customdata;
|
||||
TextScroll *tsc = static_cast<TextScroll *>(op->customdata);
|
||||
|
||||
st->flags &= ~ST_SCROLL_SELECT;
|
||||
|
||||
@@ -2754,7 +2757,7 @@ static void scroll_exit(bContext *C, wmOperator *op)
|
||||
|
||||
static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
TextScroll *tsc = op->customdata;
|
||||
TextScroll *tsc = static_cast<TextScroll *>(op->customdata);
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
||||
@@ -2800,7 +2803,7 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
return text_scroll_exec(C, op);
|
||||
}
|
||||
|
||||
tsc = MEM_callocN(sizeof(TextScroll), "TextScroll");
|
||||
tsc = static_cast<TextScroll *>(MEM_callocN(sizeof(TextScroll), "TextScroll"));
|
||||
tsc->is_first = true;
|
||||
tsc->zone = SCROLLHANDLE_BAR;
|
||||
|
||||
@@ -2868,14 +2871,14 @@ static bool text_region_scroll_poll(bContext *C)
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
||||
if (!st || !text) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!region || region->regiontype != RGN_TYPE_WINDOW) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
@@ -2915,7 +2918,7 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
tsc = MEM_callocN(sizeof(TextScroll), "TextScroll");
|
||||
tsc = static_cast<TextScroll *>(MEM_callocN(sizeof(TextScroll), "TextScroll"));
|
||||
tsc->is_first = true;
|
||||
tsc->is_scrollbar = true;
|
||||
tsc->zone = zone;
|
||||
@@ -2969,11 +2972,11 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot)
|
||||
/** \name Set Selection Operator
|
||||
* \{ */
|
||||
|
||||
typedef struct SetSelection {
|
||||
struct SetSelection {
|
||||
int selc, sell;
|
||||
short mval_prev[2];
|
||||
wmTimer *timer; /* needed for scrolling when mouse at region bounds */
|
||||
} SetSelection;
|
||||
};
|
||||
|
||||
static int flatten_width(SpaceText *st, const char *str)
|
||||
{
|
||||
@@ -3016,11 +3019,11 @@ static int flatten_column_to_offset(SpaceText *st, const char *str, int index)
|
||||
|
||||
static TextLine *get_line_pos_wrapped(SpaceText *st, ARegion *region, int *y)
|
||||
{
|
||||
TextLine *linep = st->text->lines.first;
|
||||
TextLine *linep = static_cast<TextLine *>(st->text->lines.first);
|
||||
int i, lines;
|
||||
|
||||
if (*y < -st->top) {
|
||||
return NULL; /* We are beyond the first line... */
|
||||
return nullptr; /* We are beyond the first line... */
|
||||
}
|
||||
|
||||
for (i = -st->top; i <= *y && linep; linep = linep->next, i += lines) {
|
||||
@@ -3142,11 +3145,11 @@ static void text_cursor_set_to_pos_wrapped(
|
||||
}
|
||||
}
|
||||
else if (y < 0) { /* Before start of text. */
|
||||
linep = st->text->lines.first;
|
||||
linep = static_cast<TextLine *>(st->text->lines.first);
|
||||
charp = 0;
|
||||
}
|
||||
else { /* Beyond end of text */
|
||||
linep = st->text->lines.last;
|
||||
linep = static_cast<TextLine *>(st->text->lines.last);
|
||||
charp = linep->len;
|
||||
}
|
||||
|
||||
@@ -3191,7 +3194,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *region, int x, int y,
|
||||
charp = &text->curc;
|
||||
}
|
||||
|
||||
y -= txt_get_span(text->lines.first, *linep) - st->top;
|
||||
y -= txt_get_span(static_cast<TextLine *>(text->lines.first), *linep) - st->top;
|
||||
|
||||
if (y > 0) {
|
||||
while (y-- != 0) {
|
||||
@@ -3223,7 +3226,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *region, int x, int y,
|
||||
|
||||
static void text_cursor_timer_ensure(bContext *C, SetSelection *ssel)
|
||||
{
|
||||
if (ssel->timer == NULL) {
|
||||
if (ssel->timer == nullptr) {
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
@@ -3239,20 +3242,20 @@ static void text_cursor_timer_remove(bContext *C, SetSelection *ssel)
|
||||
|
||||
WM_event_remove_timer(wm, win, ssel->timer);
|
||||
}
|
||||
ssel->timer = NULL;
|
||||
ssel->timer = nullptr;
|
||||
}
|
||||
|
||||
static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
SetSelection *ssel = op->customdata;
|
||||
SetSelection *ssel = static_cast<SetSelection *>(op->customdata);
|
||||
|
||||
if (event->mval[1] < 0 || event->mval[1] > region->winy) {
|
||||
text_cursor_timer_ensure(C, ssel);
|
||||
|
||||
if (event->type == TIMER) {
|
||||
text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], 1);
|
||||
text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], true);
|
||||
ED_text_scroll_to_cursor(st, region, false);
|
||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
||||
}
|
||||
@@ -3262,7 +3265,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev
|
||||
|
||||
if (event->type == TIMER) {
|
||||
text_cursor_set_to_pos(
|
||||
st, region, CLAMPIS(event->mval[0], 0, region->winx), event->mval[1], 1);
|
||||
st, region, CLAMPIS(event->mval[0], 0, region->winx), event->mval[1], true);
|
||||
ED_text_scroll_to_cursor(st, region, false);
|
||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
||||
}
|
||||
@@ -3271,7 +3274,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev
|
||||
text_cursor_timer_remove(C, ssel);
|
||||
|
||||
if (event->type != TIMER) {
|
||||
text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], 1);
|
||||
text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], true);
|
||||
ED_text_scroll_to_cursor(st, region, false);
|
||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
||||
|
||||
@@ -3284,7 +3287,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev
|
||||
static void text_cursor_set_exit(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
SetSelection *ssel = op->customdata;
|
||||
SetSelection *ssel = static_cast<SetSelection *>(op->customdata);
|
||||
|
||||
text_update_cursor_moved(C);
|
||||
text_select_update_primary_clipboard(st->text);
|
||||
@@ -3305,12 +3308,12 @@ static int text_selection_set_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
}
|
||||
|
||||
op->customdata = MEM_callocN(sizeof(SetSelection), "SetCursor");
|
||||
ssel = op->customdata;
|
||||
ssel = static_cast<SetSelection *>(op->customdata);
|
||||
|
||||
ssel->mval_prev[0] = event->mval[0];
|
||||
ssel->mval_prev[1] = event->mval[1];
|
||||
|
||||
ssel->sell = txt_get_span(st->text->lines.first, st->text->sell);
|
||||
ssel->sell = txt_get_span(static_cast<TextLine *>(st->text->lines.first), st->text->sell);
|
||||
ssel->selc = st->text->selc;
|
||||
|
||||
WM_event_add_modal_handler(C, op);
|
||||
@@ -3369,7 +3372,7 @@ static int text_cursor_set_exec(bContext *C, wmOperator *op)
|
||||
int x = RNA_int_get(op->ptr, "x");
|
||||
int y = RNA_int_get(op->ptr, "y");
|
||||
|
||||
text_cursor_set_to_pos(st, region, x, y, 0);
|
||||
text_cursor_set_to_pos(st, region, x, y, false);
|
||||
|
||||
text_update_cursor_moved(C);
|
||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
||||
@@ -3414,7 +3417,7 @@ void TEXT_OT_cursor_set(wmOperatorType *ot)
|
||||
/** \name Line Number Operator
|
||||
* \{ */
|
||||
|
||||
static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
||||
static int text_line_number_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
@@ -3448,9 +3451,9 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm
|
||||
}
|
||||
|
||||
jump_to *= 10;
|
||||
jump_to += (int)(event_ascii - '0');
|
||||
jump_to += int(event_ascii - '0');
|
||||
|
||||
txt_move_toline(text, jump_to - 1, 0);
|
||||
txt_move_toline(text, jump_to - 1, false);
|
||||
last_jump = time;
|
||||
|
||||
text_update_cursor_moved(C);
|
||||
@@ -3489,7 +3492,7 @@ static int text_insert_exec(bContext *C, wmOperator *op)
|
||||
|
||||
text_drawcache_tag_update(st, false);
|
||||
|
||||
str = RNA_string_get_alloc(op->ptr, "text", NULL, 0, &str_len);
|
||||
str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, &str_len);
|
||||
|
||||
ED_text_undo_push_init(C);
|
||||
|
||||
@@ -3561,7 +3564,7 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if (ret == OPERATOR_FINISHED && st->live_edit) {
|
||||
text_run_script(C, NULL);
|
||||
text_run_script(C, nullptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -3586,7 +3589,7 @@ void TEXT_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);
|
||||
}
|
||||
|
||||
@@ -3597,8 +3600,10 @@ void TEXT_OT_insert(wmOperatorType *ot)
|
||||
* \{ */
|
||||
|
||||
/* mode */
|
||||
#define TEXT_FIND 0
|
||||
#define TEXT_REPLACE 1
|
||||
enum {
|
||||
TEXT_FIND = 0,
|
||||
TEXT_REPLACE = 1,
|
||||
};
|
||||
|
||||
static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
||||
{
|
||||
@@ -3620,7 +3625,7 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
||||
|
||||
/* Replace current */
|
||||
if (mode != TEXT_FIND && txt_has_sel(text)) {
|
||||
tmp = txt_sel_to_buf(text, NULL);
|
||||
tmp = txt_sel_to_buf(text, nullptr);
|
||||
|
||||
if (flags & ST_MATCH_CASE) {
|
||||
found = STREQ(st->findstr, tmp);
|
||||
@@ -3635,7 +3640,7 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
||||
txt_insert_buf(text, st->replacestr, strlen(st->replacestr));
|
||||
if (text->curl && text->curl->format) {
|
||||
MEM_freeN(text->curl->format);
|
||||
text->curl->format = NULL;
|
||||
text->curl->format = nullptr;
|
||||
}
|
||||
text_update_cursor_moved(C);
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
|
||||
@@ -3643,7 +3648,7 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
||||
}
|
||||
}
|
||||
MEM_freeN(tmp);
|
||||
tmp = NULL;
|
||||
tmp = nullptr;
|
||||
}
|
||||
|
||||
/* Find next */
|
||||
@@ -3653,12 +3658,12 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
||||
}
|
||||
else if (flags & ST_FIND_ALL) {
|
||||
if (text->id.next) {
|
||||
text = st->text = text->id.next;
|
||||
text = st->text = static_cast<Text *>(text->id.next);
|
||||
}
|
||||
else {
|
||||
text = st->text = bmain->texts.first;
|
||||
text = st->text = static_cast<Text *>(bmain->texts.first);
|
||||
}
|
||||
txt_move_toline(text, 0, 0);
|
||||
txt_move_toline(text, 0, false);
|
||||
text_update_cursor_moved(C);
|
||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
|
||||
}
|
||||
@@ -3719,7 +3724,7 @@ static int text_replace_all(bContext *C)
|
||||
txt_insert_buf(text, st->replacestr, strlen(st->replacestr));
|
||||
if (text->curl && text->curl->format) {
|
||||
MEM_freeN(text->curl->format);
|
||||
text->curl->format = NULL;
|
||||
text->curl->format = nullptr;
|
||||
}
|
||||
found = txt_find_string(text, st->findstr, 0, flags & ST_MATCH_CASE);
|
||||
} while (found);
|
||||
@@ -3762,7 +3767,7 @@ void TEXT_OT_replace(wmOperatorType *ot)
|
||||
/* properties */
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_boolean(ot->srna, "all", false, "Replace All", "Replace all occurrences");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -3777,7 +3782,7 @@ static int text_find_set_selected_exec(bContext *C, wmOperator *op)
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
char *tmp;
|
||||
|
||||
tmp = txt_sel_to_buf(text, NULL);
|
||||
tmp = txt_sel_to_buf(text, nullptr);
|
||||
STRNCPY(st->findstr, tmp);
|
||||
MEM_freeN(tmp);
|
||||
|
||||
@@ -3806,13 +3811,13 @@ void TEXT_OT_find_set_selected(wmOperatorType *ot)
|
||||
/** \name Replace Set Selected
|
||||
* \{ */
|
||||
|
||||
static int text_replace_set_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int text_replace_set_selected_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
char *tmp;
|
||||
|
||||
tmp = txt_sel_to_buf(text, NULL);
|
||||
tmp = txt_sel_to_buf(text, nullptr);
|
||||
STRNCPY(st->replacestr, tmp);
|
||||
MEM_freeN(tmp);
|
||||
|
||||
@@ -3851,7 +3856,7 @@ static int text_jump_to_file_at_point_internal_exec(bContext *C, wmOperator *op)
|
||||
const int column = RNA_int_get(op->ptr, "column");
|
||||
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Text *text = NULL;
|
||||
Text *text = nullptr;
|
||||
|
||||
LISTBASE_FOREACH (Text *, text_iter, &bmain->texts) {
|
||||
if (text_iter->filepath && BLI_path_cmp(text_iter->filepath, filepath) == 0) {
|
||||
@@ -3860,11 +3865,11 @@ static int text_jump_to_file_at_point_internal_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
if (text == NULL) {
|
||||
if (text == nullptr) {
|
||||
text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain));
|
||||
}
|
||||
|
||||
if (text == NULL) {
|
||||
if (text == nullptr) {
|
||||
BKE_reportf(op->reports, RPT_WARNING, "File '%s' cannot be opened", filepath);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -3897,12 +3902,12 @@ void TEXT_OT_jump_to_file_at_point_internal(wmOperatorType *ot)
|
||||
/* flags */
|
||||
ot->flag = 0;
|
||||
|
||||
prop = RNA_def_string(ot->srna, "filepath", NULL, FILE_MAX, "Filepath", "");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
prop = RNA_def_string(ot->srna, "filepath", nullptr, FILE_MAX, "Filepath", "");
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
prop = RNA_def_int(ot->srna, "line", 0, 0, INT_MAX, "Line", "Line to jump to", 1, 10000);
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
prop = RNA_def_int(ot->srna, "column", 0, 0, INT_MAX, "Column", "Column to jump to", 1, 10000);
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -3917,7 +3922,7 @@ static const EnumPropertyItem resolution_items[] = {
|
||||
{RESOLVE_RELOAD, "RELOAD", 0, "Reload", ""},
|
||||
{RESOLVE_SAVE, "SAVE", 0, "Save", ""},
|
||||
{RESOLVE_MAKE_INTERNAL, "MAKE_INTERNAL", 0, "Make Internal", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static bool text_resolve_conflict_poll(bContext *C)
|
||||
@@ -3928,7 +3933,7 @@ static bool text_resolve_conflict_poll(bContext *C)
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((text->filepath != NULL) && !(text->flags & TXT_ISMEM));
|
||||
return ((text->filepath != nullptr) && !(text->flags & TXT_ISMEM));
|
||||
}
|
||||
|
||||
static int text_resolve_conflict_exec(bContext *C, wmOperator *op)
|
||||
@@ -3951,7 +3956,7 @@ static int text_resolve_conflict_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
uiPopupMenu *pup;
|
||||
@@ -4065,7 +4070,7 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot)
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean(
|
||||
ot->srna, "split_lines", 0, "Split Lines", "Create one object per line in the text");
|
||||
ot->srna, "split_lines", false, "Split Lines", "Create one object per line in the text");
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -6,8 +6,8 @@
|
||||
* \ingroup sptext
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
|
||||
#include "text_format.h"
|
||||
#include "text_intern.h"
|
||||
#include "text_format.hh"
|
||||
#include "text_intern.hh"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Implements ED Undo System
|
||||
@@ -52,12 +52,12 @@
|
||||
/**
|
||||
* Only stores the state of a text buffer.
|
||||
*/
|
||||
typedef struct TextState {
|
||||
struct TextState {
|
||||
BArrayState *buf_array_state;
|
||||
|
||||
int cursor_line, cursor_line_select;
|
||||
int cursor_column, cursor_column_select;
|
||||
} TextState;
|
||||
};
|
||||
|
||||
static void text_state_encode(TextState *state, Text *text, BArrayStore *buffer_store)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ static void text_state_decode(TextState *state, Text *text)
|
||||
/** \name Implements ED Undo System
|
||||
* \{ */
|
||||
|
||||
typedef struct TextUndoStep {
|
||||
struct TextUndoStep {
|
||||
UndoStep step;
|
||||
UndoRefID_Text text_ref;
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ typedef struct TextUndoStep {
|
||||
* the second is the state after the operation is done.
|
||||
*/
|
||||
TextState states[2];
|
||||
} TextUndoStep;
|
||||
};
|
||||
|
||||
static struct {
|
||||
BArrayStore *buffer_store;
|
||||
|
||||
Reference in New Issue
Block a user