package main
import (
"bufio"
"bytes"
"encoding/hex"
"fmt"
"io"
"os"
"os/exec"
"reflect"
"regexp"
"sort"
"strconv"
"strings"
log "github.com/Sirupsen/logrus"
slice "github.com/bradfitz/slice"
)
const (
cfDefaultConfigHomeDir = "/.config"
cfGrvConfigDir = "/grv"
cfGrvrcFile = "/grvrc"
cfTabWidthMinValue = 1
cfTabWidthDefaultValue = 8
cfClassicThemeName = "classic"
cfColdThemeName = "cold"
cfSolarizedThemeName = "solarized"
cfMouseDefaultValue = false
cfMouseScrollRowsDefaultValue = 3
cfCommitGraphDefaultValue = false
cfConfirmCheckoutDefaultValue = true
cfPromptHistorySizeDefaultValue = 1000
cfAllView = "All"
cfMainView = "MainView"
cfHistoryView = "HistoryView"
cfStatusView = "StatusView"
cfGRVStatusView = "GRVStatusView"
cfRefView = "RefView"
cfCommitView = "CommitView"
cfDiffView = "DiffView"
cfStatusBarView = "StatusBarView"
cfHelpBarView = "HelpBarView"
cfErrorView = "ErrorView"
cfGitStatusView = "GitStatusView"
cfContextMenuView = "ContextMenuView"
cfCommandOutputView = "CommandOutputView"
cfHelpView = "HelpView"
)
// ConfigVariable stores a config variable name
type ConfigVariable string
const (
// CfTabWidth stores the tab width variable name
CfTabWidth ConfigVariable = "tabwidth"
// CfTheme stores the theme variable name
CfTheme ConfigVariable = "theme"
// CfMouse stores whether mouse support is enabled
CfMouse ConfigVariable = "mouse"
// CfMouseScrollRows stores the number of rows a view will scroll when a scroll mouse event is received
CfMouseScrollRows ConfigVariable = "mouse-scroll-rows"
// CfCommitGraph stores whether the commit graph is visible or not
CfCommitGraph ConfigVariable = "commit-graph"
// CfConfirmCheckout stores whether checkouts should be confirmed
CfConfirmCheckout ConfigVariable = "confirm-checkout"
// CfPromptHistorySize stores the maximum number of prompt entries retained
CfPromptHistorySize ConfigVariable = "prompt-history-size"
)
var systemColorValues = map[string]SystemColorValue{
"None": ColorNone,
"Black": ColorBlack,
"Red": ColorRed,
"Green": ColorGreen,
"Yellow": ColorYellow,
"Blue": ColorBlue,
"Magenta": ColorMagenta,
"Cyan": ColorCyan,
"White": ColorWhite,
}
var viewIDNames = map[string]ViewID{
cfAllView: ViewAll,
cfMainView: ViewMain,
cfHistoryView: ViewHistory,
cfStatusView: ViewStatus,
cfGRVStatusView: ViewGRVStatus,
cfRefView: ViewRef,
cfCommitView: ViewCommit,
cfDiffView: ViewDiff,
cfStatusBarView: ViewStatusBar,
cfHelpBarView: ViewHelpBar,
cfErrorView: ViewError,
cfGitStatusView: ViewGitStatus,
cfContextMenuView: ViewContextMenu,
cfCommandOutputView: ViewCommandOutput,
cfHelpView: ViewHelp,
}
var themeComponents = map[string]ThemeComponentID{
cfAllView + ".Default": CmpAllviewDefault,
cfAllView + ".SearchMatch": CmpAllviewSearchMatch,
cfAllView + ".ActiveViewSelectedRow": CmpAllviewActiveViewSelectedRow,
cfAllView + ".InactiveViewSelectedRow": CmpAllviewInactiveViewSelectedRow,
cfMainView + ".ActiveView": CmpMainviewActiveView,
cfMainView + ".NormalView": CmpMainviewNormalView,
cfRefView + ".Title": CmpRefviewTitle,
cfRefView + ".Footer": CmpRefviewFooter,
cfRefView + ".LocalBranchesHeader": CmpRefviewLocalBranchesHeader,
cfRefView + ".RemoteBranchesHeader": CmpRefviewRemoteBranchesHeader,
cfRefView + ".LocalBranch": CmpRefviewLocalBranch,
cfRefView + ".Head": CmpRefviewHead,
cfRefView + ".RemoteBranch": CmpRefviewRemoteBranch,
cfRefView + ".TagsHeader": CmpRefviewTagsHeader,
cfRefView + ".Tag": CmpRefviewTag,
cfCommitView + ".Title": CmpCommitviewTitle,
cfCommitView + ".Footer": CmpCommitviewFooter,
cfCommitView + ".ShortOid": CmpCommitviewShortOid,
cfCommitView + ".Date": CmpCommitviewDate,
cfCommitView + ".Author": CmpCommitviewAuthor,
cfCommitView + ".Summary": CmpCommitviewSummary,
cfCommitView + ".Tag": CmpCommitviewTag,
cfCommitView + ".LocalBranch": CmpCommitviewLocalBranch,
cfCommitView + ".RemoteBranch": CmpCommitviewRemoteBranch,
cfDiffView + ".Title": CmpDiffviewTitle