about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-08-24 13:34:10 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-08-24 13:34:10 -0700
commit89081a8a78acd755f2c9b9899f341113c9f63c30 (patch)
treef3b333871d0a466727a5e0d854a162a8062a3c30
parent39b2c849c415f8efe56e40fabf414a0799fb2145 (diff)
parentce31b74b10798799f03b1a9fb54dff491a1cf223 (diff)
downloadtext.love-89081a8a78acd755f2c9b9899f341113c9f63c30.tar.gz
Merge lines.love
-rw-r--r--edit.lua1
-rw-r--r--main.lua11
2 files changed, 12 insertions, 0 deletions
diff --git a/edit.lua b/edit.lua
index 878ffb7..801a483 100644
--- a/edit.lua
+++ b/edit.lua
@@ -325,6 +325,7 @@ function edit.update_font_settings(State, font_height)
   love.graphics.setFont(love.graphics.newFont(Editor_state.font_height))
   State.line_height = math.floor(font_height*1.3)
   State.em = App.newText(love.graphics.getFont(), 'm')
+  Text_cache = {}
 end
 
 --== some methods for tests
diff --git a/main.lua b/main.lua
index f206dc0..86326df 100644
--- a/main.lua
+++ b/main.lua
@@ -17,6 +17,9 @@ Editor_state = {}
 function App.initialize_globals()
   -- tests currently mostly clear their own state
 
+  -- a few text objects we can avoid recomputing unless the font changes
+  Text_cache = {}
+
   -- blinking cursor
   Cursor_time = 0
 
@@ -200,3 +203,11 @@ function App.keyreleased(key, scancode)
   Cursor_time = 0  -- ensure cursor is visible immediately after it moves
   return edit.key_released(Editor_state, key, scancode)
 end
+
+-- use this sparingly
+function to_text(s)
+  if Text_cache[s] == nil then
+    Text_cache[s] = App.newText(love.graphics.getFont(), s)
+  end
+  return Text_cache[s]
+end
>775f77c3 ^
78357b88 ^
52e3ea8a ^


775f77c3 ^



52e3ea8a ^
775f77c3 ^




























762107fd ^
775f77c3 ^





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77