rvv001 - Viewing Key Display support added
Copy to Clipboard support added
This commit is contained in:
parent
cb927a0ab3
commit
fe8fb1fa3c
1 changed files with 39 additions and 7 deletions
|
@ -89,7 +89,7 @@ import Lens.Micro.Mtl
|
|||
import Lens.Micro.TH
|
||||
import System.Hclip
|
||||
import Text.Printf
|
||||
import Text.Wrap (FillScope(..), FillStrategy(..), WrapSettings(..))
|
||||
import Text.Wrap (FillScope(..), FillStrategy(..), WrapSettings(..), wrapTextToLines, defaultWrapSettings )
|
||||
import ZcashHaskell.Keys (generateWalletSeedPhrase)
|
||||
import ZcashHaskell.Orchard
|
||||
( getSaplingFromUA
|
||||
|
@ -261,6 +261,20 @@ makeLenses ''State
|
|||
zBalance :: State -> Double
|
||||
zBalance st = (fromIntegral (st ^. balance) ) / 100000000
|
||||
|
||||
-- Function to split text into fixed-size chunks
|
||||
splitText :: Int -> T.Text -> [T.Text]
|
||||
splitText chunkSize text =
|
||||
let strippedText = T.filter (/= '\n') text -- Remove newlines
|
||||
in if T.null strippedText
|
||||
then []
|
||||
else T.take chunkSize strippedText : splitText chunkSize (T.drop chunkSize strippedText)
|
||||
|
||||
-- Create a widget to display the long text
|
||||
renderLongText :: Int -> T.Text -> Widget Name
|
||||
renderLongText lineLength longText =
|
||||
let linesOfText = splitText lineLength longText
|
||||
in vBox $ map txt linesOfText
|
||||
|
||||
drawUI :: State -> [Widget Name]
|
||||
drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||
where
|
||||
|
@ -483,10 +497,12 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
ViewingKeyShow ->
|
||||
D.renderDialog
|
||||
(D.dialog (Just ( str ( " " ++ ( T.unpack ( st ^. vkName ) ) ++ " Viewing Key ") ) ) Nothing 50)
|
||||
-- (D.dialog (Just (str " Viewin Key ")) Nothing 50)
|
||||
(C.hCenter
|
||||
(hBox [capCommand "C" "opy to Clipoard", capCommand3 "" "E" "xit"]))
|
||||
|
||||
( padAll 1 (
|
||||
C.hCenter
|
||||
(renderLongText 45 (st ^. vkData) ) ) <=>
|
||||
C.hCenter
|
||||
(hBox [capCommand "C" "opy to Clipoard", capCommand3 "" "E" "xit"])
|
||||
)
|
||||
ViewingKeyMenu ->
|
||||
D.renderDialog
|
||||
(D.dialog (Just (str " Viewing Keys ")) Nothing 50)
|
||||
|
@ -1652,9 +1668,17 @@ appEvent (BT.VtyEvent e) = do
|
|||
-- Process any other event
|
||||
ev -> BT.zoom abAddresses $ L.handleListEvent ev
|
||||
--
|
||||
-- Viewing Key Display Support
|
||||
--
|
||||
ViewingKeyShow -> do
|
||||
case e of
|
||||
V.EvKey (V.KChar 'c') [] -> do
|
||||
liftIO $
|
||||
setClipboard $
|
||||
T.unpack $ s ^. vkData
|
||||
BT.modify $
|
||||
set msg $ (T.unpack ( s ^. vkName) ) ++ " viewing key copied to Clipboard!!"
|
||||
BT.modify $ set displayBox MsgDisplay
|
||||
V.EvKey (V.KChar 'e') [] -> do
|
||||
BT.modify $ set vkName ""
|
||||
BT.modify $ set vkData ""
|
||||
|
@ -1667,11 +1691,19 @@ appEvent (BT.VtyEvent e) = do
|
|||
BT.modify $ set vkName "Full"
|
||||
BT.modify $ set vkData "VKFull->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4"
|
||||
BT.modify $ set dialogBox ViewingKeyShow
|
||||
V.EvKey (V.KChar 'i') [] -> BT.modify $ set dialogBox Blank
|
||||
V.EvKey (V.KChar 'o') [] -> BT.modify $ set dialogBox Blank
|
||||
V.EvKey (V.KChar 'i') [] -> do
|
||||
BT.modify $ set vkName "Incomming"
|
||||
BT.modify $ set vkData "VKIncoming->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4"
|
||||
BT.modify $ set dialogBox ViewingKeyShow
|
||||
V.EvKey (V.KChar 'o') [] -> do
|
||||
BT.modify $ set vkName "Outgoing"
|
||||
BT.modify $ set vkData "VKOutgoing->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4"
|
||||
BT.modify $ set dialogBox ViewingKeyShow
|
||||
V.EvKey (V.KChar 'e') [] -> BT.modify $ set dialogBox Blank
|
||||
ev -> return ()
|
||||
--
|
||||
-- Process any other event
|
||||
--
|
||||
Blank -> do
|
||||
case e of
|
||||
V.EvKey (V.KChar '\t') [] -> focusRing %= F.focusNext
|
||||
|
|
Loading…
Reference in a new issue