MCPcopy Create free account
hub / github.com/WheretIB/nullc / AdvanceCursor

Function AdvanceCursor

GUI/RichTextarea.cpp:136–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136int AdvanceCursor(AreaLine *line, int cursorX, bool left)
137{
138 // Advance direction
139 int dir = left ? -1 : 1;
140
141 // If out of bounds, return as it is
142 if(line->length == 0 || (left && cursorX == 0) || cursorX > (int)(line->length)-dir)
143 return cursorX;
144
145 // Find, what character is at the cursor position
146 unsigned char symb = line->data[cursorX + (left ? -1 : 0)].ch;
147
148 int minX = left ? 1 : 0;
149 int maxX = left ? line->length : line->length - 2;
150
151 // If it's a digit, move to the left, skipping all digits and '.'
152 if(isdigit(symb) || symb == '.')
153 {
154 while((cursorX >= minX && cursorX <= maxX) && (isdigit(line->data[cursorX + dir].ch) || line->data[cursorX + dir].ch == '.'))
155 cursorX += dir;
156 }else if(isalpha(symb) || symb == '_'){ // If it's an alphanumerical or '_', move to the left, skipping all of them
157 while((cursorX >= minX && cursorX <= maxX) && (isalnum(line->data[cursorX + dir].ch) || line->data[cursorX + dir].ch == '_'))
158 cursorX += dir;
159 }else{
160 if(cursorX != 0 && left)
161 cursorX--;
162 }
163
164 return cursorX;
165}
166
167int CALLBACK InitFont(const LOGFONTA *lpelfe, const TEXTMETRICA *lpntme, DWORD FontType, LPARAM lParam)
168{

Callers 3

OnKeyEventMethod · 0.85
OnMouseMoveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected