mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Cleanup: use full sentences in text editor code-comments
Also minor improvements, clarifications.
This commit is contained in:
parent
6d899a6726
commit
a3bf386d43
14 changed files with 458 additions and 456 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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(®ion->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(®ion->runtime->handlers, keymap);
|
||||
keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, RGN_TYPE_WINDOW);
|
||||
WM_event_add_keymap_handler_v2d_mask(®ion->runtime->handlers, keymap);
|
||||
|
||||
/* add drop boxes */
|
||||
/* Add drop boxes. */
|
||||
lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
|
||||
|
||||
WM_event_add_dropbox_handler(®ion->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 = ®ion->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(®ion->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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue