5
5
#include < cstddef> // for size_t
6
6
#include < cstdint> // for uint32_t
7
7
#include < functional> // for function
8
- #include < memory> // for allocator, shared_ptr, allocator_traits<>::value_type
9
- #include < sstream> // for basic_istream, stringstream
10
- #include < string> // for string, basic_string, operator==, getline
11
- #include < utility> // for move
12
- #include < vector> // for vector
8
+ #include < sstream> // for basic_istream, stringstream
9
+ #include < string> // for string, basic_string, operator==, getline
10
+ #include < utility> // for move
11
+ #include < vector> // for vector
13
12
14
- #include " ftxui/component/captured_mouse.hpp" // for CapturedMouse
15
13
#include " ftxui/component/component.hpp" // for Make, Input
16
14
#include " ftxui/component/component_base.hpp" // for ComponentBase
17
15
#include " ftxui/component/component_options.hpp" // for InputOption
@@ -134,7 +132,7 @@ class InputBase : public ComponentBase, public InputOption {
134
132
break ;
135
133
}
136
134
137
- cursor_char_index -= line.size () + 1 ;
135
+ cursor_char_index -= static_cast < int >( line.size () + 1 ) ;
138
136
cursor_line++;
139
137
}
140
138
@@ -164,7 +162,7 @@ class InputBase : public ComponentBase, public InputOption {
164
162
165
163
// The cursor is on this line.
166
164
const int glyph_start = cursor_char_index;
167
- const int glyph_end = GlyphNext (line, glyph_start);
165
+ const int glyph_end = static_cast < int >( GlyphNext (line, glyph_start) );
168
166
const std::string part_before_cursor = line.substr (0 , glyph_start);
169
167
const std::string part_at_cursor =
170
168
line.substr (glyph_start, glyph_end - glyph_start);
@@ -206,7 +204,7 @@ class InputBase : public ComponentBase, public InputOption {
206
204
const size_t start = GlyphPrevious (content (), cursor_position ());
207
205
const size_t end = cursor_position ();
208
206
content->erase (start, end - start);
209
- cursor_position () = start;
207
+ cursor_position () = static_cast < int >( start) ;
210
208
on_change ();
211
209
return true ;
212
210
}
@@ -234,7 +232,8 @@ class InputBase : public ComponentBase, public InputOption {
234
232
return false ;
235
233
}
236
234
237
- cursor_position () = GlyphPrevious (content (), cursor_position ());
235
+ cursor_position () =
236
+ static_cast <int >(GlyphPrevious (content (), cursor_position ()));
238
237
return true ;
239
238
}
240
239
@@ -243,7 +242,8 @@ class InputBase : public ComponentBase, public InputOption {
243
242
return false ;
244
243
}
245
244
246
- cursor_position () = GlyphNext (content (), cursor_position ());
245
+ cursor_position () =
246
+ static_cast <int >(GlyphNext (content (), cursor_position ()));
247
247
return true ;
248
248
}
249
249
@@ -258,7 +258,7 @@ class InputBase : public ComponentBase, public InputOption {
258
258
if (content ()[iter] == ' \n ' ) {
259
259
break ;
260
260
}
261
- width += GlyphWidth (content (), iter);
261
+ width += static_cast < int >( GlyphWidth (content (), iter) );
262
262
}
263
263
return width;
264
264
}
@@ -271,8 +271,9 @@ class InputBase : public ComponentBase, public InputOption {
271
271
return ;
272
272
}
273
273
274
- columns -= GlyphWidth (content (), cursor_position ());
275
- cursor_position () = GlyphNext (content (), cursor_position ());
274
+ columns -= static_cast <int >(GlyphWidth (content (), cursor_position ()));
275
+ cursor_position () =
276
+ static_cast <int >(GlyphNext (content (), cursor_position ()));
276
277
}
277
278
}
278
279
@@ -292,9 +293,10 @@ class InputBase : public ComponentBase, public InputOption {
292
293
if (content ()[previous] == ' \n ' ) {
293
294
break ;
294
295
}
295
- cursor_position () = previous;
296
+ cursor_position () = static_cast < int >( previous) ;
296
297
}
297
- cursor_position () = GlyphPrevious (content (), cursor_position ());
298
+ cursor_position () =
299
+ static_cast <int >(GlyphPrevious (content (), cursor_position ()));
298
300
while (true ) {
299
301
if (cursor_position () == 0 ) {
300
302
break ;
@@ -303,10 +305,10 @@ class InputBase : public ComponentBase, public InputOption {
303
305
if (content ()[previous] == ' \n ' ) {
304
306
break ;
305
307
}
306
- cursor_position () = previous;
308
+ cursor_position () = static_cast < int >( previous) ;
307
309
}
308
310
309
- MoveCursorColumn (columns);
311
+ MoveCursorColumn (static_cast < int >( columns) );
310
312
return true ;
311
313
}
312
314
@@ -322,14 +324,16 @@ class InputBase : public ComponentBase, public InputOption {
322
324
if (content ()[cursor_position ()] == ' \n ' ) {
323
325
break ;
324
326
}
325
- cursor_position () = GlyphNext (content (), cursor_position ());
327
+ cursor_position () =
328
+ static_cast <int >(GlyphNext (content (), cursor_position ()));
326
329
if (cursor_position () == (int )content ().size ()) {
327
330
return true ;
328
331
}
329
332
}
330
- cursor_position () = GlyphNext (content (), cursor_position ());
333
+ cursor_position () =
334
+ static_cast <int >(GlyphNext (content (), cursor_position ()));
331
335
332
- MoveCursorColumn (columns);
336
+ MoveCursorColumn (static_cast < int >( columns) );
333
337
return true ;
334
338
}
335
339
@@ -339,7 +343,7 @@ class InputBase : public ComponentBase, public InputOption {
339
343
}
340
344
341
345
bool HandleEnd () {
342
- cursor_position () = content->size ();
346
+ cursor_position () = static_cast < int >( content->size () );
343
347
return true ;
344
348
}
345
349
@@ -357,7 +361,7 @@ class InputBase : public ComponentBase, public InputOption {
357
361
DeleteImpl ();
358
362
}
359
363
content->insert (cursor_position (), character);
360
- cursor_position () += character.size ();
364
+ cursor_position () += static_cast < int >( character.size () );
361
365
on_change ();
362
366
return true ;
363
367
}
@@ -421,15 +425,15 @@ class InputBase : public ComponentBase, public InputOption {
421
425
if (IsWordCharacter (content (), previous)) {
422
426
break ;
423
427
}
424
- cursor_position () = previous;
428
+ cursor_position () = static_cast < int >( previous) ;
425
429
}
426
430
// Move left, as long as left is a word character:
427
431
while (cursor_position ()) {
428
432
const size_t previous = GlyphPrevious (content (), cursor_position ());
429
433
if (!IsWordCharacter (content (), previous)) {
430
434
break ;
431
435
}
432
- cursor_position () = previous;
436
+ cursor_position () = static_cast < int >( previous) ;
433
437
}
434
438
return true ;
435
439
}
@@ -441,7 +445,8 @@ class InputBase : public ComponentBase, public InputOption {
441
445
442
446
// Move right, until entering a word.
443
447
while (cursor_position () < (int )content ().size ()) {
444
- cursor_position () = GlyphNext (content (), cursor_position ());
448
+ cursor_position () =
449
+ static_cast <int >(GlyphNext (content (), cursor_position ()));
445
450
if (IsWordCharacter (content (), cursor_position ())) {
446
451
break ;
447
452
}
@@ -452,7 +457,7 @@ class InputBase : public ComponentBase, public InputOption {
452
457
if (!IsWordCharacter (content (), cursor_position ())) {
453
458
break ;
454
459
}
455
- cursor_position () = next;
460
+ cursor_position () = static_cast < int >( next) ;
456
461
}
457
462
458
463
return true ;
@@ -489,7 +494,7 @@ class InputBase : public ComponentBase, public InputOption {
489
494
break ;
490
495
}
491
496
492
- cursor_char_index -= line.size () + 1 ;
497
+ cursor_char_index -= static_cast < int >( line.size () + 1 ) ;
493
498
cursor_line++;
494
499
}
495
500
const int cursor_column =
@@ -515,11 +520,13 @@ class InputBase : public ComponentBase, public InputOption {
515
520
// Convert back the new_cursor_{line,column} toward cursor_position:
516
521
cursor_position () = 0 ;
517
522
for (int i = 0 ; i < new_cursor_line; ++i) {
518
- cursor_position () += lines[i].size () + 1 ;
523
+ cursor_position () += static_cast < int >( lines[i].size () + 1 ) ;
519
524
}
520
525
while (new_cursor_column > 0 ) {
521
- new_cursor_column -= GlyphWidth (content (), cursor_position ());
522
- cursor_position () = GlyphNext (content (), cursor_position ());
526
+ new_cursor_column -=
527
+ static_cast <int >(GlyphWidth (content (), cursor_position ()));
528
+ cursor_position () =
529
+ static_cast <int >(GlyphNext (content (), cursor_position ()));
523
530
}
524
531
525
532
on_change ();
0 commit comments