Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Thompson <quornian@googlemail.com>2008-07-24 01:28:48 +0400
committerIan Thompson <quornian@googlemail.com>2008-07-24 01:28:48 +0400
commitd2013570a086d8af4545cf200a84cf74cb7be05f (patch)
tree9662548847dac09814cae057783aab91169ac07c /source/blender
parent3b70337f7f247f8f394992c57c835b65fee25c03 (diff)
Refactor: Renamed text tool methods (suggestions and docs) for clarity and consistency.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_suggestions.h33
-rw-r--r--source/blender/blenkernel/intern/suggestions.c65
-rw-r--r--source/blender/python/api2_2x/Text.c12
-rw-r--r--source/blender/src/drawtext.c88
-rw-r--r--source/blender/src/usiblender.c2
5 files changed, 100 insertions, 100 deletions
diff --git a/source/blender/blenkernel/BKE_suggestions.h b/source/blender/blenkernel/BKE_suggestions.h
index b150e279574..41a87aaa05e 100644
--- a/source/blender/blenkernel/BKE_suggestions.h
+++ b/source/blender/blenkernel/BKE_suggestions.h
@@ -62,26 +62,27 @@ typedef struct SuggList {
SuggItem *selected;
} SuggList;
-/* Free all suggestion related memory */
-void free_suggestions();
+/* Free all text tool memory */
+void free_texttools();
/* Used to identify which Text object the current tools should appear against */
-void suggest_set_active(Text *text);
-void suggest_clear_active();
-short suggest_is_active(Text *text);
+void texttool_text_set_active(Text *text);
+void texttool_text_clear();
+short texttool_text_is_active(Text *text);
-void suggest_add(const char *name, char type);
-void suggest_prefix(const char *prefix);
-void suggest_clear_list();
-SuggItem *suggest_first();
-SuggItem *suggest_last();
+/* Suggestions */
+void texttool_suggest_add(const char *name, char type);
+void texttool_suggest_prefix(const char *prefix);
+void texttool_suggest_clear();
+SuggItem *texttool_suggest_first();
+SuggItem *texttool_suggest_last();
+void texttool_suggest_select(SuggItem *sel);
+SuggItem *texttool_suggest_selected();
-void suggest_set_selected(SuggItem *sel);
-SuggItem *suggest_get_selected();
-
-void suggest_documentation(const char *docs);
-char *suggest_get_docs();
-void suggest_clear_docs();
+/* Documentation */
+void texttool_docs_show(const char *docs);
+char *texttool_docs_get();
+void texttool_docs_clear();
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c
index 41265c35170..edccc0886f6 100644
--- a/source/blender/blenkernel/intern/suggestions.c
+++ b/source/blender/blenkernel/intern/suggestions.c
@@ -41,13 +41,12 @@
/* Static definitions */
/**********************/
+static Text *activeToolText = NULL;
static SuggList suggestions = {NULL, NULL, NULL, NULL, NULL};
-static Text *suggText = NULL;
-static SuggItem *lastInsert = NULL;
static char *documentation = NULL;
static int doc_lines = 0;
-static int suggest_cmp(const char *first, const char *second, int len) {
+static int txttl_cmp(const char *first, const char *second, int len) {
int cmp, i;
for (cmp=0, i=0; i<len; i++) {
if (cmp= toupper(first[i])-toupper(second[i])) {
@@ -57,7 +56,7 @@ static int suggest_cmp(const char *first, const char *second, int len) {
return cmp;
}
-static void sugg_free() {
+static void txttl_free_suggest() {
SuggItem *item, *prev;
for (item = suggestions.last; item; item=prev) {
prev = item->prev;
@@ -68,7 +67,7 @@ static void sugg_free() {
suggestions.selected = NULL;
}
-static void docs_free() {
+static void txttl_free_docs() {
if (documentation) {
MEM_freeN(documentation);
documentation = NULL;
@@ -79,31 +78,31 @@ static void docs_free() {
/* General tool functions */
/**************************/
-void free_suggestions() {
- sugg_free();
- docs_free();
+void free_texttools() {
+ txttl_free_suggest();
+ txttl_free_docs();
}
-void suggest_set_active(Text *text) {
- if (suggText == text) return;
- suggest_clear_active();
- suggText = text;
+void texttool_text_set_active(Text *text) {
+ if (activeToolText == text) return;
+ texttool_text_clear();
+ activeToolText = text;
}
-void suggest_clear_active() {
- free_suggestions();
- suggText = NULL;
+void texttool_text_clear() {
+ free_texttools();
+ activeToolText = NULL;
}
-short suggest_is_active(Text *text) {
- return suggText==text ? 1 : 0;
+short texttool_text_is_active(Text *text) {
+ return activeToolText==text ? 1 : 0;
}
/***************************/
/* Suggestion list methods */
/***************************/
-void suggest_add(const char *name, char type) {
+void texttool_suggest_add(const char *name, char type) {
SuggItem *newitem, *item;
int len, cmp;
@@ -126,7 +125,7 @@ void suggest_add(const char *name, char type) {
} else {
cmp = -1;
for (item=suggestions.last; item; item=item->prev) {
- cmp = suggest_cmp(name, item->name, len);
+ cmp = txttl_cmp(name, item->name, len);
/* Newitem comes after this item, insert here */
if (cmp >= 0) {
@@ -152,7 +151,7 @@ void suggest_add(const char *name, char type) {
suggestions.firstmatch = suggestions.lastmatch = suggestions.selected = NULL;
}
-void suggest_prefix(const char *prefix) {
+void texttool_suggest_prefix(const char *prefix) {
SuggItem *match, *first, *last;
int cmp, len = strlen(prefix);
@@ -165,7 +164,7 @@ void suggest_prefix(const char *prefix) {
first = last = NULL;
for (match=suggestions.first; match; match=match->next) {
- cmp = suggest_cmp(prefix, match->name, len);
+ cmp = txttl_cmp(prefix, match->name, len);
if (cmp==0) {
if (!first)
first = match;
@@ -188,31 +187,31 @@ void suggest_prefix(const char *prefix) {
}
}
-void suggest_clear_list() {
- sugg_free();
+void texttool_suggest_clear() {
+ txttl_free_suggest();
}
-SuggItem *suggest_first() {
+SuggItem *texttool_suggest_first() {
return suggestions.firstmatch;
}
-SuggItem *suggest_last() {
+SuggItem *texttool_suggest_last() {
return suggestions.lastmatch;
}
-SuggItem *suggest_get_selected() {
- return suggestions.selected;
+void texttool_suggest_select(SuggItem *sel) {
+ suggestions.selected = sel;
}
-void suggest_set_selected(SuggItem *sel) {
- suggestions.selected = sel;
+SuggItem *texttool_suggest_selected() {
+ return suggestions.selected;
}
/*************************/
/* Documentation methods */
/*************************/
-void suggest_documentation(const char *docs) {
+void texttool_docs_show(const char *docs) {
int len;
if (!docs) return;
@@ -236,10 +235,10 @@ void suggest_documentation(const char *docs) {
documentation[len] = '\0';
}
-char *suggest_get_docs() {
+char *texttool_docs_get() {
return documentation;
}
-void suggest_clear_docs() {
- docs_free();
+void texttool_docs_clear() {
+ txttl_free_docs();
}
diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c
index 170f808da0d..ae847d26f2d 100644
--- a/source/blender/python/api2_2x/Text.c
+++ b/source/blender/python/api2_2x/Text.c
@@ -598,8 +598,8 @@ static PyObject *Text_suggest( BPy_Text * self, PyObject * args )
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
"Active text area has no Text object");
- suggest_clear_list();
- suggest_set_active(st->text);
+ texttool_suggest_clear();
+ texttool_text_set_active(st->text);
list_len = PyList_Size(list);
for (i = 0; i < list_len; i++) {
@@ -625,11 +625,11 @@ static PyObject *Text_suggest( BPy_Text * self, PyObject * args )
return EXPP_ReturnPyObjError(PyExc_AttributeError,
"names must be non-empty and types in ['m', 'v', 'f', 'k', '?']" );
- suggest_add(name, type);
+ texttool_suggest_add(name, type);
}
if (!prefix)
prefix = "";
- suggest_prefix(prefix);
+ texttool_suggest_prefix(prefix);
scrarea_queue_redraw(curarea);
Py_RETURN_NONE;
@@ -657,8 +657,8 @@ static PyObject *Text_showDocs( BPy_Text * self, PyObject * args )
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
"Active text area has no Text object");
- suggest_set_active(st->text);
- suggest_documentation(docs);
+ texttool_text_set_active(st->text);
+ texttool_docs_show(docs);
scrarea_queue_redraw(curarea);
Py_RETURN_NONE;
diff --git a/source/blender/src/drawtext.c b/source/blender/src/drawtext.c
index 5dfadf5b7f7..c112bbe9350 100644
--- a/source/blender/src/drawtext.c
+++ b/source/blender/src/drawtext.c
@@ -1029,11 +1029,11 @@ static int do_suggest_select(SpaceText *st)
int seli, tgti;
if (!st || !st->text) return 0;
- if (!suggest_is_active(st->text)) return 0;
+ if (!texttool_text_is_active(st->text)) return 0;
- first = suggest_first();
- last = suggest_last();
- sel = suggest_get_selected();
+ first = texttool_suggest_first();
+ last = texttool_suggest_last();
+ sel = texttool_suggest_selected();
if (!last || !first)
return 0;
@@ -1068,11 +1068,11 @@ static int do_suggest_select(SpaceText *st)
if (seli<tgti) {
for (i=seli; i<tgti && sel && sel!=last; i++, sel=sel->next);
if (sel)
- suggest_set_selected(sel);
+ texttool_suggest_select(sel);
} else {
for (i=seli; i>tgti && sel && sel!=first; i--, sel=sel->prev);
if (sel)
- suggest_set_selected(sel);
+ texttool_suggest_select(sel);
}
return 1;
}
@@ -1085,9 +1085,9 @@ void draw_documentation(SpaceText *st)
int boxw=0, boxh, l, x, y;
if (!st || !st->text) return;
- if (!suggest_is_active(st->text)) return;
+ if (!texttool_text_is_active(st->text)) return;
- docs = suggest_get_docs();
+ docs = texttool_docs_get();
if (!docs) return;
@@ -1100,7 +1100,7 @@ void draw_documentation(SpaceText *st)
} else {
x = spacetext_get_fontwidth(st)*(st->text->curc-st->left) + TXT_OFFSET - 4;
}
- if (suggest_first()) {
+ if (texttool_suggest_first()) {
x += SUGG_LIST_WIDTH*spacetext_get_fontwidth(st) + 50;
}
y = curarea->winy - st->lheight*l - 2;
@@ -1155,14 +1155,14 @@ void draw_suggestion_list(SpaceText *st)
int w, boxw=0, boxh, i, l, x, y, b;
if (!st || !st->text) return;
- if (!suggest_is_active(st->text)) return;
+ if (!texttool_text_is_active(st->text)) return;
- first = suggest_first();
- last = suggest_last();
+ first = texttool_suggest_first();
+ last = texttool_suggest_last();
if (!first || !last) return;
- sel = suggest_get_selected();
+ sel = texttool_suggest_selected();
/* Count the visible lines to the cursor */
for (tmp=st->text->curl, l=-st->top; tmp; tmp=tmp->prev, l++);
@@ -1858,7 +1858,7 @@ static void get_suggest_prefix(Text *text) {
char *line, tmp[256];
if (!text) return;
- if (!suggest_is_active(text)) return;
+ if (!texttool_text_is_active(text)) return;
line= text->curl->line;
for (i=text->curc-1; i>=0; i--)
@@ -1872,7 +1872,7 @@ static void get_suggest_prefix(Text *text) {
}
strncpy(tmp, line+i, len);
tmp[len]= '\0';
- suggest_prefix(tmp);
+ texttool_suggest_prefix(tmp);
}
static void confirm_suggestion(Text *text, int skipleft) {
@@ -1881,9 +1881,9 @@ static void confirm_suggestion(Text *text, int skipleft) {
SuggItem *sel;
if (!text) return;
- if (!suggest_is_active(text)) return;
+ if (!texttool_text_is_active(text)) return;
- sel = suggest_get_selected();
+ sel = texttool_suggest_selected();
if (!sel) return;
line= text->curl->line;
@@ -1905,7 +1905,7 @@ static void confirm_suggestion(Text *text, int skipleft) {
for (i=0; i<skipleft; i++)
txt_move_right(text, 0);
- suggest_clear_active();
+ texttool_text_clear();
}
void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
@@ -1980,9 +1980,9 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
return;
}
- if (st->showsyntax && suggest_is_active(text)) {
- if (suggest_first()) tools |= TOOL_SUGG_LIST;
- if (suggest_get_docs()) tools |= TOOL_DOCUMENT;
+ if (st->showsyntax && texttool_text_is_active(text)) {
+ if (texttool_suggest_first()) tools |= TOOL_SUGG_LIST;
+ if (texttool_docs_get()) tools |= TOOL_DOCUMENT;
}
if (event==LEFTMOUSE) {
@@ -2454,11 +2454,11 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case DOWNARROWKEY:
if (tools & TOOL_SUGG_LIST) {
- SuggItem *sel = suggest_get_selected();
+ SuggItem *sel = texttool_suggest_selected();
if (!sel) {
- suggest_set_selected(suggest_first());
- } else if (sel!=suggest_last() && sel->next) {
- suggest_set_selected(sel->next);
+ texttool_suggest_select(texttool_suggest_first());
+ } else if (sel!=texttool_suggest_last() && sel->next) {
+ texttool_suggest_select(sel->next);
}
tools_cancel &= ~TOOL_SUGG_LIST;
break;
@@ -2492,9 +2492,9 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case UPARROWKEY:
if (tools & TOOL_SUGG_LIST) {
- SuggItem *sel = suggest_get_selected();
- if (sel && sel!=suggest_first() && sel->prev)
- suggest_set_selected(sel->prev);
+ SuggItem *sel = texttool_suggest_selected();
+ if (sel && sel!=texttool_suggest_first() && sel->prev)
+ texttool_suggest_select(sel->prev);
tools_cancel &= ~TOOL_SUGG_LIST;
break;
}
@@ -2506,11 +2506,11 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case PAGEDOWNKEY:
if (tools & TOOL_SUGG_LIST) {
int i;
- SuggItem *sel = suggest_get_selected();
+ SuggItem *sel = texttool_suggest_selected();
if (!sel)
- sel = suggest_first();
- for (i=0; i<SUGG_LIST_SIZE-1 && sel && sel!=suggest_last() && sel->next; i++, sel=sel->next)
- suggest_set_selected(sel->next);
+ sel = texttool_suggest_first();
+ for (i=0; i<SUGG_LIST_SIZE-1 && sel && sel!=texttool_suggest_last() && sel->next; i++, sel=sel->next)
+ texttool_suggest_select(sel->next);
tools_cancel &= ~TOOL_SUGG_LIST;
break;
} else {
@@ -2521,9 +2521,9 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case PAGEUPKEY:
if (tools & TOOL_SUGG_LIST) {
int i;
- SuggItem *sel = suggest_get_selected();
- for (i=0; i<SUGG_LIST_SIZE-1 && sel && sel!=suggest_first() && sel->prev; i++, sel=sel->prev)
- suggest_set_selected(sel->prev);
+ SuggItem *sel = texttool_suggest_selected();
+ for (i=0; i<SUGG_LIST_SIZE-1 && sel && sel!=texttool_suggest_first() && sel->prev; i++, sel=sel->prev)
+ texttool_suggest_select(sel->prev);
tools_cancel &= ~TOOL_SUGG_LIST;
break;
} else {
@@ -2543,9 +2543,9 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case WHEELUPMOUSE:
if (tools & TOOL_SUGG_LIST) {
- SuggItem *sel = suggest_get_selected();
- if (sel && sel!=suggest_first() && sel->prev)
- suggest_set_selected(sel->prev);
+ SuggItem *sel = texttool_suggest_selected();
+ if (sel && sel!=texttool_suggest_first() && sel->prev)
+ texttool_suggest_select(sel->prev);
tools_cancel &= ~TOOL_SUGG_LIST;
} else {
screen_skip(st, -U.wheellinescroll);
@@ -2555,11 +2555,11 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case WHEELDOWNMOUSE:
if (tools & TOOL_SUGG_LIST) {
- SuggItem *sel = suggest_get_selected();
+ SuggItem *sel = texttool_suggest_selected();
if (!sel) {
- suggest_set_selected(suggest_first());
- } else if (sel && sel!=suggest_last() && sel->next) {
- suggest_set_selected(sel->next);
+ texttool_suggest_select(texttool_suggest_first());
+ } else if (sel && sel!=texttool_suggest_last() && sel->next) {
+ texttool_suggest_select(sel->next);
}
tools_cancel &= ~TOOL_SUGG_LIST;
} else {
@@ -2637,13 +2637,13 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if (tools_update & TOOL_SUGG_LIST) {
get_suggest_prefix(text);
} else if (tools_cancel & TOOL_SUGG_LIST) {
- suggest_clear_active();
+ texttool_suggest_clear();
}
do_draw= 1;
}
if (tools & TOOL_DOCUMENT) {
if (tools_cancel & TOOL_DOCUMENT) {
- suggest_clear_docs();
+ texttool_docs_clear();
}
do_draw= 1;
}
diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c
index a45ddc73972..4e5a7dc92c7 100644
--- a/source/blender/src/usiblender.c
+++ b/source/blender/src/usiblender.c
@@ -1101,7 +1101,7 @@ void exit_usiblender(void)
free_actcopybuf();
free_vertexpaint();
free_imagepaint();
- free_suggestions();
+ free_texttools();
/* editnurb can remain to exist outside editmode */
freeNurblist(&editNurb);