Huw Davies (@huw) commented about programs/notepad/main.c:
- wchar_t statusTxt[25];
- int lineIndex;
- DWORD selStart;
- DWORD selEnd;
- SendMessageW(Globals.hEdit,EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd);
- if(selStart == selEnd)
Globals.trackedSel = selStart;
- if(selStart < Globals.trackedSel)
currentCol = selStart;
- else
currentCol = selEnd;
- currentLine = SendMessageW(Globals.hEdit, EM_LINEFROMCHAR, currentCol,0);
- lineIndex = SendMessageW(Globals.hEdit, EM_LINEINDEX, currentLine,0);
- swprintf(statusTxt, 25, Globals.szStatusString,currentLine+1, (currentCol+1) - lineIndex);
Use `ARRAY_SIZE(statusTxt)` instead of hardcoding the size here. Add spaces either side of the '+'s (and after the commas).
I think that the final arg would be clearer if written as `(currentCol - lineIndex) + 1` (basically compute the column index as zero-based first of all, then add the one to make it ones-based).