1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-12-04 14:46:29 -05:00

Favicons work

This commit is contained in:
makeworld 2020-12-27 20:13:13 -05:00
parent 992a824502
commit e34644be6f
2 changed files with 16 additions and 9 deletions

View File

@ -9,6 +9,7 @@ import (
"net/url"
"os/exec"
"path"
"strconv"
"strings"
"github.com/makeworld-the-better-one/amfora/cache"
@ -95,7 +96,8 @@ func handleFavicon(t *tab, host, old string) {
defer func() {
// Update display if needed
if t.page.Favicon != old && isValidTab(t) {
// TODO update browser tab label
browser.SetTabLabel(strconv.Itoa(tabNumber(t)), t.page.Favicon)
App.Draw()
}
}()
@ -117,7 +119,6 @@ func handleFavicon(t *tab, host, old string) {
}
if fav != "" {
t.page.Favicon = fav
// TODO update browser tab label
return
}

View File

@ -13,6 +13,18 @@ import (
// This file contains funcs that are small, self-contained utilities.
// tabNumber gets the index of the tab in the tabs slice. It returns -1
// if the tab is not in that slice.
func tabNumber(t *tab) int {
tempTabs := tabs
for i := range tempTabs {
if tempTabs[i] == t {
return i
}
}
return -1
}
// escapeMeta santizes a META string for use within a cview modal.
func escapeMeta(meta string) string {
return cview.Escape(strings.ReplaceAll(meta, "\n", ""))
@ -20,13 +32,7 @@ func escapeMeta(meta string) string {
// isValidTab indicates whether the passed tab is still being used, even if it's not currently displayed.
func isValidTab(t *tab) bool {
tempTabs := tabs
for i := range tempTabs {
if tempTabs[i] == t {
return true
}
}
return false
return tabNumber(t) != -1
}
func leftMargin() int {