Permalink
Browse files

Direct go to definition on Shift pressed and only one choice.

  • Loading branch information...
1 parent cb708d5 commit 9613bec773c712b4f26686b613246062fc062aaa @jutaro jutaro committed Jan 4, 2012
Showing with 21 additions and 23 deletions.
  1. +6 −9 src/IDE/Command.hs
  2. +2 −4 src/IDE/Core/Types.hs
  3. +4 −3 src/IDE/Pane/Info.hs
  4. +3 −2 src/IDE/Pane/Modules.hs
  5. +6 −5 src/IDE/Pane/SourceBuffer.hs
View
@@ -774,19 +774,19 @@ handleSpecialKeystrokes (Key { eventKeyName = name, eventModifier = mods,
printMods (m:r) = show m ++ printMods r
handleSpecialKeystrokes _ = return True
-setSymbol :: String -> IDEAction
-setSymbol symbol = do
+setSymbol :: String -> Bool -> IDEAction
+setSymbol symbol openSource = do
currentInfo' <- getWorkspaceInfo
search <- getSearch Nothing
case currentInfo' of
Nothing -> return ()
Just ((GenScopeC (PackScope _ symbolTable1)),(GenScopeC (PackScope _ symbolTable2))) ->
case filter (not . isReexported) (getIdentifierDescr symbol symbolTable1 symbolTable2) of
[] -> return ()
- a:[] -> selectIdentifier a
+ a:[] -> selectIdentifier a openSource
a:b:[] -> if isJust (dscMbModu a) && dscMbModu a == dscMbModu b &&
isNear (dscMbLocation a) (dscMbLocation b)
- then selectIdentifier a
+ then selectIdentifier a openSource
else setChoices search [a,b]
l -> setChoices search l
where
@@ -803,9 +803,9 @@ registerLeksahEvents = do
(\e@(LogMessage s t) -> getLog >>= \(log :: IDELog) -> liftIO $ appendLog log s t
>> return e)
registerEvent stRef "SelectInfo"
- (\ e@(SelectInfo str) -> setSymbol str >> return e)
+ (\ e@(SelectInfo str gotoSource) -> setSymbol str gotoSource >> return e)
registerEvent stRef "SelectIdent"
- (\ e@(SelectIdent id) -> selectIdentifier id >> return e)
+ (\ e@(SelectIdent id) -> selectIdentifier id False >> return e)
registerEvent stRef "InfoChanged"
(\ e@(InfoChanged b) -> reloadKeepSelection b >> return e)
registerEvent stRef "UpdateWorkspaceInfo"
@@ -845,9 +845,6 @@ registerLeksahEvents = do
(\ e@TraceChanged -> fillTraceList >> return e)
registerEvent stRef "GotoDefinition"
(\ e@(GotoDefinition descr) -> goToDefinition descr >> return e)
- registerEvent stRef "SearchSymbolDialog"
- (\ e@(SearchSymbolDialog text) ->
- setSymbol text >> return e)
registerEvent stRef "GetTextPopup"
(\ e@(GetTextPopup _) -> return (GetTextPopup (Just textPopupMenu)))
registerEvent stRef "StatusbarChanged"
View
@@ -235,14 +235,13 @@ runDebug = runReaderT
data IDEEvent =
InfoChanged Bool-- is it the initial = True else False
| UpdateWorkspaceInfo
- | SelectInfo String
+ | SelectInfo String Bool -- navigate to source (== True)
| SelectIdent Descr
| LogMessage String LogTag
| RecordHistory GUIHistory
| Sensitivity [(SensitivityMask,Bool)]
| SearchMeta String
| StartFindInitial
- | SearchSymbolDialog String
| GotoDefinition Descr
| LoadSession FilePath
| SaveSession FilePath
@@ -261,13 +260,12 @@ instance Event IDEEvent String where
getSelector (InfoChanged _) = "InfoChanged"
getSelector UpdateWorkspaceInfo = "UpdateWorkspaceInfo"
getSelector (LogMessage _ _) = "LogMessage"
- getSelector (SelectInfo _) = "SelectInfo"
+ getSelector (SelectInfo _ _) = "SelectInfo"
getSelector (SelectIdent _) = "SelectIdent"
getSelector (RecordHistory _) = "RecordHistory"
getSelector (Sensitivity _) = "Sensitivity"
getSelector (SearchMeta _) = "SearchMeta"
getSelector (StartFindInitial) = "StartFindInitial"
- getSelector (SearchSymbolDialog _) = "SearchSymbolDialog"
getSelector (GotoDefinition _) = "GotoDefinition"
getSelector (LoadSession _) = "LoadSession"
getSelector (SaveSession _) = "SaveSession"
View
@@ -116,10 +116,11 @@ instance RecoverablePane IDEInfo InfoState IDEM where
createHyperLinkSupport descriptionView sw (\_ _ iter -> do
(GtkEditorIter beg,GtkEditorIter en) <- reflectIDE (getIdentifierUnderCursorFromIter (GtkEditorIter iter, GtkEditorIter iter)) ideR
- return (beg, en)) (\_ _ slice -> do
+ return (beg, en)) (\_ shift' slice -> do
when (slice /= []) $ do
-- liftIO$ print ("slice",slice)
- reflectIDE (triggerEventIDE (SelectInfo slice)) ideR
+ reflectIDE (triggerEventIDE
+ (SelectInfo slice shift')) ideR
return ()
)
@@ -144,7 +145,7 @@ instance RecoverablePane IDEInfo InfoState IDEM where
symbol <- textBufferGetText buf l r True
when (controlIsPressed e)
(reflectIDE (do
- triggerEventIDE (SelectInfo symbol)
+ triggerEventIDE (SelectInfo symbol False)
return ()) ideR)
return False)
return (Just info,[ConnectC cid])
View
@@ -298,8 +298,8 @@ instance RecoverablePane IDEModules ModulesState IDEM where
return ()
return (Just modules,[ConnectC cid1,ConnectC cid2, ConnectC cid3])
-selectIdentifier :: Descr -> IDEAction
-selectIdentifier idDescr = do
+selectIdentifier :: Descr -> Bool -> IDEAction
+selectIdentifier idDescr openSource= do
systemScope <- getSystemInfo
workspaceScope <- getWorkspaceInfo
packageScope <- getPackageInfo
@@ -311,6 +311,7 @@ selectIdentifier idDescr = do
Just sc -> do
when (fst currentScope < sc) (setScope (sc,snd currentScope))
selectIdentifier' (modu pm) (dscName idDescr)
+ when openSource (goToDefinition idDescr)
scopeForDescr :: PackModule -> Maybe (GenScope,GenScope) ->
Maybe (GenScope,GenScope) -> Maybe GenScope -> Maybe Scope
@@ -518,13 +518,13 @@ builder' bs mbfn ind bn rbn ct prefs pp nb windows = do
("underscore",[GtkOld.Shift, GtkOld.Control],_) -> do
(start, end) <- getIdentifierUnderCursor buffer
slice <- getSlice buffer start end True
- triggerEventIDE (SelectInfo slice)
+ triggerEventIDE (SelectInfo slice False)
return True
-- Redundant should become a go to definition directly
("minus",[GtkOld.Control],_) -> do
(start, end) <- getIdentifierUnderCursor buffer
slice <- getSlice buffer start end True
- triggerEventIDE (SelectInfo slice)
+ triggerEventIDE (SelectInfo slice True)
return True
_ -> do
-- liftIO $ print ("sourcebuffer key:",name,modifier,keyval)
@@ -534,10 +534,11 @@ builder' bs mbfn ind bn rbn ct prefs pp nb windows = do
GtkEditorView sv -> do
(liftIO $ createHyperLinkSupport sv sw (\ctrl shift iter -> do
(GtkEditorIter beg,GtkEditorIter en) <- reflectIDE (getIdentifierUnderCursorFromIter (GtkEditorIter iter, GtkEditorIter iter)) ideR
- return (beg, if ctrl then en else beg)) (\_ _ slice -> do
+ return (beg, if ctrl then en else beg)) (\_ shift' slice -> do
when (slice /= []) $ do
-- liftIO$ print ("slice",slice)
- reflectIDE (triggerEventIDE (SelectInfo slice)) ideR
+ reflectIDE (triggerEventIDE
+ (SelectInfo slice shift')) ideR
return ()
))
@@ -707,7 +708,7 @@ selectInfo sv = do
buf <- getBuffer sv
(l,r) <- getIdentifierUnderCursor buf
symbol <- getText buf l r True
- triggerEvent ideR (SelectInfo symbol)
+ triggerEvent ideR (SelectInfo symbol False)
return ()
markActiveLabelAsChanged :: IDEAction

0 comments on commit 9613bec

Please sign in to comment.