-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow menu items to span multiple lines
- Loading branch information
Showing
40 changed files
with
1,419 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Unreleased | ||
|
||
* Add support for multiline menu items. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
module Ribosome.Menu.Data.CursorIndex where | ||
|
||
newtype CursorIndex = | ||
CursorIndex { unCursorIndex :: Int } | ||
CursorIndex { unCursorIndex :: Word } | ||
deriving stock (Eq, Show, Generic) | ||
deriving newtype (Num, Real, Enum, Integral, Ord) | ||
|
||
instance Default CursorIndex where | ||
def = | ||
0 | ||
def = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module Ribosome.Menu.Data.CursorLine where | ||
|
||
newtype CursorLine = | ||
CursorLine { unCursorLine :: Int } | ||
CursorLine { unCursorLine :: Word } | ||
deriving stock (Eq, Show, Generic) | ||
deriving newtype (Num, Real, Enum, Integral, Ord) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,50 @@ | ||
module Ribosome.Menu.Data.NvimMenuState where | ||
|
||
import Ribosome.Menu.Data.CursorIndex (CursorIndex) | ||
import Ribosome.Menu.Data.CursorLine (CursorLine) | ||
import Ribosome.Menu.Data.MenuView (MenuView) | ||
import Ribosome.Menu.Data.Entry (Entry) | ||
import Ribosome.Menu.Data.MenuView (EntryIndex, MenuView) | ||
|
||
data NvimMenuState = | ||
NvimMenuState { | ||
view :: MenuView, | ||
cursorIndex :: CursorIndex, | ||
indexes :: [(Int, Bool)] | ||
data PartialEntry a = | ||
PartialEntry { | ||
entry :: Entry a, | ||
visibleLines :: Word | ||
} | ||
deriving stock (Eq, Show, Generic) | ||
|
||
instance Default NvimMenuState where | ||
def = | ||
NvimMenuState def 0 def | ||
data EntrySlice i = | ||
EntrySlice { | ||
full :: [Entry i], | ||
indexBot :: EntryIndex, | ||
indexTop :: EntryIndex, | ||
partialBot :: Maybe (PartialEntry i), | ||
partialTop :: Maybe (PartialEntry i) | ||
} | ||
| | ||
OnlyPartialEntry { | ||
entry :: PartialEntry i, | ||
index :: EntryIndex | ||
} | ||
deriving stock (Eq, Show, Generic) | ||
|
||
topIndex :: Lens' NvimMenuState Int | ||
topIndex = | ||
#view . #topIndex | ||
sliceRange :: EntrySlice i -> (EntryIndex, EntryIndex) | ||
sliceRange = \case | ||
EntrySlice {..} -> (indexBot, indexTop) | ||
OnlyPartialEntry {index} -> (index, index) | ||
|
||
botIndex :: Lens' NvimMenuState Int | ||
botIndex = | ||
#view . #botIndex | ||
data SliceIndexes = | ||
SliceIndexes { | ||
full :: [(Word, Bool)], | ||
partialBot :: Maybe (Word, Word, Bool), | ||
partialTop :: Maybe (Word, Word, Bool) | ||
} | ||
deriving stock (Eq, Show, Generic) | ||
deriving anyclass (Default) | ||
|
||
cursor :: Lens' NvimMenuState CursorIndex | ||
cursor = | ||
#view . #cursor | ||
data NvimMenuState = | ||
NvimMenuState { | ||
view :: MenuView, | ||
slice :: SliceIndexes | ||
} | ||
deriving stock (Eq, Show, Generic) | ||
|
||
cursorLine :: Lens' NvimMenuState CursorLine | ||
cursorLine = | ||
#view . #cursorLine | ||
instance Default NvimMenuState where | ||
def = NvimMenuState def def |
Oops, something went wrong.