about summary refs log tree commit diff stats
path: root/edit
Commit message (Expand)AuthorAgeFilesLines
* 5856Kartik Agaram2020-01-011-7/+2
* 5485 - promote SubX to top-levelKartik Agaram2019-07-2714-12404/+23
* 4266 - space for alloc-id in heap allocationsKartik Agaram2018-06-241-10/+12
* 4262 - literal 'null'Kartik Agaram2018-06-1710-38/+38
* 4261 - start using literals for 'true' and 'false'Kartik Agaram2018-06-179-94/+107
* 4258 - undo 4257Kartik Agaram2018-06-153-39/+10
* 4257 - abortive attempt at safe fat pointersKartik Agaram2018-06-153-10/+39
* 4208Kartik K. Agaram2018-02-171-6/+42
* 4207Kartik K. Agaram2018-02-151-1/+0
* 4206 - edit/ app: consistent cursor positioningKartik K. Agaram2018-02-154-9/+3
* 4205Kartik K. Agaram2018-02-151-45/+45
* 4169Kartik K. Agaram2017-12-301-7/+5
* 4134 - 'input' = 'ingredient'Kartik K. Agaram2017-12-0312-92/+92
* 3984 - bugfix: display errors when scrolling recipe sideKartik K. Agaram2017-08-251-0/+38
* 3982 - bugfix: clear old recipe errors on F4Kartik K. Agaram2017-08-222-0/+60
* 3981Kartik K. Agaram2017-08-222-7/+4
* 3980Kartik K. Agaram2017-08-226-68/+68
* 3979Kartik K. Agaram2017-08-221-4/+4
* 3978Kartik K. Agaram2017-08-221-13/+18
* 3977Kartik K. Agaram2017-08-221-1/+1
* 3962Kartik K. Agaram2017-06-271-6/+13
* 3960Kartik K. Agaram2017-06-251-14/+38
* 3959Kartik K. Agaram2017-06-251-2/+13
* 3958Kartik K. Agaram2017-06-252-13/+19
* 3957Kartik K. Agaram2017-06-251-0/+2
* 3955Kartik K. Agaram2017-06-252-36/+32
* 3954Kartik K. Agaram2017-06-253-110/+39
* 3953Kartik K. Agaram2017-06-241-24/+51
* 3952Kartik K. Agaram2017-06-241-11/+10
* 3950Kartik K. Agaram2017-06-241-2/+43
* 3946Kartik K. Agaram2017-06-231-3/+3
* 3944Kartik K. Agaram2017-06-231-1/+25
* 3943Kartik K. Agaram2017-06-234-45/+0
* 3942Kartik K. Agaram2017-06-234-18/+18
* 3941Kartik K. Agaram2017-06-234-13/+29
* 3940Kartik K. Agaram2017-06-221-1/+1
* 3939Kartik K. Agaram2017-06-222-3/+9
* 3938Kartik K. Agaram2017-06-221-2/+32
* 3935Kartik K. Agaram2017-06-223-3/+3
* 3928Kartik K. Agaram2017-06-191-4/+5
* 3926Kartik K. Agaram2017-06-191-2/+57
* 3925Kartik K. Agaram2017-06-191-0/+292
* 3924Kartik K. Agaram2017-06-181-1/+1
* 3923Kartik K. Agaram2017-06-181-15/+91
* 3922Kartik K. Agaram2017-06-172-7/+4
* 3921Kartik K. Agaram2017-06-162-4/+6
* 3919Kartik K. Agaram2017-06-162-5/+89
* 3918Kartik K. Agaram2017-06-161-3/+47
* 3916 - minimal prints when commenting linesKartik K. Agaram2017-06-161-11/+139
* 3915Kartik K. Agaram2017-06-161-4/+2
0&id=143289bbd0736d72553a3c2a080aa3d125366b38'>^
fa04a1e ^


27b2517 ^

fa04a1e ^
27b2517 ^
337dd18 ^






fa04a1e ^
511fea3 ^



3376f92 ^
511fea3 ^















0897413 ^
511fea3 ^




0897413 ^
511fea3 ^


3376f92 ^
3376f92 ^



511fea3 ^




3376f92 ^

511fea3 ^


3376f92 ^







511fea3 ^



























3376f92 ^


















28fc9fa ^











0897413 ^



























511fea3 ^












3376f92 ^



511fea3 ^




3376f92 ^
511fea3 ^




d224487 ^
511fea3 ^

d224487 ^



511fea3 ^










3376f92 ^


511fea3 ^
3376f92 ^
511fea3 ^
3376f92 ^
511fea3 ^
3376f92 ^





