@@ -85,7 +85,7 @@ defmodule Scenic.Component.Input.TextField do
85
85
86
86
# theme is passed in as an inherited style
87
87
theme =
88
- ( styles [ :theme ] || Theme . preset ( :dark ) )
88
+ ( styles [ :theme ] || Theme . preset_caret ( :dark ) )
89
89
|> Theme . normalize ( )
90
90
91
91
# get the text_field specific styles
@@ -131,7 +131,7 @@ defmodule Scenic.Component.Input.TextField do
131
131
t: { 0 , @ default_font_size } ,
132
132
id: :text
133
133
)
134
- |> Caret . add_to_graph ( { height , theme . text } , id: :carat )
134
+ |> Caret . add_to_graph ( { height , theme . text } , id: :caret )
135
135
end ,
136
136
t: { @ inset_x , 0 }
137
137
)
@@ -142,7 +142,7 @@ defmodule Scenic.Component.Input.TextField do
142
142
id: :border
143
143
)
144
144
|> update_text ( display , state )
145
- |> update_carat ( display , index )
145
+ |> update_caret ( display , index )
146
146
|> push_graph ( )
147
147
148
148
{ :ok , % { state | graph: graph } }
@@ -164,12 +164,12 @@ defmodule Scenic.Component.Input.TextField do
164
164
165
165
# --------------------------------------------------------
166
166
# current value string is empty. show the hint string
167
- # defp update_carat ( graph, state ) do
168
- # x = calc_carat_x ( state )
169
- # Graph.modify( graph, :carat , &update_opts(&1, t: {x,0}) )
167
+ # defp update_caret ( graph, state ) do
168
+ # x = calc_caret_x ( state )
169
+ # Graph.modify( graph, :caret , &update_opts(&1, t: {x,0}) )
170
170
# end
171
171
172
- defp update_carat ( graph , value , index ) do
172
+ defp update_caret ( graph , value , index ) do
173
173
str_len = String . length ( value )
174
174
175
175
# double check the postition
@@ -180,25 +180,25 @@ defmodule Scenic.Component.Input.TextField do
180
180
true -> index
181
181
end
182
182
183
- # calc the carat position
183
+ # calc the caret position
184
184
x = index * @ char_width
185
185
186
- # move the carat
187
- Graph . modify ( graph , :carat , & update_opts ( & 1 , t: { x , 0 } ) )
186
+ # move the caret
187
+ Graph . modify ( graph , :caret , & update_opts ( & 1 , t: { x , 0 } ) )
188
188
end
189
189
190
190
# --------------------------------------------------------
191
191
defp capture_focus ( context , % { focused: false , graph: graph , theme: theme } = state ) do
192
192
# capture the input
193
193
ViewPort . capture_input ( context , @ input_capture )
194
194
195
- # start animating the carat
196
- Scene . cast_to_refs ( nil , :gain_focus )
195
+ # start animating the caret
196
+ Scene . cast_to_refs ( nil , :start_caret )
197
197
198
- # show the carat
198
+ # show the caret
199
199
graph =
200
200
graph
201
- |> Graph . modify ( :carat , & update_opts ( & 1 , hidden: false ) )
201
+ |> Graph . modify ( :caret , & update_opts ( & 1 , hidden: false ) )
202
202
|> Graph . modify ( :border , & update_opts ( & 1 , stroke: { 2 , theme . focus } ) )
203
203
|> push_graph ( )
204
204
@@ -213,13 +213,13 @@ defmodule Scenic.Component.Input.TextField do
213
213
# release the input
214
214
ViewPort . release_input ( context , @ input_capture )
215
215
216
- # stop animating the carat
217
- Scene . cast_to_refs ( nil , :lose_focus )
216
+ # stop animating the caret
217
+ Scene . cast_to_refs ( nil , :stop_caret )
218
218
219
- # hide the carat
219
+ # hide the caret
220
220
graph =
221
221
graph
222
- |> Graph . modify ( :carat , & update_opts ( & 1 , hidden: true ) )
222
+ |> Graph . modify ( :caret , & update_opts ( & 1 , hidden: true ) )
223
223
|> Graph . modify ( :border , & update_opts ( & 1 , stroke: { 2 , theme . border } ) )
224
224
|> push_graph ( )
225
225
@@ -306,11 +306,11 @@ defmodule Scenic.Component.Input.TextField do
306
306
{ index , graph }
307
307
308
308
i ->
309
- # reset the carat blinker
310
- Scene . cast_to_refs ( nil , :reset_carat )
311
- # move the carat
309
+ # reset_caret the caret blinker
310
+ Scene . cast_to_refs ( nil , :reset_caret )
311
+ # move the caret
312
312
graph =
313
- update_carat ( graph , value , i )
313
+ update_caret ( graph , value , i )
314
314
|> push_graph ( )
315
315
316
316
{ i , graph }
@@ -351,13 +351,13 @@ defmodule Scenic.Component.Input.TextField do
351
351
{ 0 , graph }
352
352
353
353
i ->
354
- # reset the carat blinker
355
- Scene . cast_to_refs ( nil , :reset_carat )
356
- # move the carat
354
+ # reset_caret the caret blinker
355
+ Scene . cast_to_refs ( nil , :reset_caret )
356
+ # move the caret
357
357
i = i - 1
358
358
359
359
graph =
360
- update_carat ( graph , value , i )
360
+ update_caret ( graph , value , i )
361
361
|> push_graph ( )
362
362
363
363
{ i , graph }
@@ -372,7 +372,7 @@ defmodule Scenic.Component.Input.TextField do
372
372
_context ,
373
373
% { index: index , value: value , graph: graph } = state
374
374
) do
375
- # the max position for the carat
375
+ # the max position for the caret
376
376
max_index = String . length ( value )
377
377
378
378
# move left. clamp to 0
@@ -382,13 +382,13 @@ defmodule Scenic.Component.Input.TextField do
382
382
{ index , graph }
383
383
384
384
i ->
385
- # reset the carat blinker
386
- Scene . cast_to_refs ( nil , :reset_carat )
387
- # move the carat
385
+ # reset the caret blinker
386
+ Scene . cast_to_refs ( nil , :reset_caret_caret )
387
+ # move the caret
388
388
i = i + 1
389
389
390
390
graph =
391
- update_carat ( graph , value , i )
391
+ update_caret ( graph , value , i )
392
392
|> push_graph ( )
393
393
394
394
{ i , graph }
@@ -414,11 +414,11 @@ defmodule Scenic.Component.Input.TextField do
414
414
{ index , graph }
415
415
416
416
_ ->
417
- # reset the carat blinker
418
- Scene . cast_to_refs ( nil , :reset_carat )
419
- # move the carat
417
+ # reset the caret blinker
418
+ Scene . cast_to_refs ( nil , :reset_caret )
419
+ # move the caret
420
420
graph =
421
- update_carat ( graph , value , 0 )
421
+ update_caret ( graph , value , 0 )
422
422
|> push_graph ( )
423
423
424
424
{ 0 , graph }
@@ -437,7 +437,7 @@ defmodule Scenic.Component.Input.TextField do
437
437
_context ,
438
438
% { index: index , value: value , graph: graph } = state
439
439
) do
440
- # the max position for the carat
440
+ # the max position for the caret
441
441
max_index = String . length ( value )
442
442
443
443
# move left. clamp to 0
@@ -447,11 +447,11 @@ defmodule Scenic.Component.Input.TextField do
447
447
{ index , graph }
448
448
449
449
_ ->
450
- # reset the carat blinker
451
- Scene . cast_to_refs ( nil , :reset_carat )
452
- # move the carat
450
+ # reset the caret blinker
451
+ Scene . cast_to_refs ( nil , :reset_caret )
452
+ # move the caret
453
453
graph =
454
- update_carat ( graph , value , max_index )
454
+ update_caret ( graph , value , max_index )
455
455
|> push_graph ( )
456
456
457
457
{ max_index , graph }
@@ -477,8 +477,8 @@ defmodule Scenic.Component.Input.TextField do
477
477
id: id
478
478
} = state
479
479
) do
480
- # reset the carat blinker
481
- Scene . cast_to_refs ( nil , :reset_carat )
480
+ # reset_caret the caret blinker
481
+ Scene . cast_to_refs ( nil , :reset_caret )
482
482
483
483
# delete the char to the left of the index
484
484
value =
@@ -498,7 +498,7 @@ defmodule Scenic.Component.Input.TextField do
498
498
graph =
499
499
graph
500
500
|> update_text ( display , state )
501
- |> update_carat ( display , index )
501
+ |> update_caret ( display , index )
502
502
|> push_graph ( )
503
503
504
504
state =
@@ -523,8 +523,8 @@ defmodule Scenic.Component.Input.TextField do
523
523
id: id
524
524
} = state
525
525
) do
526
- # reset the carat blinker
527
- Scene . cast_to_refs ( nil , :reset_carat )
526
+ # reset the caret blinker
527
+ Scene . cast_to_refs ( nil , :reset_caret )
528
528
529
529
# delete the char at the index
530
530
value =
@@ -537,7 +537,7 @@ defmodule Scenic.Component.Input.TextField do
537
537
# send the value changed event
538
538
send_event ( { :value_changed , id , value } )
539
539
540
- # update the graph (the carat doesn't move)
540
+ # update the graph (the caret doesn't move)
541
541
graph =
542
542
graph
543
543
|> update_text ( display , state )
@@ -591,8 +591,8 @@ defmodule Scenic.Component.Input.TextField do
591
591
id: id
592
592
} = state
593
593
) do
594
- # reset the carat blinker
595
- Scene . cast_to_refs ( nil , :reset_carat )
594
+ # reset the caret blinker
595
+ Scene . cast_to_refs ( nil , :reset_caret )
596
596
597
597
# insert the char into the string at the index location
598
598
{ left , right } = String . split_at ( value , index )
@@ -609,7 +609,7 @@ defmodule Scenic.Component.Input.TextField do
609
609
graph =
610
610
graph
611
611
|> update_text ( display , state )
612
- |> update_carat ( display , index )
612
+ |> update_caret ( display , index )
613
613
|> push_graph ( )
614
614
615
615
state =
0 commit comments