Skip to content

Commit

Permalink
Only replace main window with live content for /url and /c leaving ex…
Browse files Browse the repository at this point in the history
…tra windows alone
  • Loading branch information
glguy committed Aug 20, 2024
1 parent 1e2c699 commit a9b8a86
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/Client/Image/Layout.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Client.Image.StatusLine (statusLineImage, minorStatusLineImage)
import Client.Image.Textbox (textboxImage)
import Client.State
import Client.State.Focus ( Focus, Subfocus )
import Client.View (viewLines)
import Client.View (viewMainLines, viewExtraLines)
import Control.Lens (view)
import Graphics.Vty.Attributes (defAttr)
import Graphics.Vty.Image
Expand Down Expand Up @@ -57,7 +57,7 @@ drawLayoutOne st extrafocus =
-- don't count textbox or the main status line against the main window's height
saveRows = 1 + imageHeight (statusLineImage w st)

extraLines = [ (focus, subfocus, viewLines focus subfocus w st)
extraLines = [ (focus, subfocus, viewExtraLines focus subfocus w st)
| (focus, subfocus) <- extrafocus ]

-- | Layout algorithm for all windows in a single column.
Expand Down Expand Up @@ -85,7 +85,7 @@ drawLayoutTwo st extrafocus =
divider = charFill (view palWindowDivider pal) ' ' 1 rows
rows = view clientHeight st

extraLines = [ (focus, subfocus, viewLines focus subfocus wr st)
extraLines = [ (focus, subfocus, viewExtraLines focus subfocus wr st)
| (focus, subfocus) <- extrafocus ]

drawMain ::
Expand All @@ -99,7 +99,7 @@ drawMain w h scroll st = (overscroll, row, col, nextOffset, msgs <-> bottomImg)
focus = view clientFocus st
subfocus = view clientSubfocus st

msgLines = viewLines focus subfocus w st
msgLines = viewMainLines focus subfocus w st

(overscroll, msgs) = messagePane w h' scroll msgLines

Expand Down
21 changes: 13 additions & 8 deletions src/Client/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ This module selects the correct view based on the current state.
-}
module Client.View
( viewLines
( viewMainLines
, viewExtraLines
) where

import Client.Image.PackedImage (Image')
Expand All @@ -35,13 +36,18 @@ import Client.View.Windows (windowsImages)
import Client.View.WindowSwitch (windowSwitchImages)
import Control.Lens (view)

viewLines :: Focus -> Subfocus -> Int -> ClientState -> [Image']
viewLines focus subfocus w !st =
-- | Generate the lines for the main window (the one associated with text input)
viewMainLines :: Focus -> Subfocus -> Int -> ClientState -> [Image']
viewMainLines focus subfocus w !st
| Just ("url",arg) <- clientActiveCommand st = urlSelectionView w (actualFocus subfocus focus) arg st
| Just ("c" ,arg) <- clientActiveCommand st = windowSwitchImages arg w st
| otherwise = viewExtraLines focus subfocus w st

-- | Generate the lines for an extra window. This is like 'viewMainLines' except
-- it doesn't react to the current state of the input bar.
viewExtraLines :: Focus -> Subfocus -> Int -> ClientState -> [Image']
viewExtraLines focus subfocus w !st =
case subfocus of
_ | Just ("url",arg) <- clientActiveCommand st ->
urlSelectionView w focus' arg st
_ | Just ("c",arg) <- clientActiveCommand st ->
windowSwitchImages arg w st
FocusInfo network channel ->
channelInfoImages network channel st
FocusUsers network channel
Expand All @@ -65,4 +71,3 @@ viewLines focus subfocus w !st =
_ -> chatMessageImages focus w st
where
pal = clientPalette st
focus' = actualFocus subfocus focus

0 comments on commit a9b8a86

Please sign in to comment.