mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
Favicons work
This commit is contained in:
parent
992a824502
commit
e34644be6f
@ -9,6 +9,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/makeworld-the-better-one/amfora/cache"
|
"github.com/makeworld-the-better-one/amfora/cache"
|
||||||
@ -95,7 +96,8 @@ func handleFavicon(t *tab, host, old string) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
// Update display if needed
|
// Update display if needed
|
||||||
if t.page.Favicon != old && isValidTab(t) {
|
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 != "" {
|
if fav != "" {
|
||||||
t.page.Favicon = fav
|
t.page.Favicon = fav
|
||||||
// TODO update browser tab label
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,18 @@ import (
|
|||||||
|
|
||||||
// This file contains funcs that are small, self-contained utilities.
|
// 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.
|
// escapeMeta santizes a META string for use within a cview modal.
|
||||||
func escapeMeta(meta string) string {
|
func escapeMeta(meta string) string {
|
||||||
return cview.Escape(strings.ReplaceAll(meta, "\n", ""))
|
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.
|
// isValidTab indicates whether the passed tab is still being used, even if it's not currently displayed.
|
||||||
func isValidTab(t *tab) bool {
|
func isValidTab(t *tab) bool {
|
||||||
tempTabs := tabs
|
return tabNumber(t) != -1
|
||||||
for i := range tempTabs {
|
|
||||||
if tempTabs[i] == t {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func leftMargin() int {
|
func leftMargin() int {
|
||||||
|
Loading…
Reference in New Issue
Block a user