511fea3 ^
3376f92 ^


28fc9fa ^






3376f92 ^
511fea3 ^

3376f92 ^
bbdf9df ^




f9262e4 ^
bbdf9df ^


3376f92 ^
bbdf9df ^
3376f92 ^
bbdf9df ^


3376f92 ^

bbdf9df ^


36419d8 ^
bbdf9df ^
8e5ed2a ^












36419d8 ^
8e5ed2a ^



bbdf9df ^


3376f92 ^





511fea3 ^
3376f92 ^


bbdf9df ^
3376f92 ^
bbdf9df ^
0897413 ^
511fea3 ^
bbdf9df ^

3376f92 ^
bbdf9df ^
511fea3 ^
bbdf9df ^
27b2517 ^

511fea3 ^






0abafa6 ^

3376f92 ^

f9262e4 ^
3376f92 ^


fa04a1e ^

3376f92 ^

6c36e04 ^
3376f92 ^




3cf6c82 ^
3376f92 ^
3cf6c82 ^
bbdf9df ^
3376f92 ^
bbdf9df ^
3376f92 ^

bbdf9df ^
f9262e4 ^
3cf6c82 ^














bbdf9df ^

0abafa6 ^
3376f92 ^
711d228 ^
3376f92 ^

711d228 ^




3376f92 ^

711d228 ^

3376f92 ^

0abafa6 ^



3376f92 ^
511fea3 ^
fa04a1e ^

3376f92 ^
511fea3 ^


33f2d4f ^
511fea3 ^






3376f92 ^



f9262e4 ^
3376f92 ^
fa04a1e ^


5685a17 ^
fa04a1e ^




27b2517 ^



4bdc0f3 ^




337dd18 ^
4bdc0f3 ^

337dd18 ^
4bdc0f3 ^

337dd18 ^
4bdc0f3 ^
27b2517 ^

fa04a1e ^


5685a17 ^
fa04a1e ^
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509



               
             

                 
                 
 
                                         
                                     
                                        
                                                  
                                             
                                  
                                 

                                       



                                               


                           
                        

                                   
                         






                                   

                              

 















                                                                                    
 

                                                                         
 
                                                
                                                                           




                                    
                                                                       










                                                   
                                                                  



                                    
                                                                


                            

                                                    
                                      
                                                             






                                                
 



                                  
 















                                                                                       
                                      




                                                                                   
                                                                                       


                                                     
         



                                       




                                   

         


                                                      







                              



























                                                                          


















                                                                                  











                                                  



























                                                                                   












                                                              



                    




                                               
         




                                                                          
                                            

                                                               



                                                                                










                                                        


                        
                        
                     
                    
                         
                     





                                   
                                 


                         






                                 
                                           

                                                                     
 




                                      
                                 


                                                  
                               
         
 


                                                

                                                               


                                                             
                                                                            
                         












                                                                           
                                                                            



                                  


                          





                                                               
                                                               


                                       
 
                          
                                
                               
                             

                                 
                              
                              
                               
                              

         






                                                       

         

                      
 


                                                   

 

                                                        
                                          




                                                                             
                                                           
                                         
                                                    
                                   
                                                                     
                                               

                                                       
                                 
                                              














                                                                     

                           
                           
                                                                     
                                       

                                               




                                                        

                                               

                                      

                                                   



                   
                                    
                           

 
                                             


                                                                                  
                                                                               






                                                                          



                                                                                  
         
                         


                        
                        




                                             



                                                             




                                                    
                             

                                                                        
                

                                                      
         
                                                              

                                          


                                    
                           
 
package widgets

import (
	"bytes"
	"fmt"
	"io"
	"os/exec"
	"strings"

	"github.com/danwakefield/fnmatch"
	"github.com/emersion/go-imap"
	"github.com/emersion/go-message"
	_ "github.com/emersion/go-message/charset"
	"github.com/emersion/go-message/mail"
	"github.com/gdamore/tcell"
	"github.com/google/shlex"
	"github.com/mattn/go-runewidth"

	"git.sr.ht/~sircmpwn/aerc/config"
	"git.sr.ht/~sircmpwn/aerc/lib"
	"git.sr.ht/~sircmpwn/aerc/lib/ui"
	"git.sr.ht/~sircmpwn/aerc/worker/types"
)

type MessageViewer struct {
	ui.Invalidatable
	conf     *config.AercConfig
	err      error
	grid     *ui.Grid
	msg      *types.MessageInfo
	switcher *PartSwitcher
	store    *lib.MessageStore
}

