1
1

Minor tidying and commenting

This commit is contained in:
2008-08-31 16:23:31 +00:00
parent 3bab89cc1c
commit 062bf735e7
5 changed files with 27 additions and 25 deletions

View File

@@ -101,7 +101,7 @@ void convert_tabs (struct SpaceText *st, int tab);
void txt_copy_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_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);

View File

@@ -2682,14 +2682,14 @@ int setcurr_tab (Text *text)
/*********************************/
static int color_match(TextMarker *a, TextMarker *b) {
return (a->clr[0]==b->clr[0] &&
a->clr[1]==b->clr[1] &&
a->clr[2]==b->clr[2] &&
a->clr[3]==b->clr[3]);
return (a->color[0]==b->color[0] &&
a->color[1]==b->color[1] &&
a->color[2]==b->color[2] &&
a->color[3]==b->color[3]);
}
/* 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;
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->flags= flags;
marker->clr[0]= clr[0];
marker->clr[1]= clr[1];
marker->clr[2]= clr[2];
marker->clr[3]= clr[3];
marker->color[0]= color[0];
marker->color[1]= color[1];
marker->color[2]= color[2];
marker->color[3]= color[3];
for (tmp=text->markers.last; tmp; tmp=tmp->prev)
if (tmp->lineno < marker->lineno || (tmp->lineno==marker->lineno && tmp->start < marker->start))

View File

@@ -38,15 +38,17 @@ typedef struct TextLine {
struct TextLine *next, *prev;
char *line;
char *format;
int len, blen;
char *format; /* may be NULL if syntax is off or not yet formatted */
int len, blen; /* blen unused */
} TextLine;
typedef struct TextMarker {
struct TextMarker *next, *prev;
int lineno, start, end, pad1;
int group, flags;
char clr[4], pad[4];
int lineno, start, end, pad1; /* line number and start/end character indices */
int group, flags; /* see BKE_text.h for flag defines */
char color[4], pad[4]; /* draw color of the marker */
} TextMarker;
typedef struct Text {

View File

@@ -688,7 +688,7 @@ static PyObject *Text_markSelection( BPy_Text * self, PyObject * args )
{
int group = 0, flags = 0,r, g, b;
Text *text;
char clr[4];
char color[4];
text = self->text;
if (!text)
@@ -703,14 +703,14 @@ static PyObject *Text_markSelection( BPy_Text * self, PyObject * args )
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
"Cannot mark multi-line selection.");
clr[0] = (char) (r&0xFF);
clr[1] = (char) (g&0xFF);
clr[2] = (char) (b&0xFF);
clr[3] = 255;
color[0] = (char) (r&0xFF);
color[1] = (char) (g&0xFF);
color[2] = (char) (b&0xFF);
color[3] = 255;
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;
}

View File

@@ -809,7 +809,7 @@ static void draw_markers(SpaceText *st) {
x2= get_char_pos(st, line->line, marker->end) - st->left + offc;
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;
y= curarea->winy-3;
@@ -1518,13 +1518,13 @@ void find_and_replace(SpaceText *st, short mode) {
txt_insert_buf(text, g_replace_str);
if (st->showsyntax) txt_format_line(st, text->curl, 1);
} else if (mode==2) {
char clr[4];
BIF_GetThemeColor4ubv(TH_SHADE2, clr);
char color[4];
BIF_GetThemeColor4ubv(TH_SHADE2, color);
if (txt_find_marker(text, text->curl, text->selc, TMARK_GRP_FINDALL, 0)) {
if (tmp) MEM_freeN(tmp), tmp=NULL;
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);