mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
(non)utf8 input in GUI
This commit is contained in:
@@ -44,10 +44,13 @@ getCommand = do
|
|||||||
s <- getLine
|
s <- getLine
|
||||||
return $ pCommand s
|
return $ pCommand s
|
||||||
|
|
||||||
getCommandUTF :: IO Command
|
-- decodes UTF8 if u==False, i.e. if the grammar does not use UTF8;
|
||||||
getCommandUTF = do
|
-- used in the Java GUI, which always uses UTF8
|
||||||
|
|
||||||
|
getCommandUTF :: Bool -> IO Command
|
||||||
|
getCommandUTF u = do
|
||||||
s <- getLine
|
s <- getLine
|
||||||
return $ pCommand s -- the GUI is doing this: $ decodeUTF8 s
|
return $ pCommand $ if u then s else decodeUTF8 s
|
||||||
|
|
||||||
pCommand = pCommandWords . words where
|
pCommand = pCommandWords . words where
|
||||||
pCommandWords s = case s of
|
pCommandWords s = case s of
|
||||||
|
|||||||
@@ -441,6 +441,15 @@ displaySStateJavaX isNew env state = encodeUTF8 $ mkUnicode $
|
|||||||
Just lang -> optDecodeUTF8 (stateGrammarOfLang env (language lang))
|
Just lang -> optDecodeUTF8 (stateGrammarOfLang env (language lang))
|
||||||
_ -> id
|
_ -> id
|
||||||
|
|
||||||
|
-- the env is UTF8 if the display language is
|
||||||
|
--- should be independent
|
||||||
|
isCEnvUTF8 :: CEnv -> SState -> Bool
|
||||||
|
isCEnvUTF8 env st = maybe False id $ do
|
||||||
|
lang <- getOptVal opts menuDisplay
|
||||||
|
co <- getOptVal (stateOptions (stateGrammarOfLang env (language lang))) uniCoding
|
||||||
|
return $ co == "utf8"
|
||||||
|
where
|
||||||
|
opts = addOptions (optsSState st) (globalOptions env)
|
||||||
|
|
||||||
langAbstract = language "Abstract"
|
langAbstract = language "Abstract"
|
||||||
langXML = language "XML"
|
langXML = language "XML"
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ sessionLineJ isNew env = do
|
|||||||
---- the Boolean is a temporary hack to have two parallel GUIs
|
---- the Boolean is a temporary hack to have two parallel GUIs
|
||||||
editLoopJnewX :: Bool -> CEnv -> SState -> IO ()
|
editLoopJnewX :: Bool -> CEnv -> SState -> IO ()
|
||||||
editLoopJnewX isNew env state = do
|
editLoopJnewX isNew env state = do
|
||||||
c <- getCommandUTF
|
c <- getCommandUTF (isCEnvUTF8 env state) ----
|
||||||
case c of
|
case c of
|
||||||
CQuit -> return ()
|
CQuit -> return ()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user