mirror of
https://github.com/makeworld-the-better-one/amfora.git
synced 2024-11-22 07:23:05 +03:00
🐛 Add no-color UI elements - fixes #16
This commit is contained in:
parent
4eea75edeb
commit
5056bd303d
@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Mark status code 21 as invalid
|
||||
- Bottom bar is not in focus after clicking Enter
|
||||
- Badly formed links on pages can no longer crash the browser
|
||||
- Disabling color in config affects UI elements (#16)
|
||||
|
||||
|
||||
## [1.0.0] - 2020-06-18
|
||||
|
2
NOTES.md
2
NOTES.md
@ -11,5 +11,5 @@
|
||||
- Modal styling messed up when wrapped - example occurence is the error modal for a long unsupported scheme URL
|
||||
- Filed [issue 26](https://gitlab.com/tslocum/cview/-/issues/26)
|
||||
- Add some bold back into modal text after this is fixed
|
||||
- Bookmark keys aren't deleted, just set to ""
|
||||
- Bookmark keys aren't deleted, just set to `""`
|
||||
- Waiting on [this viper PR](https://github.com/spf13/viper/pull/519) to be merged
|
@ -2,7 +2,7 @@
|
||||
|
||||
<center> <!-- I know, that's not how you usually do it :) -->
|
||||
<img src="logo.png" alt="amphora logo" width="30%">
|
||||
<h6>Modified from: amphora by Alvaro Cabrera from the Noun Project</h6>
|
||||
<h6><em>Modified from: amphora by Alvaro Cabrera from the Noun Project</em></h6>
|
||||
</center>
|
||||
|
||||
|
||||
@ -15,6 +15,8 @@
|
||||
</a>
|
||||
</center>
|
||||
|
||||
###### Recording of v1.0.0
|
||||
|
||||
Amfora aims to be the best looking [Gemini](https://gemini.circumlunar.space/) client with the most features... all in the terminal. It does not support Gopher or other non-Web protocols - check out [Bombadillo](http://bombadillo.colorfield.space/) for that.
|
||||
|
||||
It also aims to be completely cross platform, with full Windows support. If you're on Windows, I would not recommend using the default terminal software. Maybe use [Cmder](https://cmder.net/) instead?
|
||||
@ -35,6 +37,8 @@ update-desktop-database ~/.local/share/applications
|
||||
|
||||
Just call `amfora` or `amfora <url>` on the terminal. On Windows it might be `amfora.exe` instead.
|
||||
|
||||
To determine the version, you can run `amfora --version` or `amfora -v`.
|
||||
|
||||
The project keeps many standard terminal keybindings and is intuitive. Press <kbd>?</kbd> inside the application to pull up the help menu with a list of all the keybindings, and <kbd>Esc</kbd> to leave it. If you have used Bombadillo you will find it similar.
|
||||
|
||||
It is designed with large or fullscreen terminals in mind. For optimal usage, make your terminal fullscreen. It was also designed with a dark background terminal in mind, but please file an issue if the colour choices look bad on your terminal setup. It was tested with left-to-right languages, and will likely not work as well with right-to-left languages like Arabic.
|
||||
|
@ -5,19 +5,16 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/makeworld-the-better-one/amfora/renderer"
|
||||
"github.com/makeworld-the-better-one/amfora/structs"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/makeworld-the-better-one/amfora/bookmarks"
|
||||
"github.com/makeworld-the-better-one/amfora/renderer"
|
||||
"github.com/makeworld-the-better-one/amfora/structs"
|
||||
"github.com/spf13/viper"
|
||||
"gitlab.com/tslocum/cview"
|
||||
)
|
||||
|
||||
// For adding and removing bookmarks, basically a clone of the input modal.
|
||||
var bkmkModal = cview.NewModal().
|
||||
SetBackgroundColor(tcell.ColorTeal).
|
||||
SetButtonBackgroundColor(tcell.ColorNavy).
|
||||
SetButtonTextColor(tcell.ColorWhite).
|
||||
SetTextColor(tcell.ColorWhite)
|
||||
|
||||
// bkmkCh is for the user action
|
||||
@ -25,6 +22,20 @@ var bkmkCh = make(chan int) // 1, 0, -1 for add/update, cancel, and remove
|
||||
var bkmkModalText string // The current text of the input field in the modal
|
||||
|
||||
func bkmkInit() {
|
||||
if viper.GetBool("a-general.color") {
|
||||
bkmkModal.SetBackgroundColor(tcell.ColorTeal).
|
||||
SetButtonBackgroundColor(tcell.ColorNavy).
|
||||
SetButtonTextColor(tcell.ColorWhite)
|
||||
} else {
|
||||
bkmkModal.SetBackgroundColor(tcell.ColorBlack).
|
||||
SetButtonBackgroundColor(tcell.ColorWhite).
|
||||
SetButtonTextColor(tcell.ColorBlack)
|
||||
bkmkModal.GetForm().
|
||||
SetLabelColor(tcell.ColorWhite).
|
||||
SetFieldBackgroundColor(tcell.ColorWhite).
|
||||
SetFieldTextColor(tcell.ColorBlack)
|
||||
}
|
||||
|
||||
bkmkModal.SetBorder(true)
|
||||
bkmkModal.SetBorderColor(tcell.ColorWhite)
|
||||
bkmkModal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
|
||||
|
@ -23,8 +23,7 @@ var termW int
|
||||
// The user input and URL display bar at the bottom
|
||||
var bottomBar = cview.NewInputField().
|
||||
SetFieldBackgroundColor(tcell.ColorWhite).
|
||||
SetFieldTextColor(tcell.ColorBlack).
|
||||
SetLabelColor(tcell.ColorGreen)
|
||||
SetFieldTextColor(tcell.ColorBlack)
|
||||
|
||||
// Viewer for the tab primitives
|
||||
// Pages are named as strings of tab numbers - so the textview for the first tab
|
||||
@ -115,6 +114,11 @@ func Init() {
|
||||
}
|
||||
tabPages.AddPage("help", helpTable, true, false)
|
||||
|
||||
if viper.GetBool("a-general.color") {
|
||||
bottomBar.SetLabelColor(tcell.ColorGreen)
|
||||
} else {
|
||||
bottomBar.SetLabelColor(tcell.ColorBlack)
|
||||
}
|
||||
bottomBar.SetBackgroundColor(tcell.ColorWhite)
|
||||
bottomBar.SetDoneFunc(func(key tcell.Key) {
|
||||
switch key {
|
||||
@ -333,7 +337,11 @@ func NewTab() {
|
||||
|
||||
// Add tab number to the actual place where tabs are show on the screen
|
||||
// Tab regions are 0-indexed but text displayed on the screen starts at 1
|
||||
fmt.Fprintf(tabRow, `["%d"][darkcyan] %d [white][""]|`, curTab, curTab+1)
|
||||
if viper.GetBool("a-general.color") {
|
||||
fmt.Fprintf(tabRow, `["%d"][darkcyan] %d [white][""]|`, curTab, curTab+1)
|
||||
} else {
|
||||
fmt.Fprintf(tabRow, `["%d"] %d [""]|`, curTab, curTab+1)
|
||||
}
|
||||
tabRow.Highlight(strconv.Itoa(curTab)).ScrollToHighlight()
|
||||
|
||||
bottomBar.SetLabel("")
|
||||
@ -376,8 +384,14 @@ func CloseTab() {
|
||||
tabPages.SwitchToPage(strconv.Itoa(curTab)) // Go to previous page
|
||||
// Rewrite the tab display
|
||||
tabRow.Clear()
|
||||
for i := 0; i < NumTabs(); i++ {
|
||||
fmt.Fprintf(tabRow, `["%d"][darkcyan] %d [white][""]|`, i, i+1)
|
||||
if viper.GetBool("a-general.color") {
|
||||
for i := 0; i < NumTabs(); i++ {
|
||||
fmt.Fprintf(tabRow, `["%d"][darkcyan] %d [white][""]|`, i, i+1)
|
||||
}
|
||||
} else {
|
||||
for i := 0; i < NumTabs(); i++ {
|
||||
fmt.Fprintf(tabRow, `["%d"] %d [""]|`, i, i+1)
|
||||
}
|
||||
}
|
||||
tabRow.Highlight(strconv.Itoa(curTab)).ScrollToHighlight()
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/spf13/viper"
|
||||
"gitlab.com/tslocum/cview"
|
||||
)
|
||||
|
||||
@ -13,23 +14,14 @@ import (
|
||||
// The bookmark modal is in bookmarks.go
|
||||
|
||||
var infoModal = cview.NewModal().
|
||||
SetBackgroundColor(tcell.ColorGray).
|
||||
SetButtonBackgroundColor(tcell.ColorNavy).
|
||||
SetButtonTextColor(tcell.ColorWhite).
|
||||
SetTextColor(tcell.ColorWhite).
|
||||
AddButtons([]string{"Ok"})
|
||||
|
||||
var errorModal = cview.NewModal().
|
||||
SetBackgroundColor(tcell.ColorMaroon).
|
||||
SetButtonBackgroundColor(tcell.ColorNavy).
|
||||
SetButtonTextColor(tcell.ColorWhite).
|
||||
SetTextColor(tcell.ColorWhite).
|
||||
AddButtons([]string{"Ok"})
|
||||
|
||||
var inputModal = cview.NewModal().
|
||||
SetBackgroundColor(tcell.ColorGreen).
|
||||
SetButtonBackgroundColor(tcell.ColorNavy).
|
||||
SetButtonTextColor(tcell.ColorWhite).
|
||||
SetTextColor(tcell.ColorWhite).
|
||||
AddButtons([]string{"Send", "Cancel"})
|
||||
|
||||
@ -37,8 +29,6 @@ var inputCh = make(chan string)
|
||||
var inputModalText string // The current text of the input field in the modal
|
||||
|
||||
var yesNoModal = cview.NewModal().
|
||||
SetButtonBackgroundColor(tcell.ColorNavy).
|
||||
SetButtonTextColor(tcell.ColorWhite).
|
||||
SetTextColor(tcell.ColorWhite).
|
||||
AddButtons([]string{"Yes", "No"})
|
||||
|
||||
@ -52,6 +42,39 @@ func modalInit() {
|
||||
AddPage("yesno", yesNoModal, false, false).
|
||||
AddPage("bkmk", bkmkModal, false, false)
|
||||
|
||||
// Color setup
|
||||
if viper.GetBool("a-general.color") {
|
||||
infoModal.SetBackgroundColor(tcell.ColorGray).
|
||||
SetButtonBackgroundColor(tcell.ColorNavy).
|
||||
SetButtonTextColor(tcell.ColorWhite)
|
||||
errorModal.SetBackgroundColor(tcell.ColorMaroon).
|
||||
SetButtonBackgroundColor(tcell.ColorNavy).
|
||||
SetButtonTextColor(tcell.ColorWhite)
|
||||
inputModal.SetBackgroundColor(tcell.ColorGreen).
|
||||
SetButtonBackgroundColor(tcell.ColorNavy).
|
||||
SetButtonTextColor(tcell.ColorWhite)
|
||||
yesNoModal.SetButtonBackgroundColor(tcell.ColorNavy).
|
||||
SetButtonTextColor(tcell.ColorWhite)
|
||||
} else {
|
||||
infoModal.SetBackgroundColor(tcell.ColorBlack).
|
||||
SetButtonBackgroundColor(tcell.ColorWhite).
|
||||
SetButtonTextColor(tcell.ColorBlack)
|
||||
errorModal.SetBackgroundColor(tcell.ColorBlack).
|
||||
SetButtonBackgroundColor(tcell.ColorWhite).
|
||||
SetButtonTextColor(tcell.ColorBlack)
|
||||
inputModal.SetBackgroundColor(tcell.ColorBlack).
|
||||
SetButtonBackgroundColor(tcell.ColorWhite).
|
||||
SetButtonTextColor(tcell.ColorBlack)
|
||||
inputModal.GetForm().
|
||||
SetLabelColor(tcell.ColorWhite).
|
||||
SetFieldBackgroundColor(tcell.ColorWhite).
|
||||
SetFieldTextColor(tcell.ColorBlack)
|
||||
|
||||
// YesNo background color is changed in funcs
|
||||
yesNoModal.SetButtonBackgroundColor(tcell.ColorWhite).
|
||||
SetButtonTextColor(tcell.ColorBlack)
|
||||
}
|
||||
|
||||
// Modal functions that can't be added up above, because they return the wrong type
|
||||
|
||||
infoModal.SetBorder(true)
|
||||
@ -161,7 +184,12 @@ func Input(prompt string) (string, bool) {
|
||||
|
||||
// YesNo displays a modal asking a yes-or-no question.
|
||||
func YesNo(prompt string) bool {
|
||||
yesNoModal.SetText(prompt).SetBackgroundColor(tcell.ColorPurple)
|
||||
if viper.GetBool("a-general.color") {
|
||||
yesNoModal.SetBackgroundColor(tcell.ColorPurple)
|
||||
} else {
|
||||
yesNoModal.SetBackgroundColor(tcell.ColorBlack)
|
||||
}
|
||||
yesNoModal.SetText(prompt)
|
||||
tabPages.ShowPage("yesno")
|
||||
tabPages.SendToFront("yesno")
|
||||
App.SetFocus(yesNoModal)
|
||||
@ -177,9 +205,13 @@ func YesNo(prompt string) bool {
|
||||
func Tofu(host string) bool {
|
||||
// Reuses yesNoModal, with error colour
|
||||
|
||||
yesNoModal.SetBackgroundColor(tcell.ColorMaroon)
|
||||
if viper.GetBool("a-general.color") {
|
||||
yesNoModal.SetBackgroundColor(tcell.ColorMaroon)
|
||||
} else {
|
||||
yesNoModal.SetBackgroundColor(tcell.ColorBlack)
|
||||
}
|
||||
yesNoModal.SetText(
|
||||
fmt.Sprintf("%s's certificate has changed, possibly indicating an security issue. Are you sure you want to continue anyway?", host),
|
||||
fmt.Sprintf("%s's certificate has changed, possibly indicating an security issue. Are you sure you want to continue?", host),
|
||||
)
|
||||
tabPages.ShowPage("yesno")
|
||||
tabPages.SendToFront("yesno")
|
||||
|
Loading…
Reference in New Issue
Block a user