@ -9,6 +9,23 @@ import (
)
func main ( ) {
config := Config {
Style : StyleConfig {
Background : tcell . ColorDefault ,
Text : tcell . ColorWhite ,
Subtle : tcell . ColorGray ,
WarningText : tcell . NewRGBColor ( 249 , 38 , 114 ) ,
TextSpecial1 : tcell . NewRGBColor ( 174 , 129 , 255 ) ,
TextSpecial2 : tcell . NewRGBColor ( 166 , 226 , 46 ) ,
TopBarBackground : tcell . NewRGBColor ( 249 , 38 , 114 ) ,
TopBarText : tcell . ColorWhite ,
StatusBarBackground : tcell . NewRGBColor ( 249 , 38 , 114 ) ,
StatusBarText : tcell . ColorWhite ,
ListSelectedBackground : tcell . NewRGBColor ( 249 , 38 , 114 ) ,
ListSelectedText : tcell . ColorWhite ,
} ,
}
err := CreateConfigDir ( )
if err != nil {
log . Fatalln ( err )
@ -22,8 +39,31 @@ func main() {
App : tview . NewApplication ( ) ,
API : & API { } ,
HaveAccount : false ,
Config : & config ,
}
clearContent := func ( screen tcell . Screen , x int , y int , width int , height int ) ( int , int , int , int ) {
for cx := x ; cx < width + x ; cx ++ {
for cy := y ; cy < height + y ; cy ++ {
screen . SetContent ( cx , cy , ' ' , nil , tcell . StyleDefault . Background ( app . Config . Style . Background ) )
}
}
y2 := y + height
for cx := x + 1 ; cx < width + x ; cx ++ {
screen . SetContent ( cx , y , tview . BoxDrawingsLightHorizontal , nil , tcell . StyleDefault . Foreground ( app . Config . Style . Subtle ) )
screen . SetContent ( cx , y2 , tview . BoxDrawingsLightHorizontal , nil , tcell . StyleDefault . Foreground ( app . Config . Style . Subtle ) )
}
x2 := x + width
for cy := y + 1 ; cy < height + y ; cy ++ {
screen . SetContent ( x , cy , tview . BoxDrawingsLightVertical , nil , tcell . StyleDefault . Foreground ( app . Config . Style . Subtle ) )
screen . SetContent ( x2 , cy , tview . BoxDrawingsLightVertical , nil , tcell . StyleDefault . Foreground ( app . Config . Style . Subtle ) )
}
screen . SetContent ( x , y , tview . BoxDrawingsLightDownAndRight , nil , tcell . StyleDefault . Foreground ( app . Config . Style . Subtle ) )
screen . SetContent ( x , y + height , tview . BoxDrawingsLightUpAndRight , nil , tcell . StyleDefault . Foreground ( app . Config . Style . Subtle ) )
screen . SetContent ( x + width , y , tview . BoxDrawingsLightDownAndLeft , nil , tcell . StyleDefault . Foreground ( app . Config . Style . Subtle ) )
screen . SetContent ( x + width , y + height , tview . BoxDrawingsLightUpAndLeft , nil , tcell . StyleDefault . Foreground ( app . Config . Style . Subtle ) )
return x + 1 , y + 1 , width - 1 , height - 1
}
if exists {
accounts , err := GetAccounts ( path )
if err != nil {
@ -52,16 +92,17 @@ func main() {
tview . Borders . BottomRightFocus = tview . BoxDrawingsLightUpAndLeft
top := tview . NewTextView ( )
top . SetBackgroundColor ( tcell . ColorGreen )
top . SetBackgroundColor ( app . Config . Style . TopBarBackground )
top . SetTextColor ( app . Config . Style . TopBarText )
app . UI = & UI { app : app , Top : top , Timeline : TimelineHome }
app . UI . TootList = NewTootList ( app , tview . NewList ( ) )
app . UI . TootList . View . SetSelectedTextColor ( tcell . ColorWhite )
app . UI . TootList . View . SetSelectedBackgroundColor ( tcell . ColorRed )
app . UI . TootList . View . SetBackgroundColor ( app . Config . Style . Background )
app . UI . TootList . View . SetSelectedTextColor ( app . Config . Style . ListSelectedText )
app . UI . TootList . View . SetSelectedBackgroundColor ( app . Config . Style . ListSelectedBackground )
app . UI . TootList . View . ShowSecondaryText ( false )
app . UI . TootList . View . SetHighlightFullLine ( true )
app . UI . TootList . View . SetBackgroundColor ( tcell . ColorDefault )
app . UI . TootList . View . SetChangedFunc ( func ( index int , _ string , _ string , _ rune ) {
if app . HaveAccount {
@ -69,36 +110,34 @@ func main() {
}
} )
lo := NewLinkOverlay ( app , tview . NewTextView ( ) ,
NewControls ( app , tview . NewTextView ( ) ) ,
)
lo . View . SetBorderPadding ( 0 , 0 , 0 , 0 )
app . UI . StatusText = NewStatusText ( app , tview . NewTextView ( ) ,
NewControls ( app , tview . NewTextView ( ) ) , lo ,
NewControls ( app , tview . NewTextView ( ) ) , NewLinkOverlay ( app ) ,
)
app . UI . StatusText . View . SetWordWrap ( true ) . SetDynamicColors ( true )
app . UI . StatusText . View . SetBackgroundColor ( tcell . ColorDefault )
app . UI . StatusText . View . SetBackgroundColor ( app . Config . Style . Background )
app . UI . StatusText . View . SetTextColor ( app . Config . Style . Text )
app . UI . StatusText . Controls . View . SetDynamicColors ( true )
app . UI . StatusText . Controls . View . SetBackgroundColor ( tcell . ColorDefault )
app . UI . StatusText . Controls . View . SetBackgroundColor ( app . Config . Style . Background )
app . UI . CmdBar = NewCmdBar ( app ,
tview . NewInputField ( ) ,
)
app . UI . CmdBar . View . SetFieldBackgroundColor ( tcell . ColorDefault )
app . UI . CmdBar . View . SetFieldBackgroundColor ( app . Config . Style . Background )
app . UI . CmdBar . View . SetFieldTextColor ( app . Config . Style . Text )
app . UI . Status = tview . NewTextView ( )
app . UI . Status . SetBackgroundColor ( tcell . ColorBrown )
app . UI . Status . SetBackgroundColor ( app . Config . Style . StatusBarBackground )
app . UI . Status . SetTextColor ( app . Config . Style . StatusBarText )
verticalLine := tview . NewBox ( ) . SetBackgroundColor ( tcell . ColorDefault )
verticalLine := tview . NewBox ( ) . SetBackgroundColor ( app . Config . Style . Background )
verticalLine . SetDrawFunc ( func ( screen tcell . Screen , x int , y int , width int , height int ) ( int , int , int , int ) {
for cy := y ; cy < y + height ; cy ++ {
screen . SetContent ( x , cy , tview . BoxDrawingsLightVertical , nil , tcell . StyleDefault . Foreground ( tcell . ColorGra y ) )
screen . SetContent ( x , cy , tview . BoxDrawingsLightVertical , nil , tcell . StyleDefault . Foreground ( app . Config . St yle . Subtle ) )
}
return 0 , 0 , 0 , 0
} )
app . UI . Pages = tview . NewPages ( )
app . UI . Pages . SetBackgroundColor ( tcell . ColorDefault )
app . UI . Pages . SetBackgroundColor ( app . Config . Style . Background )
app . UI . Pages . AddPage ( "main" ,
tview . NewFlex ( ) .
AddItem ( tview . NewFlex ( ) . SetDirection ( tview . FlexRow ) .
@ -106,7 +145,7 @@ func main() {
AddItem ( tview . NewFlex ( ) . SetDirection ( tview . FlexColumn ) .
AddItem ( app . UI . TootList . View , 0 , 2 , false ) .
AddItem ( verticalLine , 1 , 0 , false ) .
AddItem ( tview . NewBox ( ) . SetBackgroundColor ( tcell . ColorDefault ) , 1 , 0 , false ) .
AddItem ( tview . NewBox ( ) . SetBackgroundColor ( app . Config . Style . Background ) , 1 , 0 , false ) .
AddItem ( tview . NewFlex ( ) . SetDirection ( tview . FlexRow ) .
AddItem ( app . UI . StatusText . View , 0 , 9 , false ) .
AddItem ( app . UI . StatusText . Controls . View , 1 , 0 , false ) ,
@ -146,24 +185,33 @@ func main() {
app . UI . MessageBox = NewMessageBox ( app , tview . NewTextView ( ) ,
NewControls ( app , tview . NewTextView ( ) ) ,
)
//app.UI.MessageBox.View.SetBorder(true).SetTitle("New toot")
app . UI . MessageBox . View . SetBackgroundColor ( tcell . ColorDefault )
app . UI . MessageBox . View . SetBackgroundColor ( app . Config . Style . Background )
app . UI . MessageBox . View . SetTextColor ( app . Config . Style . Text )
app . UI . MessageBox . View . SetDynamicColors ( true )
app . UI . MessageBox . Controls . View . SetDynamicColors ( true )
app . UI . MessageBox . Controls . View . SetBackgroundColor ( tcell . ColorDefault )
app . UI . MessageBox . Controls . View . SetBackgroundColor ( app . Config . Style . Background )
app . UI . MessageBox . Controls . View . SetTextColor ( app . Config . Style . Text )
app . UI . Pages . AddPage ( "toot" ,
modal ( flToot , app . UI . MessageBox . View , app . UI . MessageBox . Controls . View ) , true , false )
//app.UI.StatusText.LinkOverlay.View.SetBorder(true).SetTitle("Follow link")
app . UI . StatusText . LinkOverlay . View . SetBackgroundColor ( tcell . ColorDefault )
app . UI . StatusText . LinkOverlay . View . SetDynamicColors ( true )
app . UI . StatusText . LinkOverlay . Controls . View . SetDynamicColors ( true )
app . UI . StatusText . LinkOverlay . Controls . View . SetBackgroundColor ( tcell . ColorDefault )
links := modal ( flLinks , app . UI . StatusText . LinkOverlay . View , app . UI . StatusText . LinkOverlay . Controls . View )
app . UI . Pages . AddPage ( "links" , tview . NewFlex ( ) . AddItem ( nil , 0 , 1 , false ) .
AddItem ( tview . NewFlex ( ) . SetDirection ( tview . FlexRow ) .
AddItem ( nil , 0 , 1 , false ) .
AddItem ( app . UI . StatusText . LinkOverlay . Flex . SetDirection ( tview . FlexRow ) .
AddItem ( app . UI . StatusText . LinkOverlay . List , 0 , 10 , true ) .
AddItem ( app . UI . StatusText . LinkOverlay . TextBottom , 1 , 1 , true ) , 0 , 8 , false ) .
AddItem ( nil , 0 , 1 , false ) , 0 , 8 , true ) .
AddItem ( nil , 0 , 1 , false ) , true , false )
app . UI . Pages . AddPage ( "links" ,
links , true , false )
app . UI . StatusText . LinkOverlay . Flex . SetDrawFunc ( clearContent )
app . UI . StatusText . LinkOverlay . TextBottom . SetBackgroundColor ( app . Config . Style . Background )
app . UI . StatusText . LinkOverlay . List . SetBackgroundColor ( app . Config . Style . Background )
app . UI . StatusText . LinkOverlay . List . SetMainTextColor ( app . Config . Style . Text )
app . UI . StatusText . LinkOverlay . List . SetSelectedBackgroundColor ( app . Config . Style . ListSelectedBackground )
app . UI . StatusText . LinkOverlay . List . SetSelectedTextColor ( app . Config . Style . ListSelectedText )
app . UI . StatusText . LinkOverlay . List . ShowSecondaryText ( false )
app . UI . StatusText . LinkOverlay . List . SetHighlightFullLine ( true )
app . UI . AuthOverlay = NewAuthoverlay ( app , tview . NewFlex ( ) , tview . NewInputField ( ) ,
NewControls ( app , tview . NewTextView ( ) ) )
@ -171,11 +219,12 @@ func main() {
app . UI . Pages . AddPage ( "login" ,
authModal ( app . UI . AuthOverlay . Flex , app . UI . AuthOverlay . View , app . UI . AuthOverlay . Controls . View ) , true , false )
app . UI . AuthOverlay . Flex . SetDrawFunc ( clearContent )
app . UI . AuthOverlay . Flex . SetBackgroundColor ( tcell . ColorDefault )
app . UI . AuthOverlay . View . SetBackgroundColor ( tcell . ColorDefault )
app . UI . AuthOverlay . View . SetFieldBackgroundColor ( tcell . ColorDefault )
app . UI . AuthOverlay . View . SetFieldTextColor ( tcell . ColorWhite )
app . UI . AuthOverlay . Controls . View . SetBackgroundColor ( tcell . ColorDefault )
app . UI . AuthOverlay . Flex . SetBackgroundColor ( app . Config . Style . Background )
app . UI . AuthOverlay . View . SetBackgroundColor ( app . Config . Style . Background )
app . UI . AuthOverlay . View . SetFieldBackgroundColor ( app . Config . Style . Background )
app . UI . AuthOverlay . View . SetFieldTextColor ( app . Config . Style . Text )
app . UI . AuthOverlay . Controls . View . SetBackgroundColor ( app . Config . Style . Background )
app . UI . AuthOverlay . Controls . View . SetTextColor ( app . Config . Style . Text )
app . UI . AuthOverlay . Draw ( )
app . UI . MediaOverlay = NewMediaView ( app )
@ -183,24 +232,28 @@ func main() {
AddItem ( tview . NewFlex ( ) . SetDirection ( tview . FlexRow ) .
AddItem ( nil , 0 , 1 , false ) .
AddItem ( app . UI . MediaOverlay . Flex . SetDirection ( tview . FlexRow ) .
AddItem ( app . UI . MediaOverlay . TextTop , 0 , 1 , true ) .
AddItem ( app . UI . MediaOverlay . TextTop , 1 , 1 , true ) .
AddItem ( app . UI . MediaOverlay . FileList , 0 , 10 , true ) .
AddItem ( app . UI . MediaOverlay . TextBottom , 0 , 1 , true ) .
AddItem ( app . UI . MediaOverlay . TextBottom , 1 , 1 , true ) .
AddItem ( app . UI . MediaOverlay . InputField . View , 2 , 1 , false ) , 0 , 8 , false ) .
AddItem ( nil , 0 , 1 , false ) , 0 , 8 , true ) .
AddItem ( nil , 0 , 1 , false ) , true , false )
app . UI . MediaOverlay . FileList . SetSelectedTextColor ( tcell . ColorWhite )
app . UI . MediaOverlay . FileList . SetSelectedBackgroundColor ( tcell . ColorRed )
app . UI . MediaOverlay . FileList . SetBackgroundColor ( app . Config . Style . Background )
app . UI . MediaOverlay . FileList . SetMainTextColor ( app . Config . Style . Text )
app . UI . MediaOverlay . FileList . SetSelectedBackgroundColor ( app . Config . Style . ListSelectedBackground )
app . UI . MediaOverlay . FileList . SetSelectedTextColor ( app . Config . Style . ListSelectedText )
app . UI . MediaOverlay . FileList . ShowSecondaryText ( false )
app . UI . MediaOverlay . FileList . SetHighlightFullLine ( true )
app . UI . MediaOverlay . FileList . SetBackgroundColor ( tcell . ColorDefault )
app . UI . MediaOverlay . Flex . SetBackgroundColor ( tcell . ColorDefault )
app . UI . MediaOverlay . TextTop . SetBackgroundColor ( tcell . ColorDefault )
app . UI . MediaOverlay . TextBottom . SetBackgroundColor ( tcell . ColorDefault )
app . UI . MediaOverlay . InputField . View . SetBackgroundColor ( tcell . ColorDefault )
app . UI . MediaOverlay . InputField . View . SetFieldBackgroundColor ( tcell . ColorDefault )
app . UI . MediaOverlay . Flex . SetBackgroundColor ( app . Config . Style . Background )
app . UI . MediaOverlay . TextTop . SetBackgroundColor ( app . Config . Style . Background )
app . UI . MediaOverlay . TextTop . SetTextColor ( app . Config . Style . Text )
app . UI . MediaOverlay . TextBottom . SetBackgroundColor ( app . Config . Style . Background )
app . UI . MediaOverlay . TextBottom . SetTextColor ( app . Config . Style . Text )
app . UI . MediaOverlay . InputField . View . SetBackgroundColor ( app . Config . Style . Background )
app . UI . MediaOverlay . InputField . View . SetFieldBackgroundColor ( app . Config . Style . Background )
app . UI . MediaOverlay . InputField . View . SetFieldTextColor ( app . Config . Style . Text )
app . UI . MediaOverlay . Flex . SetDrawFunc ( clearContent )
if ! app . HaveAccount {
@ -219,55 +272,8 @@ func main() {
}
if app . UI . Focus == LinkOverlayFocus {
if ! app . UI . StatusText . LinkOverlay . Scroll {
if event . Key ( ) == tcell . KeyRune {
switch event . Rune ( ) {
case 't' :
app . UI . StatusText . LinkOverlay . ActivateScroll ( )
default :
app . UI . StatusText . LinkOverlay . AddRune ( event . Rune ( ) )
}
} else {
switch event . Key ( ) {
case tcell . KeyEsc :
if app . UI . StatusText . LinkOverlay . HasInput ( ) {
app . UI . StatusText . LinkOverlay . Clear ( )
} else {
app . UI . SetFocus ( LeftPaneFocus )
app . UI . StatusText . LinkOverlay . DisableScroll ( )
}
return nil
}
}
return nil
} else {
switch event . Key ( ) {
case tcell . KeyEsc :
app . UI . StatusText . LinkOverlay . DisableScroll ( )
return nil
}
}
if event . Key ( ) == tcell . KeyRune {
switch event . Rune ( ) {
case 't' :
app . UI . StatusText . LinkOverlay . DisableScroll ( )
return nil
case 'q' :
app . UI . SetFocus ( LeftPaneFocus )
app . UI . StatusText . LinkOverlay . DisableScroll ( )
return nil
}
} else {
switch event . Key ( ) {
case tcell . KeyEsc :
app . UI . SetFocus ( LeftPaneFocus )
app . UI . StatusText . LinkOverlay . DisableScroll ( )
return nil
}
}
return event
app . UI . StatusText . LinkOverlay . InputHandler ( event )
return nil
}
if app . UI . Focus == CmdBarFocus {
@ -284,22 +290,22 @@ func main() {
if app . UI . Focus == MessageFocus {
if event . Key ( ) == tcell . KeyRune {
switch event . Rune ( ) {
case 'p' :
case 'p' , 'P' :
app . UI . MessageBox . Post ( )
return nil
case 'e' :
case 'e' , 'E' :
app . UI . MessageBox . EditText ( )
return nil
case 'c' :
case 'c' , 'C' :
app . UI . MessageBox . EditSpoiler ( )
return nil
case 't' :
case 't' , 'T' :
app . UI . MessageBox . ToggleSpoiler ( )
return nil
case 'm' :
case 'm' , 'M' :
app . UI . SetFocus ( MessageAttachmentFocus )
return nil
case 'q' :
case 'q' , 'Q' :
app . UI . SetFocus ( LeftPaneFocus )
return nil
}
@ -316,20 +322,24 @@ func main() {
if app . UI . Focus == MessageAttachmentFocus && app . UI . MediaOverlay . Focus == MediaFocusOverview {
if event . Key ( ) == tcell . KeyRune {
switch event . Rune ( ) {
case 'j' :
case 'j' , 'J' :
app . UI . MediaOverlay . Next ( )
case 'k' :
case 'k' , 'K' :
app . UI . MediaOverlay . Prev ( )
case 'd' :
case 'd' , 'D' :
app . UI . MediaOverlay . Delete ( )
case 'a' :
case 'a' , 'A' :
app . UI . MediaOverlay . SetFocus ( MediaFocusAdd )
case 'q' :
case 'q' , 'Q' :
app . UI . SetFocus ( MessageFocus )
return nil
}
} else {
switch event . Key ( ) {
case tcell . KeyUp :
app . UI . MediaOverlay . Prev ( )
case tcell . KeyDown :
app . UI . MediaOverlay . Next ( )
case tcell . KeyEsc :
app . UI . SetFocus ( MessageFocus )
return nil
@ -342,20 +352,19 @@ func main() {
if event . Key ( ) == tcell . KeyRune {
app . UI . MediaOverlay . InputField . AddRune ( event . Rune ( ) )
return nil
} else {
switch event . Key ( ) {
case tcell . KeyTab , tcell . KeyDown :
app . UI . MediaOverlay . InputField . AutocompleteNext ( )
return nil
case tcell . KeyBacktab , tcell . KeyUp :
app . UI . MediaOverlay . InputField . AutocompletePrev ( )
return nil
case tcell . KeyEnter :
app . UI . MediaOverlay . InputField . CheckDone ( )
return nil
case tcell . KeyEsc :
app . UI . MediaOverlay . SetFocus ( MediaFocusOverview )
}
}
switch event . Key ( ) {
case tcell . KeyTab , tcell . KeyDown :
app . UI . MediaOverlay . InputField . AutocompleteNext ( )
return nil
case tcell . KeyBacktab , tcell . KeyUp :
app . UI . MediaOverlay . InputField . AutocompletePrev ( )
return nil
case tcell . KeyEnter :
app . UI . MediaOverlay . InputField . CheckDone ( )
return nil
case tcell . KeyEsc :
app . UI . MediaOverlay . SetFocus ( MediaFocusOverview )
}
return event
}
@ -363,16 +372,16 @@ func main() {
if app . UI . Focus == LeftPaneFocus {
if event . Key ( ) == tcell . KeyRune {
switch event . Rune ( ) {
case 'v' :
case 'v' , 'V' :
app . UI . SetFocus ( RightPaneFocus )
return nil
case 'k' :
case 'k' , 'K' :
app . UI . TootList . Prev ( )
return nil
case 'j' :
case 'j' , 'J' :
app . UI . TootList . Next ( )
return nil
case 'q' :
case 'q' , 'Q' :
app . App . Stop ( )
return nil
}
@ -410,19 +419,19 @@ func main() {
app . UI . CmdBar . View . SetText ( ":" )
app . UI . SetFocus ( CmdBarFocus )
return nil
case 't' :
case 't' , 'T' :
app . UI . ShowThread ( )
case 's' :
case 's' , 'S' :
app . UI . ShowSensetive ( )
case 'c' :
case 'c' , 'C' :
app . UI . NewToot ( )
case 'o' :
case 'o' , 'O' :
app . UI . ShowLinks ( )
case 'r' :
case 'r' , 'R' :
app . UI . Reply ( )
case 'm' :
case 'm' , 'M' :
app . UI . OpenMedia ( )
case 'f' :
case 'f' , 'F' :
//TODO UPDATE TOOT IN LIST
app . UI . FavoriteEvent ( )
case 'b' :