about summary refs log tree commit diff stats
path: root/html/lambda-to-mu.mu.html
Commit message (Collapse)AuthorAgeFilesLines
* 4134 - 'input' = 'ingredient'Kartik K. Agaram2017-12-031-18/+18
|
* 4122Kartik K. Agaram2017-11-151-3/+3
|
* 4008Kartik K. Agaram2017-09-251-3/+3
| | | | | Allow list `push` operation to save result in a new list rather than mutate the existing list.
* 4003Kartik K. Agaram2017-09-231-11/+11
|
* 3901Kartik K. Agaram2017-06-091-6/+6
|
* 3837Kartik K. Agaram2017-04-191-6/+6
|
* 3831Kartik K. Agaram2017-04-181-5/+5
| | | | Fix CI.
* 3830 - crosslink shape-shifting containers in htmlKartik K. Agaram2017-04-181-8/+8
|
* 3829Kartik K. Agaram2017-04-181-11/+11
|
* 3820Kartik K. Agaram2017-04-131-11/+11
|
* 3764 - better colors for cross-linksKartik K. Agaram2017-03-081-3/+4
|
* 3761Kartik K. Agaram2017-03-071-171/+172
|
* 3725Kartik K. Agaram2016-12-271-131/+131
| | | | | | More improvements to cross-linking example programs. Include their own functions as well in the tags for each program, even as you share the core .mu files everywhere.
* 3716Kartik K. Agaram2016-12-261-0/+2
| | | | Make hyperlinks less salient in the rendered html since there's so many of them.
* 3713 - cross-link calls with definitions in htmlKartik K. Agaram2016-12-261-52/+52
|
* 3710Kartik K. Agaram2016-12-261-590/+590
| | | | | Turns out we don't need to explicitly add anchors for each line. Vim's TOhtml has magic for that out of the box.
* 3709 - line numbers in htmlKartik K. Agaram2016-12-261-594/+618
| | | | | | Each line number also gets an anchor name, but I'm not hyperlinking them for now because I don't want to encourage bookmarking these links just yet. They aren't permalinks because every revision may change what's at any given line number.
* 3688Kartik K. Agaram2016-11-251-2/+8
| | | | | | | Move my todos over the past couple of years into the codebase now that it might be going dormant. Surprising how few todos left undone!
* 3681Kartik K. Agaram2016-11-221-18/+18
| | | | Couple of fixes to example programs.
* 3667Kartik K. Agaram2016-11-111-11/+11
|
* 3569Kartik K. Agaram2016-10-231-266/+266
| | | | Update syntax highlighting to not color numeric locations like literals.
* 3568Kartik K. Agaram2016-10-231-8/+8
| | | | Fix syntax highlighting for labels after commit 3552.
* 3561Kartik K. Agaram2016-10-221-2/+2
|
* 3558Kartik K. Agaram2016-10-221-1/+1
|
* 3543Kartik K. Agaram2016-10-221-3/+3
|
* 3491Kartik K. Agaram2016-10-091-60/+60
| | | | | Update the html, proving that commit 3490 worked. The only changes are from other recent commits.
* 3431Kartik K. Agaram2016-09-301-9/+9
| | | | | Improvements to syntax highlighting, particularly for Mu code in C++ files.
* 3401Kartik K. Agaram2016-09-181-0/+624
|
* 3355Kartik K. Agaram2016-09-151-623/+0
|
* 3174Kartik K. Agaram2016-08-121-0/+18
|
* 3158Kartik K. Agaram2016-07-271-0/+605
> ^
72e4b5e ^
8635c70 ^
a073d76 ^
8fa4583 ^

661e3ec ^



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
               

        
                                  
 
                                      
                                         

 
                    
                        


                                             
                               
                                 

 
                                                      

                                              
 
                                                                         
                          


                                         
                                        
                                   
         



                                                

 
                                
                           

 
                                         
                          

 
                                     
                             

 



                                                 
                                    
                                                
                                             






                                                          
                                                  
                                             
                                             
                                   

                                                    



                   
package widgets

import (
	"github.com/gdamore/tcell"

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

type ExLine struct {
	ui.Invalidatable
	cancel      func()
	commit      func(cmd string)
	tabcomplete func(cmd string) []string
	cmdHistory  lib.History
	input       *ui.TextInput
}

func NewExLine(commit func(cmd string), cancel func(),
	tabcomplete func(cmd string) []string,
	cmdHistory lib.History) *ExLine {

	input := ui.NewTextInput("").Prompt(":").TabComplete(tabcomplete)
	exline := &ExLine{
		cancel:      cancel,
		commit:      commit,
		tabcomplete: tabcomplete,
		cmdHistory:  cmdHistory,
		input:       input,
	}
	input.OnInvalidate(func(d ui.Drawable) {
		exline.Invalidate()
	})
	return exline
}

func (ex *ExLine) Invalidate() {
	ex.DoInvalidate(ex)
}

func (ex *ExLine) Draw(ctx *ui.Context) {
	ex.input.Draw(ctx)
}

func (ex *ExLine) Focus(focus bool) {
	ex.input.Focus(focus)
}

func (ex *ExLine) Event(event tcell.Event) bool {
	switch event := event.(type) {
	case *tcell.EventKey:
		switch event.Key() {
		case tcell.KeyEnter:
			cmd := ex.input.String()
			ex.input.Focus(false)
			ex.commit(cmd)
		case tcell.KeyUp:
			ex.input.Set(ex.cmdHistory.Prev())
			ex.Invalidate()
		case tcell.KeyDown:
			ex.input.Set(ex.cmdHistory.Next())
			ex.Invalidate()
		case tcell.KeyEsc, tcell.KeyCtrlC:
			ex.input.Focus(false)
			ex.cmdHistory.Reset()
			ex.cancel()
		default:
			return ex.input.Event(event)
		}
	}
	return true
}