int EBuffer::GetHilitWord(int len, const char *str, ChColor& clr, int IgnCase) { char *p; if ((Mode == 0) || (Mode->fColorize == 0)) return 0; if (len >= CK_MAXLEN) return 0; { char s[CK_MAXLEN + 1]; s[CK_MAXLEN] = 0; memcpy(s, str, len); s[len] = 0; if (HilitFindWord(s)) { clr = COUNT_CLR + hcPlain_HilitWord; return 1; } } if (len < 1) return 0; p = Mode->fColorize->Keywords.key[len]; if (IgnCase) { while (p && *p) { if (strnicmp(p, str, len) == 0) { clr = COUNT_CLR + ((unsigned char *)p)[len]; return 1; } p += len + 1; } } else { while (p && *p) { if (memcmp(p, str, len) == 0) { clr = COUNT_CLR + ((unsigned char *)p)[len]; // printf("PLEN %d %d\n", p[len], COUNT_CLR); return 1; } p += len + 1; } } if (len < 128) { char s[128]; memcpy(s, str, len); s[len] = 0; if (BFI(this, BFI_HilitTags) && TagDefined(s)) { // clr = 0x0A; clr = CLR_HexNumber; // Mode->fColorize->Colors[]; return 1; } } return 0; }
int EBuffer::HilitAddWord(const char *Word) { if (HilitFindWord(Word) == 1) return 1; WordList = (char **)realloc((void *)WordList, (1 + WordCount) * sizeof(char *)); if (WordList == 0) return 0; WordList[WordCount++] = strdup(Word); FullRedraw(); return 1; }
int EBuffer::HilitWord() { PELine L = VLine(CP.Row); char s[CK_MAXLEN + 2]; int P, len = 0; P = CharOffset(L, CP.Col); while ((P > 0) && ((ChClass(L->Chars[P - 1]) == 1) || (L->Chars[P - 1] == '_'))) P--; while (len < CK_MAXLEN && P < L->Count && (ChClass(L->Chars[P]) == 1 || L->Chars[P] == '_')) s[len++] = L->Chars[P++]; if (len == 0) return 0; s[len] = 0; return (HilitFindWord(s)) ? HilitRemoveWord(s) : HilitAddWord(s); }