XhmikosR / notepad2-mod

LOOKING FOR DEVELOPERS - Notepad2-mod, a Notepad2 fork, a fast and light-weight Notepad-like text editor with syntax highlighting
https://xhmikosr.github.io/notepad2-mod/
Other
1.45k stars 270 forks source link

add keywords of current EDITLEXER to AutoComplete word list #22

Closed zufuliu closed 12 years ago

zufuliu commented 12 years ago

in Edit.c function CompleteWord() pLexCurrent is defined in Styles.c the magic number 9 is defined in Styles.h

....

if (iStartWordPos == iCurrentLinePos || bWordAllNumbers || iCurrentLinePos - iStartWordPos < 1) { LocalFree(pLine); return; }

pWord = LocalAlloc(LPTR, 256); for (iRootLen = 0; iRootLen < 9; iRootLen++) { const char* pKeyword = pLexCurrent->pKeyWords->pszKeyWords[iRootLen]; iDocLen = 0; while (_pKeyword) { if (isspace(_pKeyword)) { pKeyword++; while (isspace(pKeyword)) pKeyword++; pWord[iDocLen] = 0; if (pWord[0]) { struct WLIST p = lListHead; struct WLIST* t = NULL; BOOL found = FALSE; while(p) { int cmp = lstrcmpA(pWord, p->word); if (!cmp) { found = TRUE; break; } else if (cmp < 0) { break; } t = p; p = p->next; } if (!found) { struct WLIST* el = (struct WLIST)LocalAlloc(LPTR, sizeof(struct WLIST)); el->word = LocalAlloc(LPTR, iDocLen + 1); lstrcpyA(el->word, pWord); el->next = p; if (t) { t->next = el; } else { lListHead = el; } iNumWords++; iWListSize += iDocLen + 1; } } iDocLen = 0; } else { pWord[iDocLen++] = pKeyword++; } } } LocalFree(pWord);

pRoot = LocalAlloc(LPTR, iCurrentLinePos - iStartWordPos + 1); lstrcpynA(pRoot, pLine + iStartWordPos, iCurrentLinePos - iStartWordPos + 1); LocalFree(pLine); iRootLen = lstrlenA(pRoot); ...

XhmikosR commented 12 years ago

I'm not sure I get what you mean. You can provide a pull request if you have a specific code change.