Skip to content

Commit

Permalink
Fixed: moving Up/Down key should rotate between function signatures f…
Browse files Browse the repository at this point in the history
…or all LSPs
  • Loading branch information
eranif committed Jun 3, 2024
1 parent 02fa54e commit 6a7bab0
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 111 deletions.
2 changes: 1 addition & 1 deletion LiteEditor/ContextRust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void ContextRust::OnEnterHit() {}

void ContextRust::OnFileSaved() {}

void ContextRust::OnKeyDown(wxKeyEvent& event) { event.Skip(); }
void ContextRust::OnKeyDown(wxKeyEvent& event) { ContextBase::OnKeyDown(event); }

void ContextRust::OnSciUpdateUI(wxStyledTextEvent& event) { wxUnusedVar(event); }

Expand Down
34 changes: 33 additions & 1 deletion LiteEditor/context_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "cl_command_event.h"
#include "cl_editor.h"
#include "cl_editor_tip_window.h"
#include "commentconfigdata.h"
#include "ctags_manager.h"
#include "drawingutils.h"
Expand Down Expand Up @@ -397,4 +398,35 @@ int ContextBase::PositionBeforeCurrent() const
return 0;
}
return GetCtrl().PositionBefore(curpos);
}
}

void ContextBase::OnKeyDown(wxKeyEvent& event)
{
clEditor& ctrl = GetCtrl();
if (!ctrl.GetFunctionTip()->IsActive()) {
event.Skip();
return;
}
switch (event.GetKeyCode()) {
case WXK_UP:
ctrl.GetFunctionTip()->SelectPrev(DoGetCalltipParamterIndex());
return;
case WXK_DOWN:
ctrl.GetFunctionTip()->SelectNext(DoGetCalltipParamterIndex());
return;
default: {
int modifier_key = event.GetModifiers();
wxChar ch = event.GetUnicodeKey();
if (modifier_key == wxMOD_CONTROL && (ch == 'J' || ch == 'N')) {
ctrl.GetFunctionTip()->SelectNext(DoGetCalltipParamterIndex());
return;
} else if (modifier_key == wxMOD_CONTROL && (ch == 'K' || ch == 'P')) {
ctrl.GetFunctionTip()->SelectPrev(DoGetCalltipParamterIndex());
return;
}
break;
}
}
// if we got here, it means that the event was not handled - call skip and return
event.Skip();
}
2 changes: 1 addition & 1 deletion LiteEditor/context_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class ContextBase : public wxEvtHandler
virtual void OnDwellEnd(wxStyledTextEvent& event) { event.Skip(); }
virtual void OnDbgDwellEnd(wxStyledTextEvent& event) { event.Skip(); }
virtual void OnDbgDwellStart(wxStyledTextEvent& event) { event.Skip(); }
virtual void OnKeyDown(wxKeyEvent& event) { event.Skip(); }
virtual void OnKeyDown(wxKeyEvent& event);
virtual void AddMenuDynamicContent(wxMenu* WXUNUSED(menu)) {}
virtual void RemoveMenuDynamicContent(wxMenu* WXUNUSED(menu)) {}
virtual void OnSciUpdateUI(wxStyledTextEvent& WXUNUSED(event)) {}
Expand Down
28 changes: 1 addition & 27 deletions LiteEditor/context_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1202,33 +1202,7 @@ void ContextCpp::OnGenerateSettersGetters(wxCommandEvent& event)
}
}

void ContextCpp::OnKeyDown(wxKeyEvent& event)
{
clEditor& ctrl = GetCtrl();
if (ctrl.GetFunctionTip()->IsActive()) {
switch (event.GetKeyCode()) {
case WXK_UP:
ctrl.GetFunctionTip()->SelectPrev(DoGetCalltipParamterIndex());
return;

case WXK_DOWN:
ctrl.GetFunctionTip()->SelectNext(DoGetCalltipParamterIndex());
return;
default: {
int modifier_key = event.GetModifiers();
wxChar ch = event.GetUnicodeKey();
if (modifier_key == wxMOD_CONTROL && (ch == 'J' || ch == 'N')) {
ctrl.GetFunctionTip()->SelectNext(DoGetCalltipParamterIndex());
return;
} else if (modifier_key == wxMOD_CONTROL && (ch == 'K' || ch == 'P')) {
ctrl.GetFunctionTip()->SelectPrev(DoGetCalltipParamterIndex());
return;
}
}
}
}
event.Skip();
}
void ContextCpp::OnKeyDown(wxKeyEvent& event) { ContextBase::OnKeyDown(event); }

void ContextCpp::OnFindImpl(wxCommandEvent& event)
{
Expand Down
Loading

0 comments on commit 6a7bab0

Please sign in to comment.