type PartSwitcher struct {
	ui.Invalidatable
	parts    []*PartViewer
	selected int
}

func formatAddresses(addrs []*imap.Address) string {
	val := bytes.Buffer{}
	for i, addr := range addrs {
		if addr.PersonalName != "" {
			val.WriteString(fmt.Sprintf("%s <%s@%s>",
				addr.PersonalName, addr.MailboxName, addr.HostName))
		} else {
			val.WriteString(fmt.Sprintf("%s@%s",
				addr.MailboxName, addr.HostName))
		}
		if i != len(addrs)-1 {
			val.WriteString(", ")
		}
	}
	return val.String()
}

func NewMessageViewer(conf *config.AercConfig,
	store *lib.MessageStore, msg *types.MessageInfo) *MessageViewer {

	grid := ui.NewGrid().Rows([]ui.GridSpec{
		{ui.SIZE_EXACT, 3}, // TODO: Based on number of header rows
		{ui.SIZE_WEIGHT, 1},
	}).Columns([]ui.GridSpec{
		{ui.SIZE_WEIGHT, 1},
	})

	// TODO: let user specify additional headers to show by default
	headers := ui.NewGrid().Rows([]ui.GridSpec{
		{ui.SIZE_EXACT, 1},
		{ui.SIZE_EXACT, 1},
		{ui.SIZE_EXACT, 1},
	}).Columns([]ui.GridSpec{
		{ui.SIZE_WEIGHT, 1},
		{ui.SIZE_WEIGHT, 1},
	})
	headers.AddChild(
		&HeaderView{
			Name:  "From",
			Value: formatAddresses(msg.Envelope.From),
		}).At(0, 0)
	headers.AddChild(
		&HeaderView{
			Name:  "To",
			Value: formatAddresses(msg.Envelope.To),
		}).At(0, 1)
	headers.AddChild(
		&HeaderView{
			Name:  "Subject",
			Value: msg.Envelope.Subject,
		}).At(1, 0).Span(1, 2)
	headers.AddChild(ui.NewFill(' ')).At(2, 0).Span(1, 2)

	body := ui.NewGrid().Rows([]ui.GridSpec{
		{ui.SIZE_WEIGHT, 1},
	}).Columns([]ui.GridSpec{
		{ui.SIZE_WEIGHT, 1},
		{ui.SIZE_EXACT, 20},
	})

	var (
		err error
		mv  *MessageViewer
	)

	switcher := &PartSwitcher{}
	if len(msg.BodyStructure.Parts) == 0 {
		pv, err := NewPartViewer(conf, store, msg, msg.BodyStructure, []int{1})
		if err != nil {
			goto handle_error
		}
		switcher.parts = []*PartViewer{pv}
		pv.OnInvalidate(func(_ ui.Drawable) {
			switcher.Invalidate()
		})
	} else {
		switcher.parts, err = enumerateParts(conf, store,
			msg, msg.BodyStructure, []int{})
		if err != nil {
			goto handle_error
		}
		switcher.selected = -1
		for i, pv := range switcher.parts {
			pv.OnInvalidate(func(_ ui.Drawable) {
				switcher.Invalidate()
			})
			// TODO: switch to user's preferred mimetype, if configured
			if switcher.selected == -1 && pv.part.MIMEType != "multipart" {
				switcher.selected = i
			}
		}
	}

	grid.AddChild(headers).At(0, 0)
	grid.AddChild(body).At(1, 0)

	mv = &MessageViewer{
		grid:     grid,
		msg:      msg,
		store:    store,
		switcher: switcher,
	}

	body.AddChild(mv.switcher).At(0, 0).Span(1, 2)
	return mv

handle_error:
	return &MessageViewer{
		err:  err,
		grid: grid,
		msg:  msg,
	}
}

func enumerateParts(conf *config.AercConfig, store *lib.MessageStore,
	msg *types.MessageInfo, body *imap.BodyStructure,
	index []int) ([]*PartViewer, error) {

	var parts []*PartViewer
	for i, part := range body.Parts {
		curindex := append(index, i+1)
		if part.MIMEType == "multipart" {
			// Multipart meta-parts are faked
			pv := &PartViewer{part: part}
			parts = append(parts, pv)
			subParts, err := enumerateParts(
				conf, store, msg, part, curindex)
			if err != nil {
				return nil, err
			}
			parts = append(parts, subParts...)
			continue
		}
		pv, err := NewPartViewer(conf, store, msg, part, curindex)
		if err != nil {
			return nil, err
		}
		parts = append(parts, pv)
	}
	return parts, nil
}

