41
41
#define MAXBUF 1024
43
extern void fl_draw(const char*, int, float, float);
43
45
////////////////////////////////////////////////////////////////
45
47
// Copy string p..e to the buffer, replacing characters with ^X and \nnn
237
239
if (readonly()) erase_cursor_only = 0; // this isn't the most efficient way
238
240
if (erase_cursor_only && p > pp) goto CONTINUE2; // this line is after
239
241
// calculate area to erase:
244
246
if (erase_cursor_only) r = xpos+2;
245
247
else if (readonly()) xx -= 3;
247
xx = xpos+(int)expandpos(p, pp, buf, 0);
249
xx = xpos+expandpos(p, pp, buf, 0);
248
250
if (erase_cursor_only) r = xx+2;
249
251
else if (readonly()) xx -= 3;
251
253
// clip to and erase it:
252
fl_push_clip(xx, Y+ypos, r-xx, height);
254
fl_push_clip((int)xx, Y+ypos, (int)(r-xx+1), height);
253
255
draw_box(box(), X-Fl::box_dx(box()), Y-Fl::box_dy(box()),
254
256
W+Fl::box_dw(box()), H+Fl::box_dh(box()), color());
255
257
// it now draws entire line over it
260
262
// Draw selection area if required:
261
263
if (selstart < selend && selstart <= e-value() && selend > p-value()) {
262
264
const char* pp = value()+selstart;
267
x1 += int(expandpos(p, pp, buf, &offset1));
268
fl_draw(buf, offset1, xpos, Y+ypos+desc);
269
x1 += expandpos(p, pp, buf, &offset1);
270
fl_draw(buf, offset1, xpos, (float)(Y+ypos+desc));
270
272
pp = value()+selend;
273
if (pp <= e) x2 = xpos+int(expandpos(p, pp, buf, &offset2));
275
if (pp <= e) x2 = xpos+expandpos(p, pp, buf, &offset2);
274
276
else offset2 = strlen(buf);
275
277
fl_color(selection_color());
276
fl_rectf(x1, Y+ypos, x2-x1, height);
278
fl_rectf((int)(x1+0.5), Y+ypos, (int)(x2-x1+0.5), height);
277
279
fl_color(fl_contrast(textcolor(), selection_color()));
278
fl_draw(buf+offset1, offset2-offset1, x1, Y+ypos+desc);
280
fl_draw(buf+offset1, offset2-offset1, x1, (float)(Y+ypos+desc));
281
fl_draw(buf+offset2, x2, Y+ypos+desc);
283
fl_draw(buf+offset2, strlen(buf+offset2), x2, (float)(Y+ypos+desc));
284
286
// draw unselected text
286
fl_draw(buf, xpos, Y+ypos+desc);
288
fl_draw(buf, strlen(buf), xpos, (float)(Y+ypos+desc));
289
291
if (do_mu) fl_pop_clip();
294
296
position() >= p-value() && position() <= e-value()) {
295
297
fl_color(cursor_color());
296
298
if (readonly()) {
297
fl_line(xpos+curx-3, Y+ypos+height-1,
298
xpos+curx, Y+ypos+height-4,
299
xpos+curx+3, Y+ypos+height-1);
299
fl_line((int)(xpos+curx-2.5f), Y+ypos+height-1,
300
(int)(xpos+curx+0.5f), Y+ypos+height-4,
301
(int)(xpos+curx+3.5f), Y+ypos+height-1);
301
fl_rectf(xpos+curx, Y+ypos, 2, height);
303
fl_rectf((int)(xpos+curx+0.5), Y+ypos, 2, height);
650
654
void Fl_Input_::maybe_do_callback() {
651
655
if (changed() || (when()&FL_WHEN_NOT_CHANGED)) {
652
clear_changed(); do_callback();}
655
660
int Fl_Input_::handletext(int event, int X, int Y, int W, int H) {
796
// Note: the following code is equivalent to:
798
// if (moveit) value_ = value_ - buffer;
799
// char* nbuffer = (char*)realloc(buffer, bufsize);
800
// if (moveit) value_ = value_ + nbuffer;
803
// We just optimized the pointer arithmetic for value_...
791
805
char* nbuffer = (char*)realloc(buffer, bufsize);
792
806
if (moveit) value_ += (nbuffer-buffer);
793
807
buffer = nbuffer;