@@ -42,18 +42,6 @@ type Model struct {
42
42
// useful for setting borders, margins and padding.
43
43
Style lipgloss.Style
44
44
45
- // HighPerformanceRendering bypasses the normal Bubble Tea renderer to
46
- // provide higher performance rendering. Most of the time the normal Bubble
47
- // Tea rendering methods will suffice, but if you're passing content with
48
- // a lot of ANSI escape codes you may see improved rendering in certain
49
- // terminals with this enabled.
50
- //
51
- // This should only be used in program occupying the entire terminal,
52
- // which is usually via the alternate screen buffer.
53
- //
54
- // Deprecated: high performance rendering is now deprecated in Bubble Tea.
55
- HighPerformanceRendering bool
56
-
57
45
initialized bool
58
46
lines []string
59
47
}
@@ -145,12 +133,12 @@ func (m *Model) SetYOffset(n int) {
145
133
146
134
// ViewDown moves the view down by the number of lines in the viewport.
147
135
// Basically, "page down".
148
- func (m * Model ) ViewDown () [] string {
136
+ func (m * Model ) ViewDown () {
149
137
if m .AtBottom () {
150
- return nil
138
+ return
151
139
}
152
140
153
- return m .LineDown (m .Height )
141
+ m .LineDown (m .Height )
154
142
}
155
143
156
144
// ViewUp moves the view up by one height of the viewport. Basically, "page up".
@@ -163,40 +151,33 @@ func (m *Model) ViewUp() []string {
163
151
}
164
152
165
153
// HalfViewDown moves the view down by half the height of the viewport.
166
- func (m * Model ) HalfViewDown () ( lines [] string ) {
154
+ func (m * Model ) HalfViewDown () {
167
155
if m .AtBottom () {
168
- return nil
156
+ return
169
157
}
170
158
171
- return m .LineDown (m .Height / 2 )
159
+ m .LineDown (m .Height / 2 )
172
160
}
173
161
174
162
// HalfViewUp moves the view up by half the height of the viewport.
175
- func (m * Model ) HalfViewUp () ( lines [] string ) {
163
+ func (m * Model ) HalfViewUp () {
176
164
if m .AtTop () {
177
- return nil
165
+ return
178
166
}
179
167
180
- return m .LineUp (m .Height / 2 )
168
+ m .LineUp (m .Height / 2 )
181
169
}
182
170
183
171
// LineDown moves the view down by the given number of lines.
184
- func (m * Model ) LineDown (n int ) ( lines [] string ) {
172
+ func (m * Model ) LineDown (n int ) {
185
173
if m .AtBottom () || n == 0 || len (m .lines ) == 0 {
186
- return nil
174
+ return
187
175
}
188
176
189
177
// Make sure the number of lines by which we're going to scroll isn't
190
178
// greater than the number of lines we actually have left before we reach
191
179
// the bottom.
192
180
m .SetYOffset (m .YOffset + n )
193
-
194
- // Gather lines to send off for performance scrolling.
195
- //
196
- // XXX: high performance rendering is deprecated in Bubble Tea.
197
- bottom := clamp (m .YOffset + m .Height , 0 , len (m .lines ))
198
- top := clamp (m .YOffset + m .Height - n , 0 , bottom )
199
- return m .lines [top :bottom ]
200
181
}
201
182
202
183
// LineUp moves the view down by the given number of lines. Returns the new
@@ -244,52 +225,6 @@ func (m *Model) GotoBottom() (lines []string) {
244
225
return m .visibleLines ()
245
226
}
246
227
247
- // Sync tells the renderer where the viewport will be located and requests
248
- // a render of the current state of the viewport. It should be called for the
249
- // first render and after a window resize.
250
- //
251
- // For high performance rendering only.
252
- //
253
- // Deprecated: high performance rendering is deprecated in Bubble Tea.
254
- func Sync (m Model ) tea.Cmd {
255
- if len (m .lines ) == 0 {
256
- return nil
257
- }
258
- top , bottom := m .scrollArea ()
259
- return tea .SyncScrollArea (m .visibleLines (), top , bottom )
260
- }
261
-
262
- // ViewDown is a high performance command that moves the viewport up by a given
263
- // number of lines. Use Model.ViewDown to get the lines that should be rendered.
264
- // For example:
265
- //
266
- // lines := model.ViewDown(1)
267
- // cmd := ViewDown(m, lines)
268
- func ViewDown (m Model , lines []string ) tea.Cmd {
269
- if len (lines ) == 0 {
270
- return nil
271
- }
272
- top , bottom := m .scrollArea ()
273
-
274
- // XXX: high performance rendering is deprecated in Bubble Tea. In a v2 we
275
- // won't need to return a command here.
276
- return tea .ScrollDown (lines , top , bottom )
277
- }
278
-
279
- // ViewUp is a high performance command the moves the viewport down by a given
280
- // number of lines height. Use Model.ViewUp to get the lines that should be
281
- // rendered.
282
- func ViewUp (m Model , lines []string ) tea.Cmd {
283
- if len (lines ) == 0 {
284
- return nil
285
- }
286
- top , bottom := m .scrollArea ()
287
-
288
- // XXX: high performance rendering is deprecated in Bubble Tea. In a v2 we
289
- // won't need to return a command here.
290
- return tea .ScrollUp (lines , top , bottom )
291
- }
292
-
293
228
// Update handles standard message-based viewport updates.
294
229
func (m Model ) Update (msg tea.Msg ) (Model , tea.Cmd ) {
295
230
var cmd tea.Cmd
@@ -304,46 +239,26 @@ func (m Model) updateAsModel(msg tea.Msg) (Model, tea.Cmd) {
304
239
m .setInitialValues ()
305
240
}
306
241
307
- var cmd tea.Cmd
308
-
309
242
switch msg := msg .(type ) {
310
243
case tea.KeyPressMsg :
311
244
switch {
312
245
case key .Matches (msg , m .KeyMap .PageDown ):
313
- lines := m .ViewDown ()
314
- if m .HighPerformanceRendering {
315
- cmd = ViewDown (m , lines )
316
- }
246
+ m .ViewDown ()
317
247
318
248
case key .Matches (msg , m .KeyMap .PageUp ):
319
- lines := m .ViewUp ()
320
- if m .HighPerformanceRendering {
321
- cmd = ViewUp (m , lines )
322
- }
249
+ m .ViewUp ()
323
250
324
251
case key .Matches (msg , m .KeyMap .HalfPageDown ):
325
- lines := m .HalfViewDown ()
326
- if m .HighPerformanceRendering {
327
- cmd = ViewDown (m , lines )
328
- }
252
+ m .HalfViewDown ()
329
253
330
254
case key .Matches (msg , m .KeyMap .HalfPageUp ):
331
- lines := m .HalfViewUp ()
332
- if m .HighPerformanceRendering {
333
- cmd = ViewUp (m , lines )
334
- }
255
+ m .HalfViewUp ()
335
256
336
257
case key .Matches (msg , m .KeyMap .Down ):
337
- lines := m .LineDown (1 )
338
- if m .HighPerformanceRendering {
339
- cmd = ViewDown (m , lines )
340
- }
258
+ m .LineDown (1 )
341
259
342
260
case key .Matches (msg , m .KeyMap .Up ):
343
- lines := m .LineUp (1 )
344
- if m .HighPerformanceRendering {
345
- cmd = ViewUp (m , lines )
346
- }
261
+ m .LineUp (1 )
347
262
}
348
263
349
264
case tea.MouseWheelMsg :
@@ -353,32 +268,18 @@ func (m Model) updateAsModel(msg tea.Msg) (Model, tea.Cmd) {
353
268
354
269
switch msg .Button {
355
270
case tea .MouseWheelDown :
356
- lines := m .LineDown (m .MouseWheelDelta )
357
- if m .HighPerformanceRendering {
358
- cmd = ViewDown (m , lines )
359
- }
271
+ m .LineDown (m .MouseWheelDelta )
360
272
361
273
case tea .MouseWheelUp :
362
- lines := m .LineUp (m .MouseWheelDelta )
363
- if m .HighPerformanceRendering {
364
- cmd = ViewUp (m , lines )
365
- }
274
+ m .LineUp (m .MouseWheelDelta )
366
275
}
367
276
}
368
277
369
- return m , cmd
278
+ return m , nil
370
279
}
371
280
372
281
// View renders the viewport into a string.
373
282
func (m Model ) View () string {
374
- if m .HighPerformanceRendering {
375
- // Just send newlines since we're going to be rendering the actual
376
- // content separately. We still need to send something that equals the
377
- // height of this view so that the Bubble Tea standard renderer can
378
- // position anything below this view properly.
379
- return strings .Repeat ("\n " , max (0 , m .Height - 1 ))
380
- }
381
-
382
283
w , h := m .Width , m .Height
383
284
if sw := m .Style .GetWidth (); sw != 0 {
384
285
w = min (w , sw )
0 commit comments