func (mv *MessageViewer) Draw(ctx *ui.Context) {
	if mv.err != nil {
		ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
		ctx.Printf(0, 0, tcell.StyleDefault, "%s", mv.err.Error())
		return
	}
	mv.grid.Draw(ctx)
}

func (mv *MessageViewer) Invalidate() {
	mv.grid.Invalidate()
}

func (mv *MessageViewer) OnInvalidate(fn func(d ui.Drawable)) {
	mv.grid.OnInvalidate(func(_ ui.Drawable) {
		fn(mv)
	})
}

func (mv *MessageViewer) CurrentPart() *PartInfo {
	switcher := mv.switcher
	part := switcher.parts[switcher.selected]

	return &PartInfo{
		Index: part.index,
		Msg:   part.msg,
		Part:  part.part,
		Store: part.store,
	}
}

func (mv *MessageViewer) PreviousPart() {
	switcher := mv.switcher
	for {
		switcher.selected--
		if switcher.selected < 0 {
			switcher.selected = len(switcher.parts) - 1
		}
		if switcher.parts[switcher.selected].part.MIMEType != "multipart" {
			break
		}
	}
	mv.Invalidate()
}

func (mv *MessageViewer) NextPart() {
	switcher := mv.switcher
	for {
		switcher.selected++
		if switcher.selected >= len(switcher.parts) {
			switcher.selected = 0
		}
		if switcher.parts[switcher.selected].part.MIMEType != "multipart" {
			break
		}
	}
	mv.Invalidate()
}

func (ps *PartSwitcher) Invalidate() {
	ps.DoInvalidate(ps)
}

func (ps *PartSwitcher) Focus(focus bool) {
	if ps.parts[ps.selected].term != nil {
		ps.parts[ps.selected].term.Focus(focus)
	}
}

func (ps *PartSwitcher) Event(event tcell.Event) bool {
	if ps.parts[ps.selected].term != nil {
		return ps.parts[ps.selected].term.Event(event)
	}
	return false
}

func (ps *PartSwitcher) Draw(ctx *ui.Context) {
	height := len(ps.parts)
	if height == 1 {
		ps.parts[ps.selected].Draw(ctx)
		return
	}
	// TODO: cap height and add scrolling for messages with many parts
	y := ctx.Height() - height
	for i, part := range ps.parts {
		style := tcell.StyleDefault.Reverse(ps.selected == i)
		ctx.Fill(0, y+i, ctx.Width(), 1, ' ', style)
		name := fmt.Sprintf("%s/%s",
			strings.ToLower(part.part.MIMEType),
			strings.ToLower(part.part.MIMESubType))
		if filename, ok := part.part.DispositionParams["filename"]; ok {
			name += fmt.Sprintf(" (%s)", filename)
		}
		ctx.Printf(len(part.index)*2, y+i, style, "%s", name)
	}
	ps.parts[ps.selected].Draw(ctx.Subcontext(
		0, 0, ctx.Width(), ctx.Height()-height))
}

func (mv *MessageViewer) Event(event tcell.Event) bool {
	return mv.switcher.Event(event)
}

func (mv *MessageViewer) Focus(focus bool) {
	mv.switcher.Focus(focus)
}

type PartViewer struct {
	ui.Invalidatable
	err     error
	fetched bool
	filter  *exec.Cmd
	index   []int
	msg     *types.MessageInfo
	pager   *exec.Cmd
	pagerin io.WriteCloser
	part    *imap.BodyStructure
	sink    io.WriteCloser
	source  io.Reader
	store   *lib.MessageStore
	term    *Terminal
}

type PartInfo struct {
	Index []int
	Msg   *types.MessageInfo
	Part  *imap.BodyStructure
	Store *lib.MessageStore
}

func NewPartViewer(conf *config.AercConfig,
	store *lib.MessageStore, msg *types.MessageInfo,
	part *imap.BodyStructure, index []int) (*PartViewer, error) {

	var (
		filter  *exec.Cmd
		pager   *exec.Cmd
		pipe    io.WriteCloser
		pagerin io.WriteCloser
		term    *Terminal
	)
	cmd, err := shlex.Split(conf.Viewer.Pager)
	if err != nil {
		return nil, err
	}

	pager = exec.Command(cmd[0], cmd[1:]...)

	for _, f := range conf.Filters {
		mime := strings.ToLower(part.MIMEType) +
			"/" + strings.ToLower(part.MIMESubType)
		switch f.FilterType {
		case config.FILTER_MIMETYPE:
			if fnmatch.Match(f.Filter, mime, 0) {
				filter = exec.Command("sh", "-c", f.Command)
			}
		case config.FILTER_HEADER:
			var header string
			switch f.Header {
			case "subject":
				header = msg.Envelope.Subject
			case "from":
				header = formatAddresses(msg.Envelope.From)
			case "to":
				header = formatAddresses(msg.Envelope.To)
			case "cc":
				header = formatAddresses(msg.Envelope.Cc)
			}
			if f.Regex.Match([]byte(header)) {
				filter = exec.Command("sh", "-c", f.Command)
			}
		}
		if filter != nil {
			break
		}
	}
	if filter != nil {
		if pipe, err = filter.StdinPipe(); err != nil {
			return nil, err
		}
		if pagerin, _ = pager.StdinPipe(); err != nil {
			return nil, err
		}
		if term, err = NewTerminal(pager); err != nil {
			return nil, err
		}
	}

	pv := &PartViewer{
		filter:  filter,
		index:   index,
		msg:     msg,
		pager:   pager,
		pagerin: pagerin,
		part:    part,
		sink:    pipe,
		store:   store,
		term:    term,
	}

	if term != nil {
		term.OnStart = func() {
			pv.attemptCopy()
		}
		term.OnInvalidate(func(_ ui.Drawable) {
			pv.Invalidate()
		})
	}

	return pv, nil
}

func (pv *PartViewer) SetSource(reader io.Reader) {
	pv.source = reader
	pv.attemptCopy()
}

func (pv *PartViewer) attemptCopy() {
	if pv.source != nil && pv.pager.Process != nil {
		header := message.Header{}
		header.SetText("Content-Transfer-Encoding", pv.part.Encoding)
		header.SetContentType(pv.part.MIMEType, pv.part.Params)
		header.SetText("Content-Description", pv.part.Description)
		if pv.filter != nil {
			stdout, _ := pv.filter.StdoutPipe()
			stderr, _ := pv.filter.StderrPipe()
			pv.filter.Start()
			ch := make(chan interface{})
			go func() {
				_, err := io.Copy(pv.pagerin, stdout)
				if err != nil {
					pv.err = err
					pv.Invalidate()
				}
				stdout.Close()
				ch <- nil
			}()
			go func() {
				_, err := io.Copy(pv.pagerin, stderr)
				if err != nil {
					pv.err = err
					pv.Invalidate()
				}
				stderr.Close()
				ch <- nil
			}()
			go func() {
				<-ch
				<-ch
				pv.pagerin.Close()
			}()
		}
		go func() {
			entity, err := message.New(header, pv.source)
			if err != nil {
				pv.err = err
				pv.Invalidate()
				return
			}
			reader := mail.NewReader(entity)
			part, err := reader.NextPart()
			if err != nil {
				pv.err = err
				pv.Invalidate()
				return
			}
			io.Copy(pv.sink, part.Body)
			pv.sink.Close()
		}()
	}
}

func (pv *PartViewer) Invalidate() {
	pv.DoInvalidate(pv)
}

func (pv *PartViewer) Draw(ctx *ui.Context) {
	if pv.filter == nil {
		// TODO: Let them download it directly or something
		ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
		ctx.Printf(0, 0, tcell.StyleDefault.Foreground(tcell.ColorRed),
			"No filter configured for this mimetype")
		return
	}
	if !pv.fetched {
		pv.store.FetchBodyPart(pv.msg.Uid, pv.index, pv.SetSource)
		pv.fetched = true
	}
	if pv.err != nil {
		ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
		ctx.Printf(0, 0, tcell.StyleDefault, "%s", pv.err.Error())
		return
	}
	pv.term.Draw(ctx)
}

type HeaderView struct {
	ui.Invalidatable
	Name  string
	Value string
}

func (hv *HeaderView) Draw(ctx *ui.Context) {
	name := hv.Name
	size := runewidth.StringWidth(name)
	lim := ctx.Width() - size - 1
	value := runewidth.Truncate(" "+hv.Value, lim, "…")
	var (
		hstyle tcell.Style
		vstyle tcell.Style
	)
	// TODO: Make this more robust and less dumb
	if hv.Name == "PGP" {
		vstyle = tcell.StyleDefault.Foreground(tcell.ColorGreen)
		hstyle = tcell.StyleDefault.Bold(true)
	} else {
		vstyle = tcell.StyleDefault
		hstyle = tcell.StyleDefault.Bold(true)
	}
	ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', vstyle)
	ctx.Printf(0, 0, hstyle, name)
	ctx.Printf(size, 0, vstyle, value)
}

func (hv *HeaderView) Invalidate() {
	hv.DoInvalidate(hv)
}