comparison dwtx/jface/text/ListLineTracker.d @ 134:51e6e63f930e

Regex fix for casts
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 01:46:20 +0200
parents 7d818bd32d63
children 6dcb0baaa031
comparison
equal deleted inserted replaced
133:7d818bd32d63 134:51e6e63f930e
208 208
209 while (left < right) { 209 while (left < right) {
210 210
211 mid= (left + right) / 2; 211 mid= (left + right) / 2;
212 212
213 line= (Line) fLines.get(mid); 213 line= cast(Line) fLines.get(mid);
214 if (offset < line.offset) { 214 if (offset < line.offset) {
215 if (left is mid) 215 if (left is mid)
216 right= left; 216 right= left;
217 else 217 else
218 right= mid - 1; 218 right= mid - 1;
224 } else if (offset is line.offset) { 224 } else if (offset is line.offset) {
225 left= right= mid; 225 left= right= mid;
226 } 226 }
227 } 227 }
228 228
229 line= (Line) fLines.get(left); 229 line= cast(Line) fLines.get(left);
230 if (line.offset > offset) 230 if (line.offset > offset)
231 --left; 231 --left;
232 return left; 232 return left;
233 } 233 }
234 234
246 if (length is 0) 246 if (length is 0)
247 return 1; 247 return 1;
248 248
249 int target= offset + length; 249 int target= offset + length;
250 250
251 Line l= (Line) fLines.get(startLine); 251 Line l= cast(Line) fLines.get(startLine);
252 252
253 if (l.delimiter is null) 253 if (l.delimiter is null)
254 return 1; 254 return 1;
255 255
256 if (l.offset + l.length > target) 256 if (l.offset + l.length > target)
272 throw new BadLocationException(); 272 throw new BadLocationException();
273 273
274 if (lines is 0 || lines is line) 274 if (lines is 0 || lines is line)
275 return 0; 275 return 0;
276 276
277 Line l= (Line) fLines.get(line); 277 Line l= cast(Line) fLines.get(line);
278 return l.length; 278 return l.length;
279 } 279 }
280 280
281 /* 281 /*
282 * @see dwtx.jface.text.ILineTracker#getLineNumberOfOffset(int) 282 * @see dwtx.jface.text.ILineTracker#getLineNumberOfOffset(int)
289 289
290 int lastLine= fLines.size() - 1; 290 int lastLine= fLines.size() - 1;
291 if (lastLine < 0) 291 if (lastLine < 0)
292 return 0; 292 return 0;
293 293
294 Line l= (Line) fLines.get(lastLine); 294 Line l= cast(Line) fLines.get(lastLine);
295 return (l.delimiter !is null ? lastLine + 1 : lastLine); 295 return (l.delimiter !is null ? lastLine + 1 : lastLine);
296 } 296 }
297 297
298 return findLine(position); 298 return findLine(position);
299 } 299 }
307 307
308 if (position is fTextLength) { 308 if (position is fTextLength) {
309 int size= fLines.size(); 309 int size= fLines.size();
310 if (size is 0) 310 if (size is 0)
311 return new Region(0, 0); 311 return new Region(0, 0);
312 Line l= (Line) fLines.get(size - 1); 312 Line l= cast(Line) fLines.get(size - 1);
313 return (l.delimiter !is null ? new Line(fTextLength, 0) : new Line(fTextLength - l.length, l.length)); 313 return (l.delimiter !is null ? new Line(fTextLength, 0) : new Line(fTextLength - l.length, l.length));
314 } 314 }
315 315
316 return getLineInformation(findLine(position)); 316 return getLineInformation(findLine(position));
317 } 317 }
327 327
328 if (lines is 0) 328 if (lines is 0)
329 return new Line(0, 0); 329 return new Line(0, 0);
330 330
331 if (line is lines) { 331 if (line is lines) {
332 Line l= (Line) fLines.get(line - 1); 332 Line l= cast(Line) fLines.get(line - 1);
333 return new Line(l.offset + l.length, 0); 333 return new Line(l.offset + l.length, 0);
334 } 334 }
335 335
336 Line l= (Line) fLines.get(line); 336 Line l= cast(Line) fLines.get(line);
337 return (l.delimiter !is null ? new Line(l.offset, l.length - l.delimiter.length()) : l); 337 return (l.delimiter !is null ? new Line(l.offset, l.length - l.delimiter.length()) : l);
338 } 338 }
339 339
340 /* 340 /*
341 * @see dwtx.jface.text.ILineTracker#getLineOffset(int) 341 * @see dwtx.jface.text.ILineTracker#getLineOffset(int)
348 348
349 if (lines is 0) 349 if (lines is 0)
350 return 0; 350 return 0;
351 351
352 if (line is lines) { 352 if (line is lines) {
353 Line l= (Line) fLines.get(line - 1); 353 Line l= cast(Line) fLines.get(line - 1);
354 if (l.delimiter !is null) 354 if (l.delimiter !is null)
355 return l.offset + l.length; 355 return l.offset + l.length;
356 throw new BadLocationException(); 356 throw new BadLocationException();
357 } 357 }
358 358
359 Line l= (Line) fLines.get(line); 359 Line l= cast(Line) fLines.get(line);
360 return l.offset; 360 return l.offset;
361 } 361 }
362 362
363 /* 363 /*
364 * @see dwtx.jface.text.ILineTracker#getNumberOfLines() 364 * @see dwtx.jface.text.ILineTracker#getNumberOfLines()
367 int lines= fLines.size(); 367 int lines= fLines.size();
368 368
369 if (lines is 0) 369 if (lines is 0)
370 return 1; 370 return 1;
371 371
372 Line l= (Line) fLines.get(lines - 1); 372 Line l= cast(Line) fLines.get(lines - 1);
373 return (l.delimiter !is null ? lines + 1 : lines); 373 return (l.delimiter !is null ? lines + 1 : lines);
374 } 374 }
375 375
376 /* 376 /*
377 * @see dwtx.jface.text.ILineTracker#getNumberOfLines(int, int) 377 * @see dwtx.jface.text.ILineTracker#getNumberOfLines(int, int)
415 return null; 415 return null;
416 416
417 if (line is lines) 417 if (line is lines)
418 return null; 418 return null;
419 419
420 Line l= (Line) fLines.get(line); 420 Line l= cast(Line) fLines.get(line);
421 return l.delimiter; 421 return l.delimiter;
422 } 422 }
423 423
424 /** 424 /**
425 * Returns the information about the first delimiter found in the given text starting at the 425 * Returns the information about the first delimiter found in the given text starting at the
462 } 462 }
463 463
464 if (start < text.length()) { 464 if (start < text.length()) {
465 if (insertPosition + count < fLines.size()) { 465 if (insertPosition + count < fLines.size()) {
466 // there is a line below the current 466 // there is a line below the current
467 Line l= (Line) fLines.get(insertPosition + count); 467 Line l= cast(Line) fLines.get(insertPosition + count);
468 int delta= text.length() - start; 468 int delta= text.length() - start;
469 l.offset-= delta; 469 l.offset-= delta;
470 l.length+= delta; 470 l.length+= delta;
471 } else { 471 } else {
472 fLines.add(new Line(offset + start, offset + text.length() - 1, null)); 472 fLines.add(new Line(offset + start, offset + text.length() - 1, null));