about summary refs log tree commit diff stats
path: root/html/001help.cc.html
Commit message (Expand)AuthorAgeFilesLines
* 4891Kartik Agaram2018-12-301-0/+1
* 4890 - new html renderingsKartik Agaram2018-12-291-17/+12
* 4814Kartik Agaram2018-12-011-54/+58
* 4709Kartik Agaram2018-10-171-8/+8
* 4539Kartik Agaram2018-09-071-11/+10
* 4447Kartik Agaram2018-07-271-27/+25
* 4239Kartik Agaram2018-05-081-13/+13
* 4228Kartik K. Agaram2018-03-151-1/+1
* 4199Kartik K. Agaram2018-01-251-56/+55
* 4161Kartik K. Agaram2017-12-151-11/+11
* 4155Kartik K. Agaram2017-12-071-8/+8
* 4134 - 'input' = 'ingredient'Kartik K. Agaram2017-12-031-42/+43
* 4102Kartik K. Agaram2017-11-011-0/+4
* 4063Kartik K. Agaram2017-10-141-2/+2
* 3971Kartik K. Agaram2017-08-191-2/+2
* 3927Kartik K. Agaram2017-06-191-7/+7
* 3897 - various updates to documentationKartik K. Agaram2017-05-291-214/+217
* 3764 - better colors for cross-linksKartik K. Agaram2017-03-081-4/+5
* 3761Kartik K. Agaram2017-03-071-50/+51
* 3751Kartik K. Agaram2017-03-021-2/+2
* 3750Kartik K. Agaram2017-03-021-8/+8
* 3749Kartik K. Agaram2017-03-021-8/+8
* 3716Kartik K. Agaram2016-12-261-0/+2
* 3713 - cross-link calls with definitions in htmlKartik K. Agaram2016-12-261-24/+24
* 3710Kartik K. Agaram2016-12-261-255/+255
* 3709 - line numbers in htmlKartik K. Agaram2016-12-261-258/+282
* 3707Kartik K. Agaram2016-12-121-1/+1
* 3642Kartik K. Agaram2016-11-061-0/+6
* 3558Kartik K. Agaram2016-10-221-2/+2
* 3544Kartik K. Agaram2016-10-221-1/+1
* 3543Kartik K. Agaram2016-10-221-1/+1
* 3524Kartik K. Agaram2016-10-201-2/+2
* 3416Kartik K. Agaram2016-09-251-1/+4
* 3315Kartik K. Agaram2016-09-101-2/+3
* 3235Kartik K. Agaram2016-08-201-1/+1
* 3174Kartik K. Agaram2016-08-121-25/+45
* 3158Kartik K. Agaram2016-07-271-0/+12
* 3102Kartik K. Agaram2016-07-051-10/+75
* 2996Kartik K. Agaram2016-05-211-5/+8
* 2812Kartik K. Agaram2016-03-271-12/+26
* 2744Kartik K. Agaram2016-03-091-4/+4
* 2743Kartik K. Agaram2016-03-091-35/+27
* 2706 - update htmlKartik K. Agaram2016-02-251-0/+1
* 2611Kartik K. Agaram2015-11-291-0/+10
* 2423 - describe shape-shifting in html docsKartik K. Agaram2015-11-101-53/+84
* 2062Kartik K. Agaram2015-08-231-13/+12
* 1949Kartik K. Agaram2015-08-061-12/+13
* 1925Kartik K. Agaram2015-08-031-1/+1
* 1885Kartik K. Agaram2015-07-291-13/+12
* 1853Kartik K. Agaram2015-07-251-12/+13
plete.h?id=0de1ff9b4de65ddca37186c943abf49a03cf8c30'>^
00170984 ^
6b830277 ^
67dead32 ^
00170984 ^
6b830277 ^
67dead32 ^
00170984 ^
6b830277 ^
89d3b9fc ^
e27061b1 ^
4bd06a5d ^
95c48a0f ^
89d3b9fc ^
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
  
                 
  
                                                            
  












                                                                       
                                                                      
  











                                                                                

   

                            


                 
                                                                
                                            
 
                                           
                                    
 
                                          
                                         

                                            
                                        
 
                                                         
                                                         
                                                        
                                                                  
                                                            

                                                 
                                                                                                          
 
                                                 
                                          
 
                                                                          
                                               
 
                                                                        
                                                        
 
                                                                             
                                                               
 
                                         
 
                                                                   
      
                
                                                

                                                


                                                    
                                            

                                                
                               


                                                  





                                                                    




                       
             



                                  




                                               
                                                   

                                          
                                                     
                       

                                                              
         
 



                                  
                                                                     



                                                                      
                                                     




                                                                         
                                         





                                              
                 
                          

          
                                              


                          
                        
 
                              


                                                               
                               

                                                         
                 
         
 
package main

import (
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"os"
	"time"

	"github.com/mattn/go-isatty"

	"git.sr.ht/~sircmpwn/aerc/commands"
	"git.sr.ht/~sircmpwn/aerc/commands/account"
	"git.sr.ht/~sircmpwn/aerc/commands/compose"
	"git.sr.ht/~sircmpwn/aerc/commands/msg"
	"git.sr.ht/~sircmpwn/aerc/commands/msgview"
	"git.sr.ht/~sircmpwn/aerc/commands/terminal"
	"git.sr.ht/~sircmpwn/aerc/config"
	libui "git.sr.ht/~sircmpwn/aerc/lib/ui"
	"git.sr.ht/~sircmpwn/aerc/widgets"
)

func getCommands(selected libui.Drawable) []*commands.Commands {
	switch selected.(type) {
	case *widgets.AccountView:
		return []*commands.Commands{
			account.AccountCommands,
			msg.MessageCommands,
			commands.GlobalCommands,
		}
	case *widgets.Composer:
		return []*commands.Commands{
			compose.ComposeCommands,
			commands.GlobalCommands,
		}
	case *widgets.MessageViewer:
		return []*commands.Commands{
			msgview.MessageViewCommands,
			msg.MessageCommands,
			commands.GlobalCommands,
		}
	case *widgets.Terminal:
		return []*commands.Commands{
			terminal.TerminalCommands,
			commands.GlobalCommands,
		}
	default:
		return []*commands.Commands{commands.GlobalCommands}
	}
}

var (
	Prefix   string
	ShareDir string
)

func main() {
	var (
		logOut io.Writer
		logger *log.Logger
	)
	if !isatty.IsTerminal(os.Stdout.Fd()) {
		logOut = os.Stdout
	} else {
		logOut = ioutil.Discard
	}
	logger = log.New(logOut, "", log.LstdFlags)
	logger.Println("Starting up aerc")

	conf, err := config.LoadConfig(nil, ShareDir)
	if err != nil {
		fmt.Printf("Failed to load config: %v\n", err)
		os.Exit(1)
	}

	var (
		aerc *widgets.Aerc
		ui   *libui.UI
	)
	aerc = widgets.NewAerc(conf, logger, func(cmd string) error {
		cmds := getCommands(aerc.SelectedTab())
		for i, set := range cmds {
			err := set.ExecuteCommand(aerc, cmd)
			if _, ok := err.(commands.NoSuchCommand); ok {
				if i == len(cmds)-1 {
					return err
				} else {
					continue
				}
			} else if _, ok := err.(commands.ErrorExit); ok {
				ui.Exit()
				return nil
			} else if err != nil {
				return err
			} else {
				break
			}
		}
		return nil
	})

	ui, err = libui.Initialize(conf, aerc)
	if err != nil {
		panic(err)
	}
	defer ui.Close()

	for !ui.ShouldExit() {
		for aerc.Tick() {
			// Continue updating our internal state
		}
		if !ui.Tick() {
			// ~60 FPS
			time.Sleep(16 * time.Millisecond)
		}
	}
}