Minor tidying and commenting
This commit is contained in:
@@ -101,7 +101,7 @@ void convert_tabs (struct SpaceText *st, int tab);
|
|||||||
void txt_copy_clipboard (struct Text *text);
|
void txt_copy_clipboard (struct Text *text);
|
||||||
void txt_paste_clipboard (struct Text *text);
|
void txt_paste_clipboard (struct Text *text);
|
||||||
|
|
||||||
void txt_add_marker (struct Text *text, struct TextLine *line, int start, int end, char clr[4], int group, int flags);
|
void txt_add_marker (struct Text *text, struct TextLine *line, int start, int end, char color[4], int group, int flags);
|
||||||
short txt_clear_marker_region (struct Text *text, struct TextLine *line, int start, int end, int group, int flags);
|
short txt_clear_marker_region (struct Text *text, struct TextLine *line, int start, int end, int group, int flags);
|
||||||
short txt_clear_markers (struct Text *text, int group, int flags);
|
short txt_clear_markers (struct Text *text, int group, int flags);
|
||||||
struct TextMarker *txt_find_marker (struct Text *text, struct TextLine *line, int curs, int group, int flags);
|
struct TextMarker *txt_find_marker (struct Text *text, struct TextLine *line, int curs, int group, int flags);
|
||||||
|
|||||||
@@ -2682,14 +2682,14 @@ int setcurr_tab (Text *text)
|
|||||||
/*********************************/
|
/*********************************/
|
||||||
|
|
||||||
static int color_match(TextMarker *a, TextMarker *b) {
|
static int color_match(TextMarker *a, TextMarker *b) {
|
||||||
return (a->clr[0]==b->clr[0] &&
|
return (a->color[0]==b->color[0] &&
|
||||||
a->clr[1]==b->clr[1] &&
|
a->color[1]==b->color[1] &&
|
||||||
a->clr[2]==b->clr[2] &&
|
a->color[2]==b->color[2] &&
|
||||||
a->clr[3]==b->clr[3]);
|
a->color[3]==b->color[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Creates and adds a marker to the list maintaining sorted order */
|
/* Creates and adds a marker to the list maintaining sorted order */
|
||||||
void txt_add_marker(Text *text, TextLine *line, int start, int end, char clr[4], int group, int flags) {
|
void txt_add_marker(Text *text, TextLine *line, int start, int end, char color[4], int group, int flags) {
|
||||||
TextMarker *tmp, *marker;
|
TextMarker *tmp, *marker;
|
||||||
|
|
||||||
marker= MEM_mallocN(sizeof(TextMarker), "text_marker");
|
marker= MEM_mallocN(sizeof(TextMarker), "text_marker");
|
||||||
@@ -2700,10 +2700,10 @@ void txt_add_marker(Text *text, TextLine *line, int start, int end, char clr[4],
|
|||||||
marker->group= group;
|
marker->group= group;
|
||||||
marker->flags= flags;
|
marker->flags= flags;
|
||||||
|
|
||||||
marker->clr[0]= clr[0];
|
marker->color[0]= color[0];
|
||||||
marker->clr[1]= clr[1];
|
marker->color[1]= color[1];
|
||||||
marker->clr[2]= clr[2];
|
marker->color[2]= color[2];
|
||||||
marker->clr[3]= clr[3];
|
marker->color[3]= color[3];
|
||||||
|
|
||||||
for (tmp=text->markers.last; tmp; tmp=tmp->prev)
|
for (tmp=text->markers.last; tmp; tmp=tmp->prev)
|
||||||
if (tmp->lineno < marker->lineno || (tmp->lineno==marker->lineno && tmp->start < marker->start))
|
if (tmp->lineno < marker->lineno || (tmp->lineno==marker->lineno && tmp->start < marker->start))
|
||||||
|
|||||||
@@ -38,15 +38,17 @@ typedef struct TextLine {
|
|||||||
struct TextLine *next, *prev;
|
struct TextLine *next, *prev;
|
||||||
|
|
||||||
char *line;
|
char *line;
|
||||||
char *format;
|
char *format; /* may be NULL if syntax is off or not yet formatted */
|
||||||
int len, blen;
|
int len, blen; /* blen unused */
|
||||||
} TextLine;
|
} TextLine;
|
||||||
|
|
||||||
typedef struct TextMarker {
|
typedef struct TextMarker {
|
||||||
struct TextMarker *next, *prev;
|
struct TextMarker *next, *prev;
|
||||||
int lineno, start, end, pad1;
|
|
||||||
int group, flags;
|
int lineno, start, end, pad1; /* line number and start/end character indices */
|
||||||
char clr[4], pad[4];
|
|
||||||
|
int group, flags; /* see BKE_text.h for flag defines */
|
||||||
|
char color[4], pad[4]; /* draw color of the marker */
|
||||||
} TextMarker;
|
} TextMarker;
|
||||||
|
|
||||||
typedef struct Text {
|
typedef struct Text {
|
||||||
|
|||||||
@@ -688,7 +688,7 @@ static PyObject *Text_markSelection( BPy_Text * self, PyObject * args )
|
|||||||
{
|
{
|
||||||
int group = 0, flags = 0,r, g, b;
|
int group = 0, flags = 0,r, g, b;
|
||||||
Text *text;
|
Text *text;
|
||||||
char clr[4];
|
char color[4];
|
||||||
|
|
||||||
text = self->text;
|
text = self->text;
|
||||||
if (!text)
|
if (!text)
|
||||||
@@ -703,14 +703,14 @@ static PyObject *Text_markSelection( BPy_Text * self, PyObject * args )
|
|||||||
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
|
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
|
||||||
"Cannot mark multi-line selection.");
|
"Cannot mark multi-line selection.");
|
||||||
|
|
||||||
clr[0] = (char) (r&0xFF);
|
color[0] = (char) (r&0xFF);
|
||||||
clr[1] = (char) (g&0xFF);
|
color[1] = (char) (g&0xFF);
|
||||||
clr[2] = (char) (b&0xFF);
|
color[2] = (char) (b&0xFF);
|
||||||
clr[3] = 255;
|
color[3] = 255;
|
||||||
|
|
||||||
group &= 0xFFFF;
|
group &= 0xFFFF;
|
||||||
|
|
||||||
txt_add_marker(text, text->curl, text->curc, text->selc, clr, group, flags);
|
txt_add_marker(text, text->curl, text->curc, text->selc, color, group, flags);
|
||||||
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -809,7 +809,7 @@ static void draw_markers(SpaceText *st) {
|
|||||||
x2= get_char_pos(st, line->line, marker->end) - st->left + offc;
|
x2= get_char_pos(st, line->line, marker->end) - st->left + offc;
|
||||||
y2= cy + offl;
|
y2= cy + offl;
|
||||||
|
|
||||||
glColor3ub(marker->clr[0], marker->clr[1], marker->clr[2]);
|
glColor3ub(marker->color[0], marker->color[1], marker->color[2]);
|
||||||
x= st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
|
x= st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
|
||||||
y= curarea->winy-3;
|
y= curarea->winy-3;
|
||||||
|
|
||||||
@@ -1518,13 +1518,13 @@ void find_and_replace(SpaceText *st, short mode) {
|
|||||||
txt_insert_buf(text, g_replace_str);
|
txt_insert_buf(text, g_replace_str);
|
||||||
if (st->showsyntax) txt_format_line(st, text->curl, 1);
|
if (st->showsyntax) txt_format_line(st, text->curl, 1);
|
||||||
} else if (mode==2) {
|
} else if (mode==2) {
|
||||||
char clr[4];
|
char color[4];
|
||||||
BIF_GetThemeColor4ubv(TH_SHADE2, clr);
|
BIF_GetThemeColor4ubv(TH_SHADE2, color);
|
||||||
if (txt_find_marker(text, text->curl, text->selc, TMARK_GRP_FINDALL, 0)) {
|
if (txt_find_marker(text, text->curl, text->selc, TMARK_GRP_FINDALL, 0)) {
|
||||||
if (tmp) MEM_freeN(tmp), tmp=NULL;
|
if (tmp) MEM_freeN(tmp), tmp=NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
txt_add_marker(text, text->curl, text->curc, text->selc, clr, TMARK_GRP_FINDALL, TMARK_EDITALL);
|
txt_add_marker(text, text->curl, text->curc, text->selc, color, TMARK_GRP_FINDALL, TMARK_EDITALL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MEM_freeN(tmp);
|
MEM_freeN(tmp);
|
||||||
|
|||||||
Reference in New Issue
Block a user