Cleanup: use full sentences in text editor code-comments

Also minor improvements, clarifications.
This commit is contained in:
Campbell Barton
2025-08-02 13:21:27 +10:00
parent 6d899a6726
commit a3bf386d43
14 changed files with 458 additions and 456 deletions

View File

@@ -53,7 +53,7 @@ ccl_device_forceinline float sobol_burley(uint rev_bit_index,
result ^= sobol_burley_table[dimension][i + j];
i += j + 1;
/* We can't do `<<= j + 1"` because that can overflow the shift
/* We can't do `<<= j + 1` because that can overflow the shift
* operator, which doesn't do what we need, at least on x86. */
rev_bit_index <<= j;
rev_bit_index <<= 1;

View File

@@ -36,7 +36,7 @@
#include "RNA_path.hh"
#include "text_format.hh"
#include "text_intern.hh" /* own include */
#include "text_intern.hh" /* Own include. */
/* ******************** default callbacks for text space ***************** */
@@ -57,20 +57,20 @@ static SpaceLink *text_create(const ScrArea * /*area*/, const Scene * /*scene*/)
stext->runtime = MEM_new<SpaceText_Runtime>(__func__);
/* header */
/* Header. */
region = BKE_area_region_new();
BLI_addtail(&stext->regionbase, region);
region->regiontype = RGN_TYPE_HEADER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
/* footer */
/* Footer. */
region = BKE_area_region_new();
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 */
/* Properties region. */
region = BKE_area_region_new();
BLI_addtail(&stext->regionbase, region);
@@ -78,7 +78,7 @@ static SpaceLink *text_create(const ScrArea * /*area*/, const Scene * /*scene*/)
region->alignment = RGN_ALIGN_RIGHT;
region->flag = RGN_FLAG_HIDDEN;
/* main region */
/* Main region. */
region = BKE_area_region_new();
BLI_addtail(&stext->regionbase, region);
@@ -96,7 +96,7 @@ static void text_free(SpaceLink *sl)
stext->text = nullptr;
}
/* spacetype; init callback */
/* Spacetype; init callback. */
static void text_init(wmWindowManager * /*wm*/, ScrArea * /*area*/) {}
static SpaceLink *text_duplicate(SpaceLink *sl)
@@ -115,12 +115,12 @@ static void text_listener(const wmSpaceTypeListenerParams *params)
const wmNotifier *wmn = params->notifier;
SpaceText *st = static_cast<SpaceText *>(area->spacedata.first);
/* context changes */
/* context changes. */
switch (wmn->category) {
case NC_TEXT:
/* check if active text was changed, no need to redraw if text isn't active
* (reference == nullptr) means text was unlinked, should update anyway for this
* case -- no way to know was text active before unlinking or not */
/* Check if active text was changed, no need to redraw if text isn't active
* `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;
}
@@ -140,7 +140,7 @@ static void text_listener(const wmSpaceTypeListenerParams *params)
}
ED_area_tag_redraw(area);
ATTR_FALLTHROUGH; /* fall down to tag redraw */
ATTR_FALLTHROUGH; /* Fall down to tag redraw. */
case NA_ADDED:
case NA_REMOVED:
case NA_SELECTED:
@@ -247,7 +247,7 @@ static int /*eContextResult*/ text_context(const bContext *C,
/********************* main region ********************/
/* add handlers, stuff you only do once or on area/region changes */
/* Add handlers, stuff you only do once or on area/region changes. */
static void text_main_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap;
@@ -255,13 +255,13 @@ static void text_main_region_init(wmWindowManager *wm, ARegion *region)
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_STANDARD, region->winx, region->winy);
/* own keymap */
/* Own keymap. */
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
/* add drop boxes */
/* Add drop boxes. */
lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
WM_event_add_dropbox_handler(&region->runtime->handlers, lb);
@@ -269,22 +269,22 @@ static void text_main_region_init(wmWindowManager *wm, ARegion *region)
static void text_main_region_draw(const bContext *C, ARegion *region)
{
/* draw entirely, view changes should be handled here */
/* Draw entirely, view changes should be handled here. */
SpaceText *st = CTX_wm_space_text(C);
// View2D *v2d = &region->v2d;
/* clear and setup matrix */
/* Clear and setup matrix. */
UI_ThemeClearColor(TH_BACK);
// UI_view2d_view_ortho(v2d);
/* data... */
/* Data. */
draw_text_main(st, region);
/* reset view matrix */
/* Reset view matrix. */
// UI_view2d_view_restore(C);
/* scrollers? */
/* Scroll-bars? */
}
static void text_cursor(wmWindow *win, ScrArea *area, ARegion *region)
@@ -317,7 +317,7 @@ static bool text_drop_path_poll(bContext * /*C*/, wmDrag *drag, const wmEvent *
static void text_drop_path_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
{
/* copy drag path to properties */
/* Copy drag path to properties. */
RNA_string_set(drop->ptr, "filepath", WM_drag_get_single_path(drag));
}
@@ -330,7 +330,7 @@ static void text_drop_id_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
{
ID *id = WM_drag_get_local_ID(drag, 0);
/* copy drag path to properties */
/* Copy drag path to properties. */
std::string text = RNA_path_full_ID_py(id);
RNA_string_set(drop->ptr, "text", text.c_str());
}
@@ -346,7 +346,7 @@ static void text_drop_string_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *dro
RNA_string_set(drop->ptr, "text", str.c_str());
}
/* this region dropbox definition */
/* This region dropbox definition. */
static void text_dropboxes()
{
ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
@@ -361,7 +361,7 @@ static void text_dropboxes()
/****************** header region ******************/
/* add handlers, stuff you only do once or on area/region changes */
/* Add handlers, stuff you only do once or on area/region changes. */
static void text_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
{
ED_region_header_init(region);
@@ -374,7 +374,7 @@ static void text_header_region_draw(const bContext *C, ARegion *region)
/****************** properties region ******************/
/* add handlers, stuff you only do once or on area/region changes */
/* Add handlers, stuff you only do once or on area/region changes. */
static void text_properties_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap;
@@ -382,7 +382,7 @@ static void text_properties_region_init(wmWindowManager *wm, ARegion *region)
region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
ED_region_panels_init(wm, region);
/* own keymaps */
/* Own keymaps. */
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, RGN_TYPE_WINDOW);
WM_event_add_keymap_handler_v2d_mask(&region->runtime->handlers, keymap);
}
@@ -443,7 +443,7 @@ void ED_spacetype_text()
st->blend_read_after_liblink = nullptr;
st->blend_write = text_space_blend_write;
/* regions: main window */
/* Regions: main window. */
art = MEM_callocN<ARegionType>("spacetype text region");
art->regionid = RGN_TYPE_WINDOW;
art->init = text_main_region_init;
@@ -453,7 +453,7 @@ void ED_spacetype_text()
BLI_addhead(&st->regiontypes, art);
/* regions: properties */
/* Regions: properties. */
art = MEM_callocN<ARegionType>("spacetype text region");
art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_COMPACT_PANEL_WIDTH;
@@ -464,7 +464,7 @@ void ED_spacetype_text()
art->draw = text_properties_region_draw;
BLI_addhead(&st->regiontypes, art);
/* regions: header */
/* Regions: header. */
art = MEM_callocN<ARegionType>("spacetype text region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
@@ -474,7 +474,7 @@ void ED_spacetype_text()
art->draw = text_header_region_draw;
BLI_addhead(&st->regiontypes, art);
/* regions: footer */
/* Regions: footer. */
art = MEM_callocN<ARegionType>("spacetype text region");
art->regionid = RGN_TYPE_FOOTER;
art->prefsizey = HEADERY;

View File

@@ -31,7 +31,7 @@
#include "ED_undo.hh"
#include "text_format.hh"
#include "text_intern.hh" /* own include */
#include "text_intern.hh" /* Own include. */
/* -------------------------------------------------------------------- */
/** \name Public API
@@ -40,7 +40,7 @@
bool space_text_do_suggest_select(SpaceText *st, const ARegion *region, const int mval[2])
{
const int lheight = TXT_LINE_HEIGHT(st);
SuggItem *item, *first, *last /* , *sel */ /* UNUSED */;
SuggItem *item, *first, *last /* , *sel */ /* UNUSED. */;
TextLine *tmp;
int l, x, y, w, h, i;
int tgti, *top;
@@ -61,9 +61,9 @@ bool space_text_do_suggest_select(SpaceText *st, const ARegion *region, const in
return false;
}
/* Count the visible lines to the cursor */
/* Count the visible lines to the cursor. */
for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) {
/* pass */
/* Pass. */
}
if (l < 0) {
return false;
@@ -81,19 +81,19 @@ bool space_text_do_suggest_select(SpaceText *st, const ARegion *region, const in
return false;
}
/* Work out which of the items is at the top of the visible list */
/* Work out which of the items is at the top of the visible list. */
for (i = 0, item = first; i < *top && item->next; i++, item = item->next) {
/* pass */
/* Pass. */
}
/* Work out the target item index in the visible list */
/* Work out the target item index in the visible list. */
tgti = (y - mval[1] - 4) / lheight;
if (tgti < 0 || tgti > SUGG_LIST_SIZE) {
return true;
}
for (i = tgti; i > 0 && item->next; i--, item = item->next) {
/* pass */
/* Pass. */
}
if (item) {
texttool_suggest_select(item);
@@ -140,7 +140,7 @@ static GHash *text_autocomplete_build(Text *text)
texttool_text_set_active(text);
/* first get the word we're at */
/* First get the word we're at. */
{
const int i = text_find_identifier_start(text->curl->line, text->curc);
seek_len = text->curc - i;
@@ -149,7 +149,7 @@ static GHash *text_autocomplete_build(Text *text)
// BLI_strncpy_utf8(seek, seek_ptr, seek_len);
}
/* now walk over entire doc and suggest words */
/* Now walk over entire doc and suggest words. */
{
gh = BLI_ghash_str_new(__func__);
@@ -159,7 +159,7 @@ static GHash *text_autocomplete_build(Text *text)
size_t i_pos = 0;
while (i_start < linep->len) {
/* seek identifier beginning */
/* Seek identifier beginning. */
i_pos = i_start;
while ((i_start < linep->len) &&
!text_check_identifier_nodigit_unicode(
@@ -192,7 +192,7 @@ static GHash *text_autocomplete_build(Text *text)
str_sub[choice_len] = '\0';
if (!BLI_ghash_lookup(gh, str_sub)) {
char *str_dup = BLI_strdupn(str_sub, choice_len);
/* A 'set' would make more sense here */
/* A `set` would make more sense here. */
BLI_ghash_insert(gh, str_dup, str_dup);
}
str_sub[choice_len] = str_sub_last;
@@ -202,7 +202,7 @@ static GHash *text_autocomplete_build(Text *text)
i_start = i_end;
}
else {
/* highly unlikely, but prevent eternal loop */
/* Highly unlikely, but prevent eternal loop. */
i_start++;
}
}
@@ -211,7 +211,7 @@ static GHash *text_autocomplete_build(Text *text)
{
GHashIterator gh_iter;
/* get the formatter for highlighting */
/* Get the formatter for highlighting. */
TextFormatType *tft;
tft = ED_text_format_get(text);
@@ -266,7 +266,7 @@ static void confirm_suggestion(Text *text)
}
line = text->curl->line;
i = text_find_identifier_start(line, text->curc /* - skipleft */);
i = text_find_identifier_start(line, text->curc /* - skipleft. */);
over = text->curc - i;
// for (i = 0; i < skipleft; i++)
@@ -399,7 +399,7 @@ static wmOperatorStatus text_autocomplete_modal(bContext *C, wmOperator *op, con
draw = 1;
}
else {
/* Work out which char we are about to delete/pass */
/* Work out which char we are about to delete/pass. */
if (st->text->curl && st->text->curc > 0) {
char ch = st->text->curl->line[st->text->curc - 1];
if ((ch == '_' || !ispunct(ch)) && !text_check_whitespace(ch)) {
@@ -432,7 +432,7 @@ static wmOperatorStatus text_autocomplete_modal(bContext *C, wmOperator *op, con
draw = 1;
}
else {
/* Work out which char we are about to pass */
/* Work out which char we are about to pass. */
if (st->text->curl && st->text->curc < st->text->curl->len) {
char ch = st->text->curl->line[st->text->curc];
if ((ch == '_' || !ispunct(ch)) && !text_check_whitespace(ch)) {
@@ -549,7 +549,7 @@ static void text_autocomplete_free(bContext *C, wmOperator *op)
op->customdata = nullptr;
}
/* other stuff */
/* Other stuff. */
{
SpaceText *st = CTX_wm_space_text(C);
st->doplugins = false;
@@ -564,7 +564,7 @@ static void text_autocomplete_cancel(bContext *C, wmOperator *op)
void TEXT_OT_autocomplete(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Text Auto Complete";
ot->description = "Show a list of used text in the open document";
ot->idname = "TEXT_OT_autocomplete";
@@ -575,7 +575,7 @@ void TEXT_OT_autocomplete(wmOperatorType *ot)
ot->modal = text_autocomplete_modal;
ot->poll = text_space_edit_poll;
/* flags */
/* Flags. */
/* Undo is handled conditionally by this operator. */
ot->flag = OPTYPE_BLOCKING;
}

View File

@@ -108,7 +108,7 @@ static int text_font_draw_character_utf8(
}
#if 0
/* Formats every line of the current text */
/** Formats every line of the current text. */
static void txt_format_text(SpaceText *st)
{
TextLine *linep;
@@ -123,7 +123,7 @@ static void txt_format_text(SpaceText *st)
}
#endif
/* Sets the current drawing color based on the format character specified */
/** Sets the current drawing color based on the format character specified. */
static void format_draw_color(const TextDrawContext *tdc, char formatchar)
{
switch (formatchar) {
@@ -175,7 +175,7 @@ static void format_draw_color(const TextDrawContext *tdc, char formatchar)
* The maximum number of characters displayable in the region
* This equals region_width/font_width for the region
* - wrap_chars:
* Characters that allow wrapping. This equals [' ', '\t', '-']
* Characters that allow wrapping. This equals [" ", "\t", "-"]
*
* \code{.py}
* def wrap(line, view_width, wrap_chars):
@@ -225,16 +225,16 @@ void space_text_wrap_offset(
text = st->text;
/* Move pointer to first visible line (top) */
/* Move pointer to first visible line (top). */
linep = static_cast<TextLine *>(text->lines.first);
i = st->top;
while (i > 0 && linep) {
int lines = space_text_get_visible_lines(st, region, linep->line);
/* Line before top */
/* Line before top. */
if (linep == linein) {
if (lines <= i) {
/* no visible part of line */
/* No visible part of line. */
return;
}
}
@@ -258,9 +258,9 @@ void space_text_wrap_offset(
*offc = 0;
for (i = 0, j = 0; linep->line[j]; j += BLI_str_utf8_size_safe(linep->line + j)) {
int chars;
const int columns = BLI_str_utf8_char_width_safe(linep->line + j); /* = 1 for tab */
const int columns = BLI_str_utf8_char_width_safe(linep->line + j); /* = 1 for tab. */
/* Mimic replacement of tabs */
/* Mimic replacement of tabs. */
ch = linep->line[j];
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
@@ -335,9 +335,9 @@ void space_text_wrap_offset_in_line(
cursin = BLI_str_utf8_offset_to_column(linein->line, linein->len, cursin);
for (i = 0, j = 0; linein->line[j]; j += BLI_str_utf8_size_safe(linein->line + j)) {
const int columns = BLI_str_utf8_char_width_safe(linein->line + j); /* = 1 for tab */
const int columns = BLI_str_utf8_char_width_safe(linein->line + j); /* = 1 for tab. */
/* Mimic replacement of tabs */
/* Mimic replacement of tabs. */
ch = linein->line[j];
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
@@ -429,12 +429,12 @@ static int space_text_draw_wrapped(const SpaceText *st,
const bool use_syntax = (tdc->syntax_highlight && format);
FlattenString fs;
int basex, lines;
int i, wrap, end, max, columns, padding; /* column */
/* warning, only valid when 'use_syntax' is set */
int a, fstart, fpos; /* utf8 chars */
int mi, ma, mstart, mend; /* mem */
int i, wrap, end, max, columns, padding; /* Column. */
/* Warning, only valid when `use_syntax` is set. */
int a, fstart, fpos; /* UTF8 characters. */
int mi, ma, mstart, mend;
char fmt_prev = 0xff;
/* don't draw lines below this */
/* Don't draw lines below this. */
const int clip_min_y = -(st->runtime->lheight_px - 1);
flatten_string(st, &fs, str);
@@ -452,11 +452,11 @@ static int space_text_draw_wrapped(const SpaceText *st,
for (i = 0, mi = 0; str[mi]; i += columns, mi += BLI_str_utf8_size_safe(str + mi)) {
columns = BLI_str_utf8_char_width_safe(str + mi);
if (i + columns > end) {
/* skip hidden part of line */
/* Skip hidden part of line. */
if (skip) {
skip--;
if (use_syntax) {
/* currently fpos only used when formatting */
/* Currently fpos only used when formatting. */
fpos += BLI_strnlen_utf8(str + mstart, mend - mstart);
}
fstart = fpos;
@@ -466,7 +466,7 @@ static int space_text_draw_wrapped(const SpaceText *st,
continue;
}
/* Draw the visible portion of text on the overshot line */
/* Draw the visible portion of text on the overshot line. */
for (a = fstart, ma = mstart; ma < mend; a++) {
if (use_syntax) {
if (fmt_prev != format[a]) {
@@ -496,7 +496,7 @@ static int space_text_draw_wrapped(const SpaceText *st,
}
}
/* Draw the remaining text */
/* Draw the remaining text. */
for (a = fstart, ma = mstart; str[ma] && y > clip_min_y; a++) {
if (use_syntax) {
if (fmt_prev != format[a]) {
@@ -553,7 +553,7 @@ static void space_text_draw(const SpaceText *st,
}
if (!in) {
flatten_string_free(&fs);
return; /* String is shorter than shift or ends with a padding */
return; /* String is shorter than shift or ends with a padding. */
}
x += tdc->cwidth_px * padding;
@@ -588,7 +588,7 @@ struct DrawCache {
int *line_height;
int total_lines, nlines;
/* this is needed to check cache relevance */
/* This is needed to check cache relevance. */
int winx, wordwrap, showlinenrs, tabnumber;
short lheight;
char cwidth_px;
@@ -596,7 +596,7 @@ struct DrawCache {
/** For partial lines recalculation. */
bool update;
int valid_head, valid_tail; /* amount of unchanged lines */
int valid_head, valid_tail; /* Amount of unchanged lines. */
};
static void space_text_drawcache_init(SpaceText *st)
@@ -626,25 +626,25 @@ static void space_text_update_drawcache(SpaceText *st, const ARegion *region)
drawcache = static_cast<DrawCache *>(st->runtime->drawcache);
nlines = drawcache->nlines;
/* check if full cache update is needed */
/* Check if full cache update is needed. */
/* area was resized */
/* Area was resized. */
full_update |= drawcache->winx != region->winx;
/* word-wrapping option was toggled */
/* Word-wrapping option was toggled. */
full_update |= drawcache->wordwrap != st->wordwrap;
/* word-wrapping option was toggled */
/* Word-wrapping option was toggled. */
full_update |= drawcache->showlinenrs != st->showlinenrs;
/* word-wrapping option was toggled */
/* Word-wrapping option was toggled. */
full_update |= drawcache->tabnumber != st->tabnumber;
/* word-wrapping option was toggled */
/* Word-wrapping option was toggled. */
full_update |= drawcache->lheight != st->runtime->lheight_px;
/* word-wrapping option was toggled */
/* Word-wrapping option was toggled. */
full_update |= drawcache->cwidth_px != st->runtime->cwidth_px;
/* text datablock was changed */
/* Text datablock was changed. */
full_update |= !STREQLEN(drawcache->text_id, txt->id.name, MAX_ID_NAME - 2);
if (st->wordwrap) {
/* update line heights */
/* Update line heights. */
if (full_update || !drawcache->line_height) {
drawcache->valid_head = 0;
drawcache->valid_tail = 0;
@@ -678,11 +678,11 @@ static void space_text_update_drawcache(SpaceText *st, const ARegion *region)
}
while (line) {
if (drawcache->valid_head) { /* we're inside valid head lines */
if (drawcache->valid_head) { /* We're inside valid head lines. */
lines_count = fp[lineno];
drawcache->valid_head--;
}
else if (lineno > new_tail - fp) { /* we-re inside valid tail lines */
else if (lineno > new_tail - fp) { /* We-re inside valid tail lines. */
lines_count = fp[lineno];
}
else {
@@ -715,7 +715,7 @@ static void space_text_update_drawcache(SpaceText *st, const ARegion *region)
drawcache->nlines = nlines;
/* store settings */
/* Store settings. */
drawcache->winx = region->winx;
drawcache->wordwrap = st->wordwrap;
drawcache->lheight = st->runtime->lheight_px;
@@ -725,7 +725,7 @@ static void space_text_update_drawcache(SpaceText *st, const ARegion *region)
STRNCPY(drawcache->text_id, txt->id.name + 2);
/* clear update flag */
/* Clear update flag. */
drawcache->update = false;
drawcache->valid_head = 0;
drawcache->valid_tail = 0;
@@ -743,8 +743,8 @@ void space_text_drawcache_tag_update(SpaceText *st, const bool full)
Text *txt = st->text;
if (drawcache->update) {
/* happens when tagging update from space listener */
/* should do nothing to prevent locally tagged cache be fully recalculated */
/* Happens when tagging update from space listener. */
/* Should do nothing to prevent locally tagged cache be fully recalculated. */
return;
}
@@ -761,9 +761,9 @@ void space_text_drawcache_tag_update(SpaceText *st, const bool full)
drawcache->valid_tail = drawcache->nlines - curlno - 1;
}
/* quick cache recalculation is also used in delete operator,
/* Quick cache recalculation is also used in delete operator,
* which could merge lines which are adjacent to current selection lines
* expand recalculate area to this lines */
* expand recalculate area to this lines. */
if (drawcache->valid_head > 0) {
drawcache->valid_head--;
}
@@ -799,7 +799,7 @@ void space_text_free_caches(SpaceText *st)
/** \name Word-Wrap Utilities
* \{ */
/* cache should be updated in caller */
/** Cache should be updated in caller. */
static int space_text_get_visible_lines_no(const SpaceText *st, int lineno)
{
const DrawCache *drawcache = static_cast<const DrawCache *>(st->runtime->drawcache);
@@ -817,9 +817,9 @@ int space_text_get_visible_lines(const SpaceText *st, const ARegion *region, con
start = 0;
end = max;
for (i = 0, j = 0; str[j]; j += BLI_str_utf8_size_safe(str + j)) {
const int columns = BLI_str_utf8_char_width_safe(str + j); /* = 1 for tab */
const int columns = BLI_str_utf8_char_width_safe(str + j); /* = 1 for tab. */
/* Mimic replacement of tabs */
/* Mimic replacement of tabs. */
ch = str[j];
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
@@ -855,7 +855,7 @@ int space_text_get_span_wrap(const SpaceText *st,
int ret = 0;
const TextLine *tmp = from;
/* Look forwards */
/* Look forwards. */
while (tmp) {
if (tmp == to) {
return ret;
@@ -897,7 +897,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *r_scroll, rcti
ltexth = space_text_get_total_lines(st, region);
blank_lines = st->runtime->viewlines / 2;
/* nicer code: use scroll rect for entire bar */
/* Nicer code: use scroll rect for entire bar. */
r_back->xmin = region->winx - (0.6 * U.widget_unit);
r_back->xmax = region->winx;
r_back->ymin = 0;
@@ -908,8 +908,8 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *r_scroll, rcti
r_scroll->ymin = pix_top_margin;
r_scroll->ymax = pix_available;
/* when re-sizing a 2D Viewport with the bar at the bottom to a greater height
* more blank lines will be added */
/* When re-sizing a 2D Viewport with the bar at the bottom to a greater height
* more blank lines will be added. */
if (ltexth + blank_lines < st->top + st->runtime->viewlines) {
blank_lines = st->top + st->runtime->viewlines - ltexth;
}
@@ -919,7 +919,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *r_scroll, rcti
barheight = (ltexth > 0) ? (st->runtime->viewlines * pix_available) / ltexth : 0;
pix_bardiff = 0;
if (barheight < 20) {
pix_bardiff = 20 - barheight; /* take into account the now non-linear sizing of the bar */
pix_bardiff = 20 - barheight; /* Take into account the now non-linear sizing of the bar. */
barheight = 20;
}
barstart = (ltexth > 0) ? ((pix_available - pix_bardiff) * st->top) / ltexth : 0;
@@ -947,7 +947,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *r_scroll, rcti
/* The scroll-bar is non-linear sized. */
if (pix_bardiff > 0) {
/* the start of the highlight is in the current viewport */
/* The start of the highlight is in the current viewport. */
if (st->runtime->viewlines && lhlstart >= st->top &&
lhlstart <= st->top + st->runtime->viewlines)
{
@@ -970,7 +970,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *r_scroll, rcti
hlend = hlstart + 2;
}
/* the end of the highlight is in the current viewport */
/* The end of the highlight is in the current viewport. */
if (st->runtime->viewlines && lhlend >= st->top &&
lhlend <= st->top + st->runtime->viewlines)
{
@@ -1047,10 +1047,6 @@ static void draw_textscroll(const SpaceText *st, const rcti *scroll, const rcti
/** \} */
/* -------------------------------------------------------------------- */
/** \name Draw Documentation
* \{ */
/* -------------------------------------------------------------------- */
/** \name Draw Suggestion List
* \{ */
@@ -1090,8 +1086,8 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
x = TXT_BODY_LEFT(st) + (vcurc * st->runtime->cwidth_px);
y = region->winy - (vcurl + 1) * lheight - 2;
/* offset back so the start of the text lines up with the suggestions,
* not essential but makes suggestions easier to follow */
/* Offset back so the start of the text lines up with the suggestions,
* not essential but makes suggestions easier to follow. */
x -= st->runtime->cwidth_px *
(st->text->curc - text_find_identifier_start(st->text->curl->line, st->text->curc));
@@ -1102,7 +1098,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
x = std::max(0, region->winx - boxw);
}
/* not needed but stands out nicer */
/* Not needed but stands out nicer. */
{
rctf rect;
rect.xmin = x;
@@ -1123,9 +1119,9 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
immUnbindProgram();
/* Set the top 'item' of the visible list */
/* Set the top `item` of the visible list. */
for (i = 0, item = first; i < *top && item->next; i++, item = item->next) {
/* pass */
/* Pass. */
}
for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) {
@@ -1171,7 +1167,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *region)
int offl, offc;
const int lheight = TXT_LINE_HEIGHT(st);
/* Convert to view space character coordinates to determine if cursor is hidden */
/* Convert to view space character coordinates to determine if cursor is hidden. */
space_text_wrap_offset(st, region, text->sell, text->selc, &offl, &offc);
vsell = txt_get_span(static_cast<TextLine *>(text->lines.first), text->sell) - st->top + offl;
vselc = space_text_get_char_pos(st, text->sell->line, text->selc) - st->left + offc;
@@ -1182,7 +1178,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *region)
}
if (text->curl == text->sell && text->curc == text->selc && !st->line_hlight && hidden) {
/* Nothing to draw here */
/* Nothing to draw here. */
return;
}
@@ -1190,9 +1186,9 @@ static void draw_text_decoration(SpaceText *st, ARegion *region)
immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
/* Draw the selection */
/* Draw the selection. */
if (text->curl != text->sell || text->curc != text->selc) {
/* Convert all to view space character coordinates */
/* Convert all to view space character coordinates. */
space_text_wrap_offset(st, region, text->curl, text->curc, &offl, &offc);
vcurl = txt_get_span(static_cast<TextLine *>(text->lines.first), text->curl) - st->top + offl;
vcurc = space_text_get_char_pos(st, text->curl->line, text->curc) - st->left + offc;
@@ -1283,7 +1279,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *region)
y2 = y1 - (lheight);
}
if (!(y1 < 0 || y2 > region->winy)) { /* check we need to draw */
if (!(y1 < 0 || y2 > region->winy)) { /* Check we need to draw. */
float highlight_color[4];
UI_GetThemeColor4fv(TH_TEXT, highlight_color);
highlight_color[3] = 0.1f;
@@ -1295,7 +1291,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *region)
}
if (!hidden) {
/* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */
/* Draw the cursor itself (we draw the sel. cursor as this is the leading edge). */
int x = TXT_BODY_LEFT(st) + (vselc * st->runtime->cwidth_px);
int y = region->winy - vsell * lheight;
if (st->flags & ST_SCROLL_SELECT) {
@@ -1339,7 +1335,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
char ch;
/* syntax_highlight must be on or else the format string will be null */
/* Syntax_highlight must be on or else the format string will be null. */
if (!text->curl || !tdc->syntax_highlight) {
return;
}
@@ -1370,7 +1366,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
}
if (b > 0) {
/* opening bracket, search forward for close */
/* Opening bracket, search forward for close. */
fc++;
c += BLI_str_utf8_size_safe(linep->line + c);
while (linep) {
@@ -1403,7 +1399,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
}
}
else {
/* closing bracket, search backward for open */
/* Closing bracket, search backward for open. */
fc--;
if (c > 0) {
c -= linep->line + c - BLI_str_find_prev_char_utf8(linep->line + c, linep->line);
@@ -1463,7 +1459,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
y += st->runtime->scroll_ofs_px[1];
}
/* draw opening bracket */
/* Draw opening bracket. */
ch = startl->line[startc];
space_text_wrap_offset(st, region, startl, startc, &offl, &offc);
viewc = space_text_get_char_pos(st, startl->line, startc) - st->left + offc;
@@ -1477,7 +1473,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
tdc, x + viewc * st->runtime->cwidth_px + 1, y - viewl * TXT_LINE_HEIGHT(st), ch);
}
/* draw closing bracket */
/* Draw closing bracket. */
ch = endl->line[endc];
space_text_wrap_offset(st, region, endl, endc, &offl, &offc);
viewc = space_text_get_char_pos(st, endl->line, endc) - st->left + offc;
@@ -1510,7 +1506,7 @@ void draw_text_main(SpaceText *st, ARegion *region)
int wraplinecount = 0, wrap_skip = 0;
int margin_column_x;
/* if no text, nothing to do */
/* If no text, nothing to do. */
if (!text) {
return;
}
@@ -1518,7 +1514,7 @@ void draw_text_main(SpaceText *st, ARegion *region)
/* DPI controlled line height and font size. */
st->runtime->lheight_px = (U.widget_unit * st->lheight) / 20;
/* don't draw lines below this */
/* Don't draw lines below this. */
const int clip_min_y = -(st->runtime->lheight_px - 1);
st->runtime->viewlines = (st->runtime->lheight_px) ?
@@ -1529,15 +1525,15 @@ void draw_text_main(SpaceText *st, ARegion *region)
space_text_update_drawcache(st, region);
/* make sure all the positional pointers exist */
/* Make sure all the positional pointers exist. */
if (!text->curl || !text->sell || !text->lines.first || !text->lines.last) {
txt_clean_text(text);
}
/* Update rectangles for scroll. */
calc_text_rcts(st, region, &scroll, &back); /* scroll will hold the entire bar size */
calc_text_rcts(st, region, &scroll, &back); /* Scroll will hold the entire bar size. */
/* update syntax formatting if needed */
/* Update syntax formatting if needed. */
tft = ED_text_format_get(text);
tmp = static_cast<TextLine *>(text->lines.first);
lineno = 0;
@@ -1571,7 +1567,7 @@ void draw_text_main(SpaceText *st, ARegion *region)
tdc.cwidth_px = max_ii(int(BLF_fixed_width(tdc.font_id)), 1);
st->runtime->cwidth_px = tdc.cwidth_px;
/* draw line numbers background */
/* Draw line numbers background. */
if (st->showlinenrs) {
uint pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
@@ -1581,7 +1577,7 @@ void draw_text_main(SpaceText *st, ARegion *region)
immUnbindProgram();
}
else {
st->runtime->line_number_display_digits = 0; /* not used */
st->runtime->line_number_display_digits = 0; /* Not used. */
}
x = TXT_BODY_LEFT(st);
@@ -1594,10 +1590,10 @@ void draw_text_main(SpaceText *st, ARegion *region)
winx = region->winx - TXT_SCROLL_WIDTH;
/* draw cursor, margin, selection and highlight */
/* Draw cursor, margin, selection and highlight. */
draw_text_decoration(st, region);
/* draw the text */
/* Draw the text. */
UI_FontThemeColor(tdc.font_id, TH_TEXT);
for (i = 0; y > clip_min_y && i < viewlines && tmp; i++, tmp = tmp->next) {
@@ -1615,13 +1611,13 @@ void draw_text_main(SpaceText *st, ARegion *region)
}
if (st->wordwrap) {
/* draw word wrapped text */
/* Draw word wrapped text. */
int lines = space_text_draw_wrapped(
st, &tdc, tmp->line, x, y, winx - x, tmp->format, wrap_skip);
y -= lines * TXT_LINE_HEIGHT(st);
}
else {
/* draw unwrapped text */
/* Draw unwrapped text. */
space_text_draw(
st, &tdc, tmp->line, st->left, region->winx / st->runtime->cwidth_px, x, y, tmp->format);
y -= TXT_LINE_HEIGHT(st);
@@ -1647,10 +1643,10 @@ void draw_text_main(SpaceText *st, ARegion *region)
}
}
/* draw other stuff */
/* Draw other stuff. */
draw_brackets(st, &tdc, region);
draw_textscroll(st, &scroll, &back);
/* draw_documentation(st, region); - No longer supported */
/* Draw_documentation(st, region); - No longer supported. */
draw_suggestion_list(st, &tdc, region);
text_font_end(&tdc);

View File

@@ -178,13 +178,13 @@ TextFormatType *ED_text_format_get(Text *text)
if (text) {
const char *text_ext = strchr(text->id.name + 2, '.');
if (text_ext) {
text_ext++; /* skip the '.' */
/* Check all text formats in the static list */
text_ext++; /* Skip the `.`. */
/* Check all text formats in the static list. */
LISTBASE_FOREACH (TextFormatType *, tft, &tft_lb) {
/* All formats should have an ext, but just in case */
/* All formats should have an ext, but just in case. */
const char **ext;
for (ext = tft->ext; *ext; ext++) {
/* If extension matches text name, return the matching tft */
/* If extension matches text name, return the matching tft. */
if (BLI_strcasecmp(text_ext, *ext) == 0) {
return tft;
}
@@ -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 */
* the "default" text format. */
return static_cast<TextFormatType *>(tft_lb.first);
}
/* Return the "default" text format */
/* Return the "default" text format. */
return static_cast<TextFormatType *>(tft_lb.first);
}
@@ -218,18 +218,18 @@ bool ED_text_is_syntax_highlight_supported(Text *text)
/* Extensionless data-blocks are considered highlightable as Python. */
return true;
}
text_ext++; /* skip the '.' */
text_ext++; /* Skip the `.`. */
if (BLI_string_is_decimal(text_ext)) {
/* "Text.001" is treated as extensionless, and thus highlightable. */
/* `Text.001` is treated as extensionless, and thus highlightable. */
return true;
}
/* Check all text formats in the static list */
/* Check all text formats in the static list. */
LISTBASE_FOREACH (TextFormatType *, tft, &tft_lb) {
/* All formats should have an ext, but just in case */
/* All formats should have an ext, but just in case. */
const char **ext;
for (ext = tft->ext; *ext; ext++) {
/* If extension matches text name, return the matching tft */
/* If extension matches text name, return the matching tft. */
if (BLI_strcasecmp(text_ext, *ext) == 0) {
return true;
}

View File

@@ -30,13 +30,18 @@ struct FlattenString {
* Format continuation flags (stored just after the null terminator).
*/
enum {
FMT_CONT_NOP = 0, /* no continuation */
FMT_CONT_QUOTESINGLE = (1 << 0), /* single quotes */
FMT_CONT_QUOTEDOUBLE = (1 << 1), /* double quotes */
FMT_CONT_TRIPLE = (1 << 2), /* triplets of quotes: """ or ''' */
/** No continuation. */
FMT_CONT_NOP = 0,
/** Single quotes. */
FMT_CONT_QUOTESINGLE = (1 << 0),
/** Double quotes. */
FMT_CONT_QUOTEDOUBLE = (1 << 1),
/** Triplets of quotes: `"""` or `'''`. */
FMT_CONT_TRIPLE = (1 << 2),
FMT_CONT_QUOTESINGLE_TRIPLE = (FMT_CONT_TRIPLE | FMT_CONT_QUOTESINGLE),
FMT_CONT_QUOTEDOUBLE_TRIPLE = (FMT_CONT_TRIPLE | FMT_CONT_QUOTEDOUBLE),
FMT_CONT_COMMENT_C = (1 << 3) /* multi-line comments, OSL only (C style) */
/** Multi-line comments, OSL only (C style). */
FMT_CONT_COMMENT_C = (1 << 3)
};
#define FMT_CONT_ALL \
(FMT_CONT_QUOTESINGLE | FMT_CONT_QUOTEDOUBLE | FMT_CONT_TRIPLE | FMT_CONT_COMMENT_C)
@@ -76,7 +81,7 @@ struct TextFormatType {
* the succeeding line if it is affected (eg. multi-line strings). Format strings
* may contain any of the following characters:
*
* It is terminated with a null-terminator '\0' followed by a continuation
* It is terminated with a null-terminator `\0 followed by a continuation
* flag indicating whether the line is part of a multi-line string.
*
* See: FMT_TYPE_ enums below
@@ -90,32 +95,33 @@ struct TextFormatType {
};
enum {
/** White-space */
/** White-space. */
FMT_TYPE_WHITESPACE = '_',
/** Comment text */
/** Comment text. */
FMT_TYPE_COMMENT = '#',
/** Punctuation and other symbols */
/** Punctuation and other symbols. */
FMT_TYPE_SYMBOL = '!',
/** Numerals */
/** Numerals. */
FMT_TYPE_NUMERAL = 'n',
/** String letters */
/** String letters. */
FMT_TYPE_STRING = 'l',
/** Decorator / Pre-processor directive */
/** Decorator / Pre-processor directive. */
FMT_TYPE_DIRECTIVE = 'd',
/** Special variables (class, def) */
/** Special variables (class, def). */
FMT_TYPE_SPECIAL = 'v',
/** Reserved keywords currently not in use, but still prohibited (OSL -> switch e.g.) */
/** Reserved keywords currently not in use, but still prohibited (OSL -> switch e.g.). */
FMT_TYPE_RESERVED = 'r',
/** Built-in names (return, for, etc.) */
/** Built-in names (return, for, etc.). */
FMT_TYPE_KEYWORD = 'b',
/** Regular text (identifiers, etc.) */
/** Regular text (identifiers, etc.). */
FMT_TYPE_DEFAULT = 'q',
};
TextFormatType *ED_text_format_get(Text *text);
void ED_text_format_register(TextFormatType *tft);
/* formatters */
/* Formatters. */
void ED_text_format_register_glsl();
void ED_text_format_register_py();
void ED_text_format_register_osl();

View File

@@ -293,7 +293,7 @@ static const Span<const char *> text_format_glsl_literals_reserved(
* https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf
*/
static const char *text_format_glsl_literals_specialvar_data[] = {
/* Force single column, sorted list */
/* Force single column, sorted list. */
/* clang-format off */
"gl_ClipDistance",
"gl_FragCoord",
@@ -333,8 +333,8 @@ static const Span<const char *> text_format_glsl_literals_specialvar(
/** \} */
/*---------------------------------------------------------------------*/
/* name local functions
*/
/** \name Local Functions
* \{ */
static int txtfmt_glsl_find_builtinfunc(const char *string)
{
@@ -368,7 +368,7 @@ static int txtfmt_glsl_find_preprocessor(const char *string)
{
if (string[0] == '#') {
int i = 1;
/* White-space is ok '# foo'. */
/* White-space is ok `# foo`. */
while (text_check_whitespace(string[i])) {
i++;
}
@@ -411,20 +411,20 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine *line, const bool do
char cont_orig, cont, find, prev = ' ';
int len, i;
/* Get continuation from previous line */
/* Get continuation from previous line. */
if (line->prev && line->prev->format != nullptr) {
fmt = line->prev->format;
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
BLI_assert((FMT_CONT_ALL & cont) == cont);
}
else {
cont = FMT_CONT_NOP;
}
/* Get original continuation from this line */
/* Get original continuation from this line. */
if (line->format != nullptr) {
fmt = line->format;
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
}
else {
@@ -440,7 +440,7 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine *line, const bool do
fmt = line->format;
while (*str) {
/* Handle escape sequences by skipping both \ and next char */
/* Handle escape sequences by skipping both \ and next char. */
if (*str == '\\') {
*fmt = prev;
fmt++;
@@ -453,9 +453,9 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine *line, const bool do
str += BLI_str_utf8_size_safe(str);
continue;
}
/* Handle continuations */
/* Handle continuations. */
if (cont) {
/* C-Style comments */
/* C-Style comments. */
if (cont & FMT_CONT_COMMENT_C) {
if (*str == '*' && *(str + 1) == '/') {
*fmt = FMT_TYPE_COMMENT;
@@ -467,7 +467,7 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine *line, const bool do
else {
*fmt = FMT_TYPE_COMMENT;
}
/* Handle other comments */
/* Handle other comments. */
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
@@ -481,12 +481,12 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine *line, const bool do
}
/* Not in a string... */
else {
/* Deal with comments first */
/* Deal with comments first. */
if (*str == '/' && *(str + 1) == '/') {
/* fill the remaining line */
/* Fill the remaining line. */
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
}
/* C-Style (multi-line) comments */
/* C-Style (multi-line) comments. */
else if (*str == '/' && *(str + 1) == '*') {
cont = FMT_CONT_COMMENT_C;
*fmt = FMT_TYPE_COMMENT;
@@ -495,7 +495,7 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine *line, const bool do
*fmt = FMT_TYPE_COMMENT;
}
else if (ELEM(*str, '"', '\'')) {
/* Strings */
/* Strings. */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
*fmt = FMT_TYPE_STRING;
@@ -504,13 +504,13 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine *line, const bool do
else if (*str == ' ') {
*fmt = FMT_TYPE_WHITESPACE;
}
/* Numbers (digits not part of an identifier and periods followed by digits) */
/* Numbers (digits not part of an identifier and periods followed by digits). */
else if ((prev != FMT_TYPE_DEFAULT && text_check_digit(*str)) ||
(*str == '.' && text_check_digit(*(str + 1))))
{
*fmt = FMT_TYPE_NUMERAL;
}
/* Punctuation */
/* Punctuation. */
else if ((*str != '#') && text_check_delim(*str)) {
*fmt = FMT_TYPE_SYMBOL;
}
@@ -525,7 +525,7 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine *line, const bool do
/* Keep aligned arguments for readability. */
/* clang-format off */
/* Special vars(v) or built-in keywords(b) */
/* Special vars(v) or built-in keywords(b). */
/* keep in sync with `txtfmt_glsl_format_identifier()`. */
if ((i = txtfmt_glsl_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
} else if ((i = txtfmt_glsl_find_builtinfunc(str)) != -1) { prev = FMT_TYPE_KEYWORD;
@@ -558,7 +558,7 @@ static void txtfmt_glsl_format_line(SpaceText *st, TextLine *line, const bool do
fmt++;
*fmt = cont;
/* If continuation has changed and we're allowed, process the next line */
/* If continuation has changed and we're allowed, process the next line. */
if (cont != cont_orig && do_next && line->next) {
txtfmt_glsl_format_line(st, line->next, do_next);
}

View File

@@ -111,7 +111,7 @@ static const char *text_format_osl_literals_reserved_data[] = {
static const Span<const char *> text_format_osl_literals_reserved(
text_format_osl_literals_reserved_data, ARRAY_SIZE(text_format_osl_literals_reserved_data));
/* OSL shader types */
/** OSL shader types. */
static const char *text_format_osl_literals_specialvar_data[] = {
/* Force single column, sorted list. */
/* clang-format off */
@@ -135,7 +135,7 @@ static int txtfmt_osl_find_builtinfunc(const char *string)
{
const int i = text_format_string_literal_find(text_format_osl_literals_builtinfunc, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
if (i == 0 || text_check_identifier(string[i])) {
return -1;
}
@@ -146,7 +146,7 @@ static int txtfmt_osl_find_reserved(const char *string)
{
const int i = text_format_string_literal_find(text_format_osl_literals_reserved, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
if (i == 0 || text_check_identifier(string[i])) {
return -1;
}
@@ -157,19 +157,19 @@ static int txtfmt_osl_find_specialvar(const char *string)
{
const int i = text_format_string_literal_find(text_format_osl_literals_specialvar, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
if (i == 0 || text_check_identifier(string[i])) {
return -1;
}
return i;
}
/* matches py 'txtfmt_osl_find_decorator' */
/* Matches Python's #txtfmt_osl_find_decorator. */
static int txtfmt_osl_find_preprocessor(const char *string)
{
if (string[0] == '#') {
int i = 1;
/* White-space is ok '# foo'. */
/* White-space is ok `# foo`. */
while (text_check_whitespace(string[i])) {
i++;
}
@@ -214,20 +214,20 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
char cont_orig, cont, find, prev = ' ';
int len, i;
/* Get continuation from previous line */
/* Get continuation from previous line. */
if (line->prev && line->prev->format != nullptr) {
fmt = line->prev->format;
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
BLI_assert((FMT_CONT_ALL & cont) == cont);
}
else {
cont = FMT_CONT_NOP;
}
/* Get original continuation from this line */
/* Get original continuation from this line. */
if (line->format != nullptr) {
fmt = line->format;
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
}
else {
@@ -243,7 +243,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
fmt = line->format;
while (*str) {
/* Handle escape sequences by skipping both \ and next char */
/* Handle escape sequences by skipping both \ and next char. */
if (*str == '\\') {
*fmt = prev;
fmt++;
@@ -256,9 +256,9 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
str += BLI_str_utf8_size_safe(str);
continue;
}
/* Handle continuations */
/* Handle continuations. */
if (cont) {
/* C-Style comments */
/* C-Style comments. */
if (cont & FMT_CONT_COMMENT_C) {
if (*str == '*' && *(str + 1) == '/') {
*fmt = FMT_TYPE_COMMENT;
@@ -270,7 +270,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
else {
*fmt = FMT_TYPE_COMMENT;
}
/* Handle other comments */
/* Handle other comments. */
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
@@ -284,12 +284,12 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
}
/* Not in a string... */
else {
/* Deal with comments first */
/* Deal with comments first. */
if (*str == '/' && *(str + 1) == '/') {
/* fill the remaining line */
/* Fill the remaining line. */
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
}
/* C-Style (multi-line) comments */
/* C-Style (multi-line) comments. */
else if (*str == '/' && *(str + 1) == '*') {
cont = FMT_CONT_COMMENT_C;
*fmt = FMT_TYPE_COMMENT;
@@ -298,7 +298,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
*fmt = FMT_TYPE_COMMENT;
}
else if (ELEM(*str, '"', '\'')) {
/* Strings */
/* Strings. */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
*fmt = FMT_TYPE_STRING;
@@ -307,13 +307,13 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
else if (*str == ' ') {
*fmt = FMT_TYPE_WHITESPACE;
}
/* Numbers (digits not part of an identifier and periods followed by digits) */
/* Numbers (digits not part of an identifier and periods followed by digits). */
else if ((prev != FMT_TYPE_DEFAULT && text_check_digit(*str)) ||
(*str == '.' && text_check_digit(*(str + 1))))
{
*fmt = FMT_TYPE_NUMERAL;
}
/* Punctuation */
/* Punctuation. */
else if ((*str != '#') && text_check_delim(*str)) {
*fmt = FMT_TYPE_SYMBOL;
}
@@ -328,7 +328,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
/* Keep aligned arguments for readability. */
/* clang-format off */
/* Special vars(v) or built-in keywords(b) */
/* Special vars(v) or built-in keywords(b). */
/* keep in sync with `txtfmt_osl_format_identifier()`. */
if ((i = txtfmt_osl_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
} else if ((i = txtfmt_osl_find_builtinfunc(str)) != -1) { prev = FMT_TYPE_KEYWORD;
@@ -356,12 +356,12 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
str++;
}
/* Terminate and add continuation char */
/* Terminate and add continuation char. */
*fmt = '\0';
fmt++;
*fmt = cont;
/* If continuation has changed and we're allowed, process the next line */
/* If continuation has changed and we're allowed, process the next line. */
if (cont != cont_orig && do_next && line->next) {
txtfmt_osl_format_line(st, line->next, do_next);
}

View File

@@ -21,7 +21,7 @@
/** \name Local Literal Definitions
* \{ */
/** Language Directives */
/** Language Directives. */
static const char *text_format_pov_literals_keyword_data[] = {
/* Force single column, sorted list. */
/* clang-format off */
@@ -67,7 +67,7 @@ static const Span<const char *> text_format_pov_literals_keyword(
* http://www.povray.org/documentation/view/3.7.0/212/
*/
/** Float Functions */
/** Float Functions. */
static const char *text_format_pov_literals_reserved_data[] = {
/* Force single column, sorted list. */
/* clang-format on */
@@ -215,7 +215,7 @@ static const Span<const char *> text_format_pov_literals_reserved(
* http://www.povray.org/documentation/view/3.7.0/212/
*/
/* Language Keywords */
/* Language Keywords. */
static const char *text_format_pov_literals_builtins_data[] = {
/* Force single column, sorted list. */
/* clang-format off */
@@ -690,7 +690,7 @@ static const Span<const char *> text_format_pov_literals_bool(
* \{ */
/**
* POV keyword (minus boolean & 'nil').
* POV keyword (minus boolean & `nil`).
* See:
* http://www.povray.org/documentation/view/3.7.0/212/
*/
@@ -700,7 +700,7 @@ static int txtfmt_pov_find_keyword(const char *string)
const int i = text_format_string_literal_find(text_format_pov_literals_keyword, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
}
@@ -708,7 +708,7 @@ static int txtfmt_pov_find_reserved_keywords(const char *string)
{
const int i = text_format_string_literal_find(text_format_pov_literals_reserved, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
}
@@ -716,7 +716,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
{
const int i = text_format_string_literal_find(text_format_pov_literals_builtins, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
}
@@ -724,7 +724,7 @@ static int txtfmt_pov_find_specialvar(const char *string)
{
const int i = text_format_string_literal_find(text_format_pov_literals_specialvar, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
}
@@ -732,7 +732,7 @@ static int txtfmt_pov_find_bool(const char *string)
{
const int i = text_format_string_literal_find(text_format_pov_literals_bool, string);
/* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */
/* If next source char is an identifier (eg. `i` in "Nonetheless") no match. */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
}
@@ -769,20 +769,20 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
char cont_orig, cont, find, prev = ' ';
int len, i;
/* Get continuation from previous line */
/* Get continuation from previous line. */
if (line->prev && line->prev->format != nullptr) {
fmt = line->prev->format;
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
BLI_assert((FMT_CONT_ALL & cont) == cont);
}
else {
cont = FMT_CONT_NOP;
}
/* Get original continuation from this line */
/* Get original continuation from this line. */
if (line->format != nullptr) {
fmt = line->format;
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
}
else {
@@ -798,7 +798,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
fmt = line->format;
while (*str) {
/* Handle escape sequences by skipping both \ and next char */
/* Handle escape sequences by skipping both \ and next char. */
if (*str == '\\') {
*fmt = prev;
fmt++;
@@ -811,9 +811,9 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
str += BLI_str_utf8_size_safe(str);
continue;
}
/* Handle continuations */
/* Handle continuations. */
if (cont) {
/* C-Style comments */
/* C-Style comments. */
if (cont & FMT_CONT_COMMENT_C) {
if (*str == '*' && *(str + 1) == '/') {
*fmt = FMT_TYPE_COMMENT;
@@ -825,7 +825,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
else {
*fmt = FMT_TYPE_COMMENT;
}
/* Handle other comments */
/* Handle other comments. */
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
@@ -839,7 +839,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
}
/* Not in a string... */
else {
/* C-Style (multi-line) comments */
/* C-Style (multi-line) comments. */
if (*str == '/' && *(str + 1) == '*') {
cont = FMT_CONT_COMMENT_C;
*fmt = FMT_TYPE_COMMENT;
@@ -847,12 +847,12 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
str++;
*fmt = FMT_TYPE_COMMENT;
}
/* Single line comment */
/* Single line comment. */
else if (*str == '/' && *(str + 1) == '/') {
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
}
else if (ELEM(*str, '"', '\'')) {
/* Strings */
/* Strings. */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
*fmt = FMT_TYPE_STRING;
@@ -861,13 +861,13 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
else if (*str == ' ') {
*fmt = FMT_TYPE_WHITESPACE;
}
/* Numbers (digits not part of an identifier and periods followed by digits) */
/* Numbers (digits not part of an identifier and periods followed by digits). */
else if ((prev != FMT_TYPE_DEFAULT && text_check_digit(*str)) ||
(*str == '.' && text_check_digit(*(str + 1))))
{
*fmt = FMT_TYPE_NUMERAL;
}
/* Booleans */
/* Booleans. */
else if (prev != FMT_TYPE_DEFAULT && (i = txtfmt_pov_find_bool(str)) != -1) {
if (i > 0) {
text_format_fill_ascii(&str, &fmt, FMT_TYPE_NUMERAL, i);
@@ -877,7 +877,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
*fmt = FMT_TYPE_DEFAULT;
}
}
/* Punctuation */
/* Punctuation. */
else if (text_check_delim(*str)) {
*fmt = FMT_TYPE_SYMBOL;
}
@@ -892,7 +892,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
/* Keep aligned arguments for readability. */
/* clang-format off */
/* Special vars(v) or built-in keywords(b) */
/* Special vars(v) or built-in keywords(b). */
/* keep in sync with `txtfmt_pov_format_identifier()`. */
if ((i = txtfmt_pov_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
} else if ((i = txtfmt_pov_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD;
@@ -916,12 +916,12 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
str++;
}
/* Terminate and add continuation char */
/* Terminate and add continuation char. */
*fmt = '\0';
fmt++;
*fmt = cont;
/* If continuation has changed and we're allowed, process the next line */
/* If continuation has changed and we're allowed, process the next line. */
if (cont != cont_orig && do_next && line->next) {
txtfmt_pov_format_line(st, line->next, do_next);
}

View File

@@ -27,7 +27,7 @@
* http://www.povray.org/documentation/view/3.7.0/212/
*/
/* Language Directives */
/* Language Directives. */
static const char *text_format_pov_ini_literals_keyword_data[] = {
/* Force single column, sorted list. */
@@ -282,7 +282,7 @@ static const Span<const char *> text_format_pov_ini_literals_reserved(
text_format_pov_ini_literals_reserved_data,
ARRAY_SIZE(text_format_pov_ini_literals_reserved_data));
/** POV INI Built-in Constants */
/** POV INI Built-in Constants. */
static const char *text_format_pov_ini_literals_bool_data[] = {
/* Force single column, sorted list. */
/* clang-format off */
@@ -315,7 +315,7 @@ static int txtfmt_ini_find_keyword(const char *string)
{
const int i = text_format_string_literal_find(text_format_pov_ini_literals_keyword, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
}
@@ -323,7 +323,7 @@ static int txtfmt_ini_find_reserved(const char *string)
{
const int i = text_format_string_literal_find(text_format_pov_ini_literals_reserved, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
}
@@ -331,7 +331,7 @@ static int txtfmt_ini_find_bool(const char *string)
{
const int i = text_format_string_literal_find(text_format_pov_ini_literals_bool, string);
/* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */
/* If next source char is an identifier (eg. `i` in "Nonetheless") no match. */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
}
@@ -364,20 +364,20 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
char cont_orig, cont, find, prev = ' ';
int len, i;
/* Get continuation from previous line */
/* Get continuation from previous line. */
if (line->prev && line->prev->format != nullptr) {
fmt = line->prev->format;
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
BLI_assert((FMT_CONT_ALL & cont) == cont);
}
else {
cont = FMT_CONT_NOP;
}
/* Get original continuation from this line */
/* Get original continuation from this line. */
if (line->format != nullptr) {
fmt = line->format;
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
}
else {
@@ -393,7 +393,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
fmt = line->format;
while (*str) {
/* Handle escape sequences by skipping both \ and next char */
/* Handle escape sequences by skipping both \ and next char. */
if (*str == '\\') {
*fmt = prev;
fmt++;
@@ -406,9 +406,9 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
str += BLI_str_utf8_size_safe(str);
continue;
}
/* Handle continuations */
/* Handle continuations. */
if (cont) {
/* Multi-line comments */
/* Multi-line comments. */
if (cont & FMT_CONT_COMMENT_C) {
if (*str == ']' && *(str + 1) == ']') {
*fmt = FMT_TYPE_COMMENT;
@@ -420,7 +420,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
else {
*fmt = FMT_TYPE_COMMENT;
}
/* Handle other comments */
/* Handle other comments. */
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
@@ -434,13 +434,13 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
}
/* Not in a string... */
else {
/* Multi-line comments not supported */
/* Single line comment */
/* Multi-line comments not supported. */
/* Single line comment. */
if (*str == ';') {
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
}
else if (ELEM(*str, '"', '\'')) {
/* Strings */
/* Strings. */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
*fmt = FMT_TYPE_STRING;
@@ -449,13 +449,13 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
else if (*str == ' ') {
*fmt = FMT_TYPE_WHITESPACE;
}
/* Numbers (digits not part of an identifier and periods followed by digits) */
/* Numbers (digits not part of an identifier and periods followed by digits). */
else if ((prev != FMT_TYPE_DEFAULT && text_check_digit(*str)) ||
(*str == '.' && text_check_digit(*(str + 1))))
{
*fmt = FMT_TYPE_NUMERAL;
}
/* Booleans */
/* Booleans. */
else if (prev != FMT_TYPE_DEFAULT && (i = txtfmt_ini_find_bool(str)) != -1) {
if (i > 0) {
text_format_fill_ascii(&str, &fmt, FMT_TYPE_NUMERAL, i);
@@ -465,7 +465,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
*fmt = FMT_TYPE_DEFAULT;
}
}
/* Punctuation */
/* Punctuation. */
else if ((*str != '#') && text_check_delim(*str)) {
*fmt = FMT_TYPE_SYMBOL;
}
@@ -475,12 +475,12 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
*fmt = FMT_TYPE_DEFAULT;
}
/* Not white-space, a digit, punctuation, or continuing text.
* Must be new, check for special words */
* Must be new, check for special words. */
else {
/* Keep aligned arguments for readability. */
/* clang-format off */
/* Special vars(v) or built-in keywords(b) */
/* Special vars(v) or built-in keywords(b). */
/* keep in sync with `txtfmt_ini_format_identifier()`. */
if ((i = txtfmt_ini_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD;
} else if ((i = txtfmt_ini_find_reserved(str)) != -1) { prev = FMT_TYPE_RESERVED;
@@ -501,12 +501,12 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
str++;
}
/* Terminate and add continuation char */
/* Terminate and add continuation char. */
*fmt = '\0';
fmt++;
*fmt = cont;
/* If continuation has changed and we're allowed, process the next line */
/* If continuation has changed and we're allowed, process the next line. */
if (cont != cont_orig && do_next && line->next) {
txtfmt_pov_ini_format_line(st, line->next, do_next);
}

View File

@@ -122,7 +122,7 @@ static int txtfmt_py_find_builtinfunc(const char *string)
{
const int i = text_format_string_literal_find(text_format_py_literals_builtinfunc, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
if (i == 0 || text_check_identifier(string[i])) {
return -1;
}
@@ -133,7 +133,7 @@ static int txtfmt_py_find_specialvar(const char *string)
{
const int i = text_format_string_literal_find(text_format_py_literals_specialvar, string);
/* If next source char is an identifier (eg. 'i' in "definite") no match */
/* If next source char is an identifier (eg. `i` in "definite") no match. */
if (i == 0 || text_check_identifier(string[i])) {
return -1;
}
@@ -164,7 +164,7 @@ static int txtfmt_py_find_bool(const char *string)
{
const int i = text_format_string_literal_find(text_format_py_literals_bool, string);
/* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */
/* If next source char is an identifier (eg. `i` in "Nonetheless") no match. */
if (i == 0 || text_check_identifier(string[i])) {
return -1;
}
@@ -251,19 +251,19 @@ static int txtfmt_py_find_numeral_inner(const char *string)
}
}
else if (first == '0') {
/* Numerals starting with '0x' or '0X' is followed by hexadecimal digits. */
/* Numerals starting with `0x` or `0X` is followed by hexadecimal digits. */
if (ELEM(second, 'x', 'X')) {
return 2 + txtfmt_py_numeral_string_count_hexadecimal(string + 2);
}
/* Numerals starting with '0o' or '0O' is followed by octal digits. */
/* Numerals starting with `0o` or `0O` is followed by octal digits. */
if (ELEM(second, 'o', 'O')) {
return 2 + txtfmt_py_numeral_string_count_octal(string + 2);
}
/* Numerals starting with '0b' or '0B' is followed by binary digits. */
/* Numerals starting with `0b` or `0B` is followed by binary digits. */
if (ELEM(second, 'b', 'B')) {
return 2 + txtfmt_py_numeral_string_count_binary(string + 2);
}
/* Other numerals starting with '0' can be followed by any number of '0' characters. */
/* Other numerals starting with `0` can be followed by any number of `0` characters. */
if (ELEM(second, '0', '_')) {
return 2 + txtfmt_py_numeral_string_count_zeros(string + 2);
}
@@ -285,17 +285,17 @@ static int txtfmt_py_literal_numeral(const char *string, char prev_fmt)
const char first = *string, second = *(string + 1);
if (prev_fmt == FMT_TYPE_NUMERAL) {
/* Previous was a number; if immediately followed by 'e' or 'E' and a digit,
/* Previous was a number; if immediately followed by `e` or `E` and a digit,
* it's a base 10 exponent (scientific notation). */
if (ELEM(first, 'e', 'E') && (text_check_digit(second) || second == '-')) {
return 1 + txtfmt_py_find_numeral_inner(string + 1);
}
/* Previous was a number; if immediately followed by '.' it's a floating point decimal number.
/* Previous was a number; if immediately followed by `.` it's a floating point decimal number.
* NOTE: keep the decimal point, it's needed to allow leading zeros. */
if (first == '.') {
return txtfmt_py_find_numeral_inner(string);
}
/* "Imaginary" part of a complex number ends with 'j' */
/* "Imaginary" part of a complex number ends with `j`. */
if (ELEM(first, 'j', 'J') && !text_check_digit(second)) {
return 1;
}
@@ -341,10 +341,10 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
char cont_orig, cont, find, prev = ' ';
int len, i;
/* Get continuation from previous line */
/* Get continuation from previous line. */
if (line->prev && line->prev->format != nullptr) {
fmt = line->prev->format;
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
BLI_assert((FMT_CONT_ALL & cont) == cont);
/* So slashes beginning on continuation display properly, see: #118767. */
if (cont & (FMT_CONT_QUOTEDOUBLE | FMT_CONT_QUOTESINGLE | FMT_CONT_TRIPLE)) {
@@ -355,10 +355,10 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
cont = FMT_CONT_NOP;
}
/* Get original continuation from this line */
/* Get original continuation from this line. */
if (line->format != nullptr) {
fmt = line->format;
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator. */
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
}
else {
@@ -374,7 +374,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
fmt = line->format;
while (*str) {
/* Handle escape sequences by skipping both \ and next char */
/* Handle escape sequences by skipping both \ and next char. */
if (*str == '\\') {
*fmt = prev;
fmt++;
@@ -387,9 +387,9 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
str += BLI_str_utf8_size_safe(str);
continue;
}
/* Handle continuations */
/* Handle continuations. */
if (cont) {
/* Triple strings ("""...""" or '''...''') */
/* Triple strings (`"""..."""` or `'''...'''`). */
if (cont & FMT_CONT_TRIPLE) {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
if (*str == find && *(str + 1) == find && *(str + 2) == find) {
@@ -401,7 +401,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
str++;
cont = FMT_CONT_NOP;
}
/* Handle other strings */
/* Handle other strings. */
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
@@ -415,13 +415,13 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
}
/* Not in a string... */
else {
/* Deal with comments first */
/* Deal with comments first. */
if (*str == '#') {
/* fill the remaining line */
/* Fill the remaining line. */
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
}
else if (ELEM(*str, '"', '\'')) {
/* Strings */
/* Strings. */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
if (*(str + 1) == find && *(str + 2) == find) {
@@ -487,7 +487,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
else if ((i = txtfmt_py_literal_numeral(str, prev)) > 0) {
text_format_fill(&str, &fmt, FMT_TYPE_NUMERAL, i);
}
/* Booleans */
/* Booleans. */
else if (prev != FMT_TYPE_DEFAULT && (i = txtfmt_py_find_bool(str)) != -1) {
if (i > 0) {
text_format_fill_ascii(&str, &fmt, FMT_TYPE_NUMERAL, i);
@@ -497,7 +497,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
*fmt = FMT_TYPE_DEFAULT;
}
}
/* Punctuation */
/* Punctuation. */
else if ((*str != '@') && text_check_delim(*str)) {
*fmt = FMT_TYPE_SYMBOL;
}
@@ -512,7 +512,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
/* Keep aligned arguments for readability. */
/* clang-format off */
/* Special vars(v) or built-in keywords(b) */
/* Special vars(v) or built-in keywords(b). */
/* keep in sync with `txtfmt_py_format_identifier()`. */
if ((i = txtfmt_py_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
} else if ((i = txtfmt_py_find_builtinfunc(str)) != -1) { prev = FMT_TYPE_KEYWORD;
@@ -540,12 +540,12 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
str++;
}
/* Terminate and add continuation char */
/* Terminate and add continuation char. */
*fmt = '\0';
fmt++;
*fmt = cont;
/* If continuation has changed and we're allowed, process the next line */
/* If continuation has changed and we're allowed, process the next line. */
if (cont != cont_orig && do_next && line->next) {
txtfmt_py_format_line(st, line->next, do_next);
}

View File

@@ -37,10 +37,10 @@ static ARegion *text_has_properties_region(ScrArea *area)
return region;
}
/* add subdiv level; after header */
/* Add subdiv level; after header. */
region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
/* is error! */
/* Is error! */
if (region == nullptr) {
return nullptr;
}
@@ -108,7 +108,7 @@ static wmOperatorStatus text_text_search_exec(bContext *C, wmOperator * /*op*/)
void TEXT_OT_start_find(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Find";
ot->description = "Start searching text";
ot->idname = "TEXT_OT_start_find";

View File

@@ -10,7 +10,7 @@
#include "DNA_vec_types.h"
/* internal exports only */
/* Internal exports only. */
struct ARegion;
struct ScrArea;
@@ -154,14 +154,14 @@ void TEXT_OT_selection_set(wmOperatorType *ot);
void TEXT_OT_cursor_set(wmOperatorType *ot);
void TEXT_OT_line_number(wmOperatorType *ot);
/* find = find indicated text */
/* The term: `find` means: find indicated text. */
void TEXT_OT_find(wmOperatorType *ot);
void TEXT_OT_find_set_selected(wmOperatorType *ot);
void TEXT_OT_replace(wmOperatorType *ot);
void TEXT_OT_replace_set_selected(wmOperatorType *ot);
void TEXT_OT_jump_to_file_at_point(wmOperatorType *ot);
/* text_find = open properties, activate search button */
/* The term `text_find` means: open properties, activate search button. */
void TEXT_OT_start_find(wmOperatorType *ot);
void TEXT_OT_to_3d_object(wmOperatorType *ot);
@@ -178,7 +178,7 @@ void TEXT_OT_autocomplete(wmOperatorType *ot);
/* `space_text.cc` */
extern "C" const char *text_context_dir[]; /* doc access */
extern "C" const char *text_context_dir[]; /* Doc access. */
namespace blender::ed::text {
struct SpaceText_Runtime {

View File

@@ -327,7 +327,7 @@ void text_update_line_edited(TextLine *line)
return;
}
/* we just free format here, and let it rebuild during draw */
/* We just free format here, and let it rebuild during draw. */
MEM_SAFE_FREE(line->format);
}
@@ -354,7 +354,7 @@ static wmOperatorStatus text_new_exec(bContext *C, wmOperator * /*op*/)
text = BKE_text_add(bmain, DATA_("Text"));
/* hook into UI */
/* Hook into UI. */
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
if (prop) {
@@ -378,7 +378,7 @@ static wmOperatorStatus text_new_exec(bContext *C, wmOperator * /*op*/)
void TEXT_OT_new(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "New Text";
ot->idname = "TEXT_OT_new";
ot->description = "Create a new text data-block";
@@ -387,7 +387,7 @@ void TEXT_OT_new(wmOperatorType *ot)
ot->exec = text_new_exec;
ot->poll = text_new_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
}
@@ -433,7 +433,7 @@ static wmOperatorStatus text_open_exec(bContext *C, wmOperator *op)
text_open_init(C, op);
}
/* hook into UI */
/* Hook into UI. */
PropertyPointerRNA *pprop = static_cast<PropertyPointerRNA *>(op->customdata);
if (pprop->prop) {
PointerRNA idptr = RNA_id_pointer_create(&text->id);
@@ -475,7 +475,7 @@ static wmOperatorStatus text_open_invoke(bContext *C, wmOperator *op, const wmEv
void TEXT_OT_open(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Open Text";
ot->idname = "TEXT_OT_open";
ot->description = "Open a new text data-block";
@@ -486,10 +486,10 @@ void TEXT_OT_open(wmOperatorType *ot)
ot->cancel = text_open_cancel;
ot->poll = text_new_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
/* properties */
/* Properties. */
WM_operator_properties_filesel(ot,
FILE_TYPE_FOLDER | FILE_TYPE_TEXT | FILE_TYPE_PYSCRIPT,
FILE_SPECIAL,
@@ -513,12 +513,12 @@ static wmOperatorStatus text_reload_exec(bContext *C, wmOperator *op)
Text *text = CTX_data_edit_text(C);
ARegion *region = CTX_wm_region(C);
/* store view & cursor state */
/* Store view & cursor state. */
const int orig_top = st->top;
const int orig_curl = BLI_findindex(&text->lines, text->curl);
const int orig_curc = text->curc;
/* Don't make this part of 'poll', since 'Alt-R' will type 'R',
/* Don't make this part of `poll`, since `Alt-R` will type `R`,
* if poll checks for the filename. */
if (text->filepath == nullptr) {
BKE_report(op->reports, RPT_ERROR, "This text has not been saved");
@@ -543,10 +543,10 @@ static wmOperatorStatus text_reload_exec(bContext *C, wmOperator *op)
text->flags &= ~TXT_ISDIRTY;
/* return to scroll position */
/* Return to scroll position. */
st->top = orig_top;
space_text_screen_clamp(st, region);
/* return cursor */
/* Return cursor. */
txt_move_to(text, orig_curl, orig_curc, false);
return OPERATOR_FINISHED;
@@ -565,7 +565,7 @@ static wmOperatorStatus text_reload_invoke(bContext *C, wmOperator *op, const wm
void TEXT_OT_reload(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Reload";
ot->idname = "TEXT_OT_reload";
ot->description = "Reload active text data-block from its file";
@@ -584,7 +584,7 @@ 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... */
/* It should be possible to unlink texts if they're lib-linked in. */
return CTX_data_edit_text(C) != nullptr;
}
@@ -594,7 +594,7 @@ static wmOperatorStatus text_unlink_exec(bContext *C, wmOperator * /*op*/)
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
/* make the previous text active, if its not there make the next text active */
/* Make the previous text active, if its not there make the next text active. */
if (st) {
if (text->id.prev) {
st->text = static_cast<Text *>(text->id.prev);
@@ -627,7 +627,7 @@ static wmOperatorStatus text_unlink_invoke(bContext *C, wmOperator *op, const wm
void TEXT_OT_unlink(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Unlink";
ot->idname = "TEXT_OT_unlink";
ot->description = "Unlink active text data-block";
@@ -637,7 +637,7 @@ void TEXT_OT_unlink(wmOperatorType *ot)
ot->invoke = text_unlink_invoke;
ot->poll = text_unlink_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
}
@@ -663,7 +663,7 @@ static wmOperatorStatus text_make_internal_exec(bContext *C, wmOperator * /*op*/
void TEXT_OT_make_internal(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Make Internal";
ot->idname = "TEXT_OT_make_internal";
ot->description = "Make active text file internal";
@@ -672,7 +672,7 @@ void TEXT_OT_make_internal(wmOperatorType *ot)
ot->exec = text_make_internal_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
}
@@ -768,7 +768,7 @@ static wmOperatorStatus text_save_invoke(bContext *C, wmOperator *op, const wmEv
void TEXT_OT_save(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Save";
ot->idname = "TEXT_OT_save";
ot->description = "Save active text data-block";
@@ -839,7 +839,7 @@ static wmOperatorStatus text_save_as_invoke(bContext *C, wmOperator *op, const w
void TEXT_OT_save_as(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Save As";
ot->idname = "TEXT_OT_save_as";
ot->description = "Save active text file with options";
@@ -849,7 +849,7 @@ void TEXT_OT_save_as(wmOperatorType *ot)
ot->invoke = text_save_as_invoke;
ot->poll = text_edit_poll;
/* properties */
/* Properties. */
WM_operator_properties_filesel(ot,
FILE_TYPE_FOLDER | FILE_TYPE_TEXT | FILE_TYPE_PYSCRIPT,
FILE_SPECIAL,
@@ -871,22 +871,22 @@ static wmOperatorStatus text_run_script(bContext *C, ReportList *reports)
Text *text = CTX_data_edit_text(C);
const bool is_live = (reports == nullptr);
/* only for comparison */
/* Only for comparison. */
void *curl_prev = text->curl;
int curc_prev = text->curc;
int selc_prev = text->selc;
if (BPY_run_text(C, text, reports, !is_live)) {
if (is_live) {
/* for nice live updates */
/* For nice live updates. */
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, nullptr);
}
return OPERATOR_FINISHED;
}
/* Don't report error messages while live editing */
/* Don't report error messages while live editing. */
if (!is_live) {
/* text may have freed itself */
/* Text may have freed itself. */
if (CTX_data_edit_text(C) == text) {
if (text->curl != curl_prev || curc_prev != text->curc || selc_prev != text->selc) {
space_text_update_cursor_moved(C);
@@ -907,7 +907,7 @@ static wmOperatorStatus text_run_script(bContext *C, ReportList *reports)
static wmOperatorStatus text_run_script_exec(bContext *C, wmOperator *op)
{
#ifndef WITH_PYTHON
(void)C; /* unused */
UNUSED_VARS(C);
BKE_report(op->reports, RPT_ERROR, "Python disabled in this build");
@@ -919,7 +919,7 @@ static wmOperatorStatus text_run_script_exec(bContext *C, wmOperator *op)
void TEXT_OT_run_script(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Run Script";
ot->idname = "TEXT_OT_run_script";
ot->description = "Run active script";
@@ -928,7 +928,7 @@ void TEXT_OT_run_script(wmOperatorType *ot)
ot->poll = text_data_poll;
ot->exec = text_run_script_exec;
/* flags */
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -959,7 +959,7 @@ static wmOperatorStatus text_paste_exec(bContext *C, wmOperator *op)
ED_text_undo_push_init(C);
/* Convert clipboard content indentation to spaces if specified */
/* Convert clipboard content indentation to spaces if specified. */
if (text->flags & TXT_TABSTOSPACES) {
char *new_buf = buf_tabs_to_spaces(buf, TXT_TABSIZE, &buf_len);
MEM_freeN(buf);
@@ -974,7 +974,7 @@ static wmOperatorStatus text_paste_exec(bContext *C, wmOperator *op)
space_text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
/* Run the script while editing, evil but useful. */
if (st->live_edit) {
text_run_script(C, nullptr);
}
@@ -984,7 +984,7 @@ static wmOperatorStatus text_paste_exec(bContext *C, wmOperator *op)
void TEXT_OT_paste(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Paste";
ot->idname = "TEXT_OT_paste";
ot->description = "Paste text from clipboard";
@@ -993,10 +993,10 @@ void TEXT_OT_paste(wmOperatorType *ot)
ot->exec = text_paste_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
/* properties */
/* Properties. */
PropertyRNA *prop;
prop = RNA_def_boolean(ot->srna,
"selection",
@@ -1022,7 +1022,7 @@ static wmOperatorStatus text_duplicate_line_exec(bContext *C, wmOperator * /*op*
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
/* Run the script while editing, evil but useful. */
if (CTX_wm_space_text(C)->live_edit) {
text_run_script(C, nullptr);
}
@@ -1032,7 +1032,7 @@ static wmOperatorStatus text_duplicate_line_exec(bContext *C, wmOperator * /*op*
void TEXT_OT_duplicate_line(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Duplicate Line";
ot->idname = "TEXT_OT_duplicate_line";
ot->description = "Duplicate the current line";
@@ -1041,7 +1041,7 @@ void TEXT_OT_duplicate_line(wmOperatorType *ot)
ot->exec = text_duplicate_line_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
}
@@ -1078,7 +1078,7 @@ static wmOperatorStatus text_copy_exec(bContext *C, wmOperator * /*op*/)
void TEXT_OT_copy(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Copy";
ot->idname = "TEXT_OT_copy";
ot->description = "Copy selected text to clipboard";
@@ -1109,7 +1109,7 @@ static wmOperatorStatus text_cut_exec(bContext *C, wmOperator * /*op*/)
space_text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
/* Run the script while editing, evil but useful. */
if (st->live_edit) {
text_run_script(C, nullptr);
}
@@ -1119,7 +1119,7 @@ static wmOperatorStatus text_cut_exec(bContext *C, wmOperator * /*op*/)
void TEXT_OT_cut(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Cut";
ot->idname = "TEXT_OT_cut";
ot->description = "Cut selected text to clipboard";
@@ -1128,7 +1128,7 @@ void TEXT_OT_cut(wmOperatorType *ot)
ot->exec = text_cut_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
}
@@ -1156,7 +1156,7 @@ static wmOperatorStatus text_indent_or_autocomplete_exec(bContext *C, wmOperator
void TEXT_OT_indent_or_autocomplete(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Indent or Autocomplete";
ot->idname = "TEXT_OT_indent_or_autocomplete";
ot->description = "Indent selected text or autocomplete";
@@ -1165,7 +1165,7 @@ void TEXT_OT_indent_or_autocomplete(wmOperatorType *ot)
ot->exec = text_indent_or_autocomplete_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = 0;
}
@@ -1202,7 +1202,7 @@ static wmOperatorStatus text_indent_exec(bContext *C, wmOperator * /*op*/)
void TEXT_OT_indent(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Indent";
ot->idname = "TEXT_OT_indent";
ot->description = "Indent selected text";
@@ -1211,7 +1211,7 @@ void TEXT_OT_indent(wmOperatorType *ot)
ot->exec = text_indent_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
}
@@ -1243,7 +1243,7 @@ static wmOperatorStatus text_unindent_exec(bContext *C, wmOperator * /*op*/)
void TEXT_OT_unindent(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Unindent";
ot->idname = "TEXT_OT_unindent";
ot->description = "Unindent selected text";
@@ -1252,7 +1252,7 @@ void TEXT_OT_unindent(wmOperatorType *ot)
ot->exec = text_unindent_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
}
@@ -1300,7 +1300,7 @@ static wmOperatorStatus text_line_break_exec(bContext *C, wmOperator * /*op*/)
void TEXT_OT_line_break(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Line Break";
ot->idname = "TEXT_OT_line_break";
ot->description = "Insert line break at cursor position";
@@ -1309,7 +1309,7 @@ void TEXT_OT_line_break(wmOperatorType *ot)
ot->exec = text_line_break_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
}
@@ -1365,7 +1365,7 @@ void TEXT_OT_comment_toggle(wmOperatorType *ot)
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
/* Identifiers. */
ot->name = "Toggle Comments";
ot->idname = "TEXT_OT_comment_toggle";
@@ -1373,10 +1373,10 @@ void TEXT_OT_comment_toggle(wmOperatorType *ot)
ot->exec = text_comment_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
/* properties */
/* 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);
@@ -1412,8 +1412,8 @@ static wmOperatorStatus text_convert_whitespace_exec(bContext *C, wmOperator *op
text->sell->line, text->sell->len, text->selc, TXT_TABSIZE) :
-1;
/* first convert to all space, this make it a lot easier to convert to tabs
* because there is no mixtures of ' ' && '\t' */
/* First convert to all space, this make it a lot easier to convert to tabs
* because there is no mixtures of ` ` && `\t`. */
LISTBASE_FOREACH (TextLine *, tmp, &text->lines) {
char *new_line;
@@ -1447,20 +1447,20 @@ static wmOperatorStatus text_convert_whitespace_exec(bContext *C, wmOperator *op
BLI_assert(text_check_line);
for (a = 0; a < text_check_line_len;) {
/* A tab can only start at a position multiple of tab_len... */
/* A tab can only start at a position multiple of `tab_len`. */
if (!(a % tab_len) && (text_check_line[a] == ' ')) {
/* a + 0 we already know to be ' ' char... */
/* A + 0 we already know to be ` ` character. */
for (j = 1;
(j < tab_len) && (a + j < text_check_line_len) && (text_check_line[a + j] == ' ');
j++)
{
/* pass */
/* Pass. */
}
if (j == tab_len) {
/* We found a set of spaces that can be replaced by a tab... */
if ((tmp_line_cur == tmp_line) && a != 0) {
/* Copy all 'valid' string already 'parsed'... */
/* Copy all *valid* string already *parsed*. */
memcpy(tmp_line_cur, text_check_line, a);
tmp_line_cur += a;
}
@@ -1531,7 +1531,7 @@ static wmOperatorStatus text_convert_whitespace_exec(bContext *C, wmOperator *op
void TEXT_OT_convert_whitespace(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Convert Whitespace";
ot->idname = "TEXT_OT_convert_whitespace";
ot->description = "Convert whitespaces by type";
@@ -1540,10 +1540,10 @@ void TEXT_OT_convert_whitespace(wmOperatorType *ot)
ot->exec = text_convert_whitespace_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
/* properties */
/* Properties. */
RNA_def_enum(ot->srna,
"type",
whitespace_type_items,
@@ -1574,7 +1574,7 @@ static wmOperatorStatus text_select_all_exec(bContext *C, wmOperator * /*op*/)
void TEXT_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Select All";
ot->idname = "TEXT_OT_select_all";
ot->description = "Select all text";
@@ -1606,7 +1606,7 @@ static wmOperatorStatus text_select_line_exec(bContext *C, wmOperator * /*op*/)
void TEXT_OT_select_line(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Select Line";
ot->idname = "TEXT_OT_select_line";
ot->description = "Select text by line";
@@ -1639,7 +1639,7 @@ static wmOperatorStatus text_select_word_exec(bContext *C, wmOperator * /*op*/)
void TEXT_OT_select_word(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Select Word";
ot->idname = "TEXT_OT_select_word";
ot->description = "Select word under cursor";
@@ -1667,7 +1667,7 @@ static wmOperatorStatus move_lines_exec(bContext *C, wmOperator *op)
space_text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
/* Run the script while editing, evil but useful. */
if (CTX_wm_space_text(C)->live_edit) {
text_run_script(C, nullptr);
}
@@ -1683,7 +1683,7 @@ void TEXT_OT_move_lines(wmOperatorType *ot)
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
/* Identifiers. */
ot->name = "Move Lines";
ot->idname = "TEXT_OT_move_lines";
ot->description = "Move the currently selected line(s) up/down";
@@ -1692,10 +1692,10 @@ void TEXT_OT_move_lines(wmOperatorType *ot)
ot->exec = move_lines_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
/* properties */
/* Properties. */
RNA_def_enum(ot->srna, "direction", direction_items, 1, "Direction", "");
}
@@ -1739,9 +1739,9 @@ static int space_text_get_cursor_rel(
for (i = 0, j = 0; loop; j += BLI_str_utf8_size_safe(linein->line + j)) {
int chars;
const int columns = BLI_str_utf8_char_width_safe(linein->line + j); /* = 1 for tab */
const int columns = BLI_str_utf8_char_width_safe(linein->line + j); /* = 1 for tab. */
/* Mimic replacement of tabs */
/* Mimic replacement of tabs. */
ch = linein->line[j];
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
@@ -1753,8 +1753,8 @@ static int space_text_get_cursor_rel(
while (chars--) {
if (rell == 0 && i - start <= relc && i + columns - start > relc) {
/* current position could be wrapped to next line */
/* this should be checked when end of current line would be reached */
/* Current position could be wrapped to next line. */
/* This should be checked when end of current line would be reached. */
selc = j;
found = true;
}
@@ -1765,8 +1765,8 @@ static int space_text_get_cursor_rel(
end = std::min(end, i);
if (found) {
/* exact cursor position was found, check if it's */
/* still on needed line (hasn't been wrapped) */
/* Exact cursor position was found, check if it's
* still on needed line (hasn't been wrapped). */
if (selc > endj && !chop) {
selc = endj;
}
@@ -1832,7 +1832,7 @@ static int cursor_skip_find_line(const SpaceText *st,
*relc = space_text_get_char_pos(st, (*linep)->line, *charp) + offc;
*rell = lines;
/* handle current line */
/* Handle current line. */
if (lines > 0) {
visible_lines = space_text_get_visible_lines(st, region, (*linep)->line);
@@ -1876,11 +1876,11 @@ static int cursor_skip_find_line(const SpaceText *st,
}
}
/* skip lines and find destination line and offsets */
/* Skip lines and find destination line and offsets. */
while (*linep) {
visible_lines = space_text_get_visible_lines(st, region, (*linep)->line);
if (lines < 0) { /* moving top */
if (lines < 0) { /* Moving top. */
if (*rell + visible_lines >= 0) {
*rell += visible_lines;
break;
@@ -1894,7 +1894,7 @@ static int cursor_skip_find_line(const SpaceText *st,
*rell += visible_lines;
*linep = (*linep)->prev;
}
else { /* moving bottom */
else { /* Moving bottom. */
if (*rell - visible_lines < 0) {
break;
}
@@ -1943,9 +1943,9 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *region, const bool sel)
for (i = 0, j = 0; loop; j += BLI_str_utf8_size_safe((*linep)->line + j)) {
int chars;
const int columns = BLI_str_utf8_char_width_safe((*linep)->line + j); /* = 1 for tab */
const int columns = BLI_str_utf8_char_width_safe((*linep)->line + j); /* = 1 for tab. */
/* Mimic replacement of tabs */
/* Mimic replacement of tabs. */
ch = (*linep)->line[j];
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
@@ -2030,9 +2030,9 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *region, const bool sel)
for (i = 0, j = 0; loop; j += BLI_str_utf8_size_safe((*linep)->line + j)) {
int chars;
const int columns = BLI_str_utf8_char_width_safe((*linep)->line + j); /* = 1 for tab */
const int columns = BLI_str_utf8_char_width_safe((*linep)->line + j); /* = 1 for tab. */
/* Mimic replacement of tabs */
/* Mimic replacement of tabs. */
ch = (*linep)->line[j];
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
@@ -2189,7 +2189,7 @@ static void space_text_cursor_skip(
if (st && region && st->wordwrap) {
int rell, relc;
/* find line and offsets inside it needed to set cursor position */
/* Find line and offsets inside it needed to set cursor position. */
if (cursor_skip_find_line(st, region, lines, linep, charp, &rell, &relc)) {
*charp = space_text_get_cursor_rel(st, region, *linep, rell, relc);
}
@@ -2218,7 +2218,7 @@ static wmOperatorStatus text_move_cursor(bContext *C, int type, bool select)
Text *text = CTX_data_edit_text(C);
ARegion *region = CTX_wm_region(C);
/* ensure we have the right region, it's optional */
/* Ensure we have the right region, it's optional. */
if (region && region->regiontype != RGN_TYPE_WINDOW) {
region = nullptr;
}
@@ -2346,7 +2346,7 @@ static wmOperatorStatus text_move_exec(bContext *C, wmOperator *op)
void TEXT_OT_move(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Move Cursor";
ot->idname = "TEXT_OT_move";
ot->description = "Move cursor to position type";
@@ -2355,7 +2355,7 @@ void TEXT_OT_move(wmOperatorType *ot)
ot->exec = text_move_exec;
ot->poll = text_edit_poll;
/* properties */
/* Properties. */
RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to");
}
@@ -2374,7 +2374,7 @@ static wmOperatorStatus text_move_select_exec(bContext *C, wmOperator *op)
void TEXT_OT_move_select(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Move Select";
ot->idname = "TEXT_OT_move_select";
ot->description = "Move the cursor while selecting";
@@ -2383,7 +2383,7 @@ void TEXT_OT_move_select(wmOperatorType *ot)
ot->exec = text_move_select_exec;
ot->poll = text_space_edit_poll;
/* properties */
/* Properties. */
RNA_def_enum(ot->srna,
"type",
move_type_items,
@@ -2429,7 +2429,7 @@ static wmOperatorStatus text_jump_invoke(bContext *C, wmOperator *op, const wmEv
void TEXT_OT_jump(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Jump";
ot->idname = "TEXT_OT_jump";
ot->description = "Jump cursor to line";
@@ -2439,7 +2439,7 @@ void TEXT_OT_jump(wmOperatorType *ot)
ot->exec = text_jump_exec;
ot->poll = text_edit_poll;
/* properties */
/* Properties. */
ot->prop = RNA_def_int(
ot->srna, "line", 1, 1, INT_MAX, "Line", "Line number to jump to", 1, 10000);
RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_TEXT);
@@ -2467,8 +2467,8 @@ static wmOperatorStatus text_delete_exec(bContext *C, wmOperator *op)
space_text_drawcache_tag_update(st, true);
/* behavior could be changed here,
* but for now just don't jump words when we have a selection */
/* Behavior could be changed here,
* but for now just don't jump words when we have a selection. */
if (txt_has_sel(text)) {
if (type == DEL_PREV_WORD) {
type = DEL_PREV_CHAR;
@@ -2541,7 +2541,7 @@ static wmOperatorStatus text_delete_exec(bContext *C, wmOperator *op)
space_text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
/* Run the script while editing, evil but useful. */
if (st->live_edit) {
text_run_script(C, nullptr);
}
@@ -2551,7 +2551,7 @@ static wmOperatorStatus text_delete_exec(bContext *C, wmOperator *op)
void TEXT_OT_delete(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Delete";
ot->idname = "TEXT_OT_delete";
ot->description = "Delete text by cursor position";
@@ -2560,10 +2560,10 @@ void TEXT_OT_delete(wmOperatorType *ot)
ot->exec = text_delete_exec;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
/* properties */
/* Properties. */
PropertyRNA *prop;
prop = RNA_def_enum(ot->srna,
"type",
@@ -2593,7 +2593,7 @@ static wmOperatorStatus text_toggle_overwrite_exec(bContext *C, wmOperator * /*o
void TEXT_OT_overwrite_toggle(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Toggle Overwrite";
ot->idname = "TEXT_OT_overwrite_toggle";
ot->description = "Toggle overwrite while typing";
@@ -2624,7 +2624,7 @@ static void space_text_screen_clamp(SpaceText *st, const ARegion *region)
}
}
/* Moves the view vertically by the specified number of lines */
/* Moves the view vertically by the specified number of lines. */
static void space_text_screen_skip(SpaceText *st, ARegion *region, int lines)
{
st->top += lines;
@@ -2673,7 +2673,7 @@ static void text_scroll_state_init(TextScroll *tsc, SpaceText *st, ARegion *regi
static bool text_scroll_poll(bContext *C)
{
/* it should be possible to still scroll linked texts to read them,
/* 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) != nullptr;
}
@@ -2704,7 +2704,7 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
space_text_update_character_width(st);
/* compute mouse move distance */
/* Compute mouse move distance. */
if (tsc->is_first) {
copy_v2_v2_int(tsc->mval_prev, mval);
tsc->is_first = false;
@@ -2714,8 +2714,8 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
sub_v2_v2v2_int(tsc->mval_delta, mval, tsc->mval_prev);
}
/* accumulate scroll, in float values for events that give less than one
* line offset but taken together should still scroll */
/* Accumulate scroll, in float values for events that give less than one
* line offset but taken together should still scroll. */
if (!tsc->is_scrollbar) {
tsc->ofs_delta_px[0] -= tsc->mval_delta[0];
tsc->ofs_delta_px[1] += tsc->mval_delta[1];
@@ -2770,7 +2770,7 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
/* Apply to the screen. */
if (scroll_ofs_new[0] != st->left || scroll_ofs_new[1] != st->top ||
/* Horizontal sub-pixel offset currently isn't used. */
/* scroll_ofs_px_new[0] != st->scroll_ofs_px[0] || */
/* `scroll_ofs_px_new[0] != st->scroll_ofs_px[0] ||`. */
scroll_ofs_px_new[1] != st->runtime->scroll_ofs_px[1])
{
@@ -2869,7 +2869,7 @@ static wmOperatorStatus text_scroll_invoke(bContext *C, wmOperator *op, const wm
space_text_update_character_width(st);
copy_v2_v2_int(tsc->mval_prev, event->xy);
/* Sensitivity of scroll set to 4pix per line/char */
/* Sensitivity of scroll set to 4pix per line/char. */
tsc->mval_delta[0] = (event->xy[0] - event->prev_xy[0]) * st->runtime->cwidth_px / 4;
tsc->mval_delta[1] = (event->xy[1] - event->prev_xy[1]) * st->runtime->lheight_px / 4;
tsc->is_first = false;
@@ -2886,10 +2886,10 @@ static wmOperatorStatus text_scroll_invoke(bContext *C, wmOperator *op, const wm
void TEXT_OT_scroll(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Scroll";
/* don't really see the difference between this and
* scroll_bar. Both do basically the same thing (aside from key-maps). */
/* Don't really see the difference between this and scroll_bar.
* Both do basically the same thing (aside from key-maps). */
ot->idname = "TEXT_OT_scroll";
/* API callbacks. */
@@ -2899,10 +2899,10 @@ void TEXT_OT_scroll(wmOperatorType *ot)
ot->cancel = text_scroll_cancel;
ot->poll = text_scroll_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_XY | OPTYPE_INTERNAL;
/* properties */
/* Properties. */
PropertyRNA *prop;
prop = RNA_def_int(
ot->srna, "lines", 1, INT_MIN, INT_MAX, "Lines", "Number of lines to scroll", -100, 100);
@@ -2917,7 +2917,7 @@ void TEXT_OT_scroll(wmOperatorType *ot)
static bool text_region_scroll_poll(bContext *C)
{
/* same as text_region_edit_poll except it works on libdata too */
/* Same as text_region_edit_poll except it works on libdata too. */
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
ARegion *region = CTX_wm_region(C);
@@ -2945,14 +2945,14 @@ static wmOperatorStatus text_scroll_bar_invoke(bContext *C, wmOperator *op, cons
return text_scroll_exec(C, op);
}
/* verify we are in the right zone */
/* Verify we are in the right zone. */
if (mval[0] > st->runtime->scroll_region_handle.xmin &&
mval[0] < st->runtime->scroll_region_handle.xmax)
{
if (mval[1] >= st->runtime->scroll_region_handle.ymin &&
mval[1] <= st->runtime->scroll_region_handle.ymax)
{
/* mouse inside scroll handle */
/* Mouse inside scroll handle. */
zone = SCROLLHANDLE_BAR;
}
else if (mval[1] > TXT_SCROLL_SPACE && mval[1] < region->winy - TXT_SCROLL_SPACE) {
@@ -2966,7 +2966,7 @@ static wmOperatorStatus text_scroll_bar_invoke(bContext *C, wmOperator *op, cons
}
if (zone == SCROLLHANDLE_INVALID_OUTSIDE) {
/* we are outside slider - nothing to do */
/* We are outside slider - nothing to do. */
return OPERATOR_PASS_THROUGH;
}
@@ -2979,7 +2979,7 @@ static wmOperatorStatus text_scroll_bar_invoke(bContext *C, wmOperator *op, cons
text_scroll_state_init(tsc, st, region);
/* jump scroll, works in v2d but needs to be added here too :S */
/* Jump scroll, works in `v2d` but needs to be added here too unfortunately. */
if (event->type == MIDDLEMOUSE) {
tsc->mval_prev[0] = region->winrct.xmin + BLI_rcti_cent_x(&st->runtime->scroll_region_handle);
tsc->mval_prev[1] = region->winrct.ymin + BLI_rcti_cent_y(&st->runtime->scroll_region_handle);
@@ -2996,10 +2996,10 @@ static wmOperatorStatus text_scroll_bar_invoke(bContext *C, wmOperator *op, cons
void TEXT_OT_scroll_bar(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Scrollbar";
/* don't really see the difference between this and
* scroll. Both do basically the same thing (aside from key-maps). */
/* Don't really see the difference between this and scroll.
* Both do basically the same thing (aside from key-maps). */
ot->idname = "TEXT_OT_scroll_bar";
/* API callbacks. */
@@ -3008,10 +3008,10 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot)
ot->cancel = text_scroll_cancel;
ot->poll = text_region_scroll_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
/* properties */
/* Properties. */
PropertyRNA *prop;
prop = RNA_def_int(
ot->srna, "lines", 1, INT_MIN, INT_MAX, "Lines", "Number of lines to scroll", -100, 100);
@@ -3027,7 +3027,7 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot)
struct SetSelection {
int selc, sell;
short mval_prev[2];
wmTimer *timer; /* needed for scrolling when mouse at region bounds */
wmTimer *timer; /* Needed for scrolling when mouse at region bounds. */
};
static int flatten_width(SpaceText *st, const char *str)
@@ -3076,7 +3076,7 @@ static TextLine *space_text_get_line_pos_wrapped(const SpaceText *st,
lines = space_text_get_visible_lines(st, region, linep->line);
if (i + lines > *y) {
/* We found the line matching given vertical 'coordinate',
/* We found the line matching given vertical *coordinate*,
* now set y relative to this line's start. */
*y -= i;
break;
@@ -3089,26 +3089,26 @@ static void space_text_cursor_set_to_pos_wrapped(
const SpaceText *st, const ARegion *region, int x, int y, const bool sel)
{
Text *text = st->text;
int max = space_text_wrap_width(st, region); /* column */
int charp = -1; /* mem */
bool found = false; /* flags */
int max = space_text_wrap_width(st, region); /* Column. */
int charp = -1; /* Mem. */
bool found = false; /* Flags. */
/* Point to line matching given y position, if any. */
TextLine *linep = space_text_get_line_pos_wrapped(st, region, &y);
if (linep) {
int i = 0, start = 0, end = max; /* column */
int j, curs = 0, endj = 0; /* mem */
bool chop = true; /* flags */
int i = 0, start = 0, end = max; /* Column. */
int j, curs = 0, endj = 0; /* Mem. */
bool chop = true; /* Flags. */
char ch;
for (j = 0; !found && ((ch = linep->line[j]) != '\0');
j += BLI_str_utf8_size_safe(linep->line + j))
{
int chars;
const int columns = BLI_str_utf8_char_width_safe(linep->line + j); /* = 1 for tab */
const int columns = BLI_str_utf8_char_width_safe(linep->line + j); /* = 1 for tab. */
/* Mimic replacement of tabs */
/* Mimic replacement of tabs. */
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
ch = ' ';
@@ -3118,20 +3118,20 @@ static void space_text_cursor_set_to_pos_wrapped(
}
while (chars--) {
/* Gone too far, go back to last wrap point */
/* Gone too far, go back to last wrap point. */
if (y < 0) {
charp = endj;
y = 0;
found = true;
break;
/* Exactly at the cursor */
/* Exactly at the cursor. */
}
if (y == 0 && i - start <= x && i + columns - start > x) {
/* current position could be wrapped to next line */
/* this should be checked when end of current line would be reached */
/* Current position could be wrapped to next line. */
/* This should be checked when end of current line would be reached. */
charp = curs = j;
found = true;
/* Prepare curs for next wrap */
/* Prepare curs for next wrap. */
}
else if (i - end <= x && i + columns - end > x) {
curs = j;
@@ -3140,8 +3140,8 @@ static void space_text_cursor_set_to_pos_wrapped(
end = std::min(end, i);
if (found) {
/* exact cursor position was found, check if it's still on needed line
* (hasn't been wrapped) */
/* Exact cursor position was found, check if it's still on needed line
* (hasn't been wrapped). */
if (charp > endj && !chop && ch != '\0') {
charp = endj;
}
@@ -3186,7 +3186,7 @@ static void space_text_cursor_set_to_pos_wrapped(
BLI_assert(y == 0);
if (!found) {
/* On correct line but didn't meet cursor, must be at end */
/* On correct line but didn't meet cursor, must be at end. */
charp = linep->len;
}
}
@@ -3194,7 +3194,7 @@ static void space_text_cursor_set_to_pos_wrapped(
linep = static_cast<TextLine *>(st->text->lines.first);
charp = 0;
}
else { /* Beyond end of text */
else { /* Beyond end of text. */
linep = static_cast<TextLine *>(st->text->lines.last);
charp = linep->len;
}
@@ -3397,7 +3397,7 @@ static void text_selection_set_cancel(bContext *C, wmOperator *op)
void TEXT_OT_selection_set(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Set Selection";
ot->idname = "TEXT_OT_selection_set";
ot->description = "Set text selection";
@@ -3446,7 +3446,7 @@ static wmOperatorStatus text_cursor_set_invoke(bContext *C, wmOperator *op, cons
void TEXT_OT_cursor_set(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Set Cursor";
ot->idname = "TEXT_OT_cursor_set";
ot->description = "Set cursor position";
@@ -3456,7 +3456,7 @@ void TEXT_OT_cursor_set(wmOperatorType *ot)
ot->exec = text_cursor_set_exec;
ot->poll = text_region_edit_poll;
/* properties */
/* Properties. */
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
}
@@ -3516,7 +3516,7 @@ static wmOperatorStatus text_line_number_invoke(bContext *C,
void TEXT_OT_line_number(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Line Number";
ot->idname = "TEXT_OT_line_number";
ot->description = "The current line number";
@@ -3690,7 +3690,7 @@ static wmOperatorStatus text_insert_invoke(bContext *C, wmOperator *op, const wm
}
}
/* run the script while editing, evil but useful */
/* Run the script while editing, evil but useful. */
if (ret == OPERATOR_FINISHED && st->live_edit) {
text_run_script(C, nullptr);
}
@@ -3702,7 +3702,7 @@ void TEXT_OT_insert(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
/* Identifiers. */
ot->name = "Insert";
ot->idname = "TEXT_OT_insert";
ot->description = "Insert text at cursor position";
@@ -3712,10 +3712,10 @@ void TEXT_OT_insert(wmOperatorType *ot)
ot->invoke = text_insert_invoke;
ot->poll = text_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
/* properties */
/* Properties. */
prop = RNA_def_string(
ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -3727,7 +3727,7 @@ void TEXT_OT_insert(wmOperatorType *ot)
/** \name Find Operator
* \{ */
/* mode */
/* Mode. */
enum {
TEXT_FIND = 0,
TEXT_REPLACE = 1,
@@ -3751,7 +3751,7 @@ static wmOperatorStatus text_find_and_replace(bContext *C, wmOperator *op, short
flags &= ~ST_FIND_WRAP;
}
/* Replace current */
/* Replace current. */
if (mode != TEXT_FIND && txt_has_sel(text)) {
tmp = txt_sel_to_buf(text, nullptr);
@@ -3779,7 +3779,7 @@ static wmOperatorStatus text_find_and_replace(bContext *C, wmOperator *op, short
tmp = nullptr;
}
/* Find next */
/* Find next. */
if (txt_find_string(text, st->findstr, flags & ST_FIND_WRAP, flags & ST_MATCH_CASE)) {
space_text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
@@ -3811,7 +3811,7 @@ static wmOperatorStatus text_find_exec(bContext *C, wmOperator *op)
void TEXT_OT_find(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Find Next";
ot->idname = "TEXT_OT_find";
ot->description = "Find specified text";
@@ -3861,7 +3861,7 @@ static wmOperatorStatus text_replace_all(bContext *C)
space_text_drawcache_tag_update(st, true);
}
else {
/* Restore position */
/* Restore position. */
txt_move_to(text, orig_curl, orig_curc, has_sel);
return OPERATOR_CANCELLED;
}
@@ -3880,7 +3880,7 @@ static wmOperatorStatus text_replace_exec(bContext *C, wmOperator *op)
void TEXT_OT_replace(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Replace";
ot->idname = "TEXT_OT_replace";
ot->description = "Replace text with the specified text";
@@ -3889,10 +3889,10 @@ void TEXT_OT_replace(wmOperatorType *ot)
ot->exec = text_replace_exec;
ot->poll = text_space_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
/* properties */
/* 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);
@@ -3923,7 +3923,7 @@ static wmOperatorStatus text_find_set_selected_exec(bContext *C, wmOperator *op)
void TEXT_OT_find_set_selected(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Find & Set Selection";
ot->idname = "TEXT_OT_find_set_selected";
ot->description = "Find specified text and set as selected";
@@ -3954,7 +3954,7 @@ static wmOperatorStatus text_replace_set_selected_exec(bContext *C, wmOperator *
void TEXT_OT_replace_set_selected(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Replace & Set Selection";
ot->idname = "TEXT_OT_replace_set_selected";
ot->description = "Replace text with specified text and set as selected";
@@ -3963,7 +3963,7 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot)
ot->exec = text_replace_set_selected_exec;
ot->poll = text_space_edit_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_UNDO;
}
@@ -4043,8 +4043,8 @@ static bool text_jump_to_file_at_point_internal(bContext *C,
txt_move_to(text, line_index, column_index, false);
/* naughty!, find text area to set, not good behavior
* but since this is a developer tool lets allow it - campbell */
/* NOTE(@ideasman42): it's bad practice that this operator searches for the text area to set.
* not a good precedent, since this is a developer tool allow it. */
if (!ED_text_activate_in_screen(C, text)) {
BKE_reportf(reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2);
}
@@ -4104,7 +4104,7 @@ void TEXT_OT_jump_to_file_at_point(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
/* Identifiers. */
ot->name = "Jump to File at Point";
ot->idname = "TEXT_OT_jump_to_file_at_point";
ot->description = "Jump to a file for the text editor";
@@ -4112,7 +4112,7 @@ void TEXT_OT_jump_to_file_at_point(wmOperatorType *ot)
/* API callbacks. */
ot->exec = text_jump_to_file_at_point_exec;
/* flags */
/* Flags. */
ot->flag = 0;
prop = RNA_def_string(ot->srna, "filepath", nullptr, FILE_MAX, "Filepath", "");
@@ -4223,7 +4223,7 @@ static wmOperatorStatus text_resolve_conflict_invoke(bContext *C,
void TEXT_OT_resolve_conflict(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Resolve Conflict";
ot->idname = "TEXT_OT_resolve_conflict";
ot->description = "When external text is out of sync, resolve the conflict";
@@ -4233,7 +4233,7 @@ void TEXT_OT_resolve_conflict(wmOperatorType *ot)
ot->invoke = text_resolve_conflict_invoke;
ot->poll = text_resolve_conflict_poll;
/* properties */
/* Properties. */
RNA_def_enum(ot->srna,
"resolution",
resolution_items,
@@ -4260,7 +4260,7 @@ static wmOperatorStatus text_to_3d_object_exec(bContext *C, wmOperator *op)
void TEXT_OT_to_3d_object(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "To 3D Object";
ot->idname = "TEXT_OT_to_3d_object";
ot->description = "Create 3D text object from active text data-block";
@@ -4269,10 +4269,10 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot)
ot->exec = text_to_3d_object_exec;
ot->poll = text_data_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
/* Properties. */
RNA_def_boolean(
ot->srna, "split_lines", false, "Split Lines", "Create one object per line in the text");
}
@@ -4302,7 +4302,7 @@ static bool text_update_shader_poll(bContext *C)
return true;
}
/* recursively check for script nodes in groups using this text and update */
/** Recursively check for script nodes in groups using this text and update. */
static bool text_update_shader_text_recursive(RenderEngine *engine,
RenderEngineType *type,
bNodeTree *ntree,
@@ -4337,7 +4337,7 @@ static wmOperatorStatus text_update_shader_exec(bContext *C, wmOperator *op)
Text *text = CTX_data_edit_text(C);
bool found = false;
/* setup render engine */
/* Setup render engine. */
RenderEngine *engine = RE_engine_create(type);
engine->reports = op->reports;
@@ -4354,7 +4354,7 @@ static wmOperatorStatus text_update_shader_exec(bContext *C, wmOperator *op)
FOREACH_NODETREE_END;
}
/* Update all cameras using text datablock. */
/* Update all cameras using text data-block. */
if (type->update_custom_camera != nullptr) {
LISTBASE_FOREACH (Camera *, cam, &bmain->cameras) {
if (cam->custom_shader == text) {
@@ -4375,7 +4375,7 @@ static wmOperatorStatus text_update_shader_exec(bContext *C, wmOperator *op)
void TEXT_OT_update_shader(wmOperatorType *ot)
{
/* identifiers */
/* Identifiers. */
ot->name = "Shader Update";
ot->description =
"Update users of this shader, such as custom cameras and script nodes, with its new sockets "
@@ -4386,7 +4386,7 @@ void TEXT_OT_update_shader(wmOperatorType *ot)
ot->exec = text_update_shader_exec;
ot->poll = text_update_shader_poll;
/* flags */
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}