about summary refs log blame commit diff stats
path: root/src/plugins/themes.h
blob: 4feb9f2e34ec456f475bcaf2fc2ab6fe6657afbe (plain) (tree)
1
2
3
4
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * themes.h
 *
 * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
 *
 * This file is part of Profanity.
 *
 * Profanity is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Profanity is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Profanity.  If not, see <https://www.gnu.org/licenses/>.
 *
 * In addition, as a special exception, the copyright holders give permission to
 * link the code of portions of this program with the OpenSSL library under
 * certain conditions as described in each individual source file, and
 * distribute linked combinations including the two.
 *
 * You must obey the GNU General Public License in all respects for all of the
 * code used other than OpenSSL. If you modify file(s) with this exception, you
 * may extend this exception to your version of the file(s), but you are not
 * obligated to do so. If you do not wish to do so, delete this exception
 * statement from your version. If you delete this exception statement from all
 * source files in the program, then also delete it here.
 *
 */

#ifndef PLUGINS_THEMES_H
#define PLUGINS_THEMES_H

void plugin_themes_init(void);
void plugin_themes_close(void);
theme_item_t plugin_themes_get(const char *const group, const char *const key, const char *const def);

#endif
span class="w"> *widgets.Terminal: return []*commands.Commands{ terminal.TerminalCommands, commands.GlobalCommands, } default: return []*commands.Commands{commands.GlobalCommands} } } func execCommand(aerc *widgets.Aerc, ui *libui.UI, 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 } continue } else if _, ok := err.(commands.ErrorExit); ok { ui.Exit() return nil } else if err != nil { return err } else { break } } return nil } func getCompletions(aerc *widgets.Aerc, cmd string) []string { var completions []string for _, set := range getCommands((*aerc).SelectedTab()) { completions = append(completions, set.GetCompletions(aerc, cmd)...) } completions = append(completions, cmd) return completions } var ( ShareDir string Version string ) func usage() { log.Fatal("Usage: aerc [-v] [mailto:...]") } func main() { opts, optind, err := getopt.Getopts(os.Args, "v") if err != nil { log.Print(err) usage() return } for _, opt := range opts { switch opt.Option { case 'v': fmt.Println("aerc " + Version) return } } initDone := make(chan struct{}) args := os.Args[optind:] if len(args) > 1 { usage() return } else if len(args) == 1 { arg := args[0] err := lib.ConnectAndExec(arg) if err == nil { return // other aerc instance takes over } fmt.Fprintf(os.Stderr, "Failed to communicate to aerc: %v", err) // continue with setting up a new aerc instance and retry after init go func(msg string) { <-initDone err := lib.ConnectAndExec(msg) if err != nil { fmt.Fprintf(os.Stderr, "Failed to communicate to aerc: %v", err) } }(arg) } var ( logOut io.Writer logger *log.Logger ) if !isatty.IsTerminal(os.Stdout.Fd()) { logOut = os.Stdout } else { logOut = ioutil.Discard os.Stdout, _ = os.Open(os.DevNull) } logger = log.New(logOut, "", log.LstdFlags) logger.Println("Starting up aerc") conf, err := config.LoadConfigFromFile(nil, ShareDir) if err != nil { fmt.Fprintf(os.Stderr, "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 { return execCommand(aerc, ui, cmd) }, func(cmd string) []string { return getCompletions(aerc, cmd) }, &commands.CmdHistory) ui, err = libui.Initialize(aerc) if err != nil { panic(err) } defer ui.Close() if conf.Ui.MouseEnabled { ui.EnableMouse() } logger.Println("Starting Unix server") as, err := lib.StartServer(logger) if err != nil { logger.Printf("Failed to start Unix server: %v (non-fatal)", err) } else { defer as.Close() as.OnMailto = aerc.Mailto } close(initDone) for !ui.ShouldExit() { for aerc.Tick() { // Continue updating our internal state } if !ui.Tick() { // ~60 FPS time.Sleep(16 * time.Millisecond) } } aerc.CloseBackends() }