Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got keymaps for swapping focus between two contexts. I need to leave … #63

Merged
merged 1 commit into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Source/Lib/Luthetus.Ide.ClassLib/Context/ContextFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ public static class ContextFacts
"Global",
"global",
Keymap.Empty);

public static readonly ContextRecord ActiveContextsContext = new(
ContextKey.NewContextKey(),
"Active Contexts",
"active-contexts",
Keymap.Empty);

public static readonly ContextRecord FolderExplorerContext = new(
ContextKey.NewContextKey(),
Expand Down Expand Up @@ -86,6 +92,7 @@ public static class ContextFacts
public static readonly ImmutableArray<ContextRecord> ContextRecords = new[]
{
GlobalContext,
ActiveContextsContext,
FolderExplorerContext,
SolutionExplorerContext,
CompilerServiceExplorerContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@inherits FluxorComponent

<ContextBoundary ContextRecord="ContextFacts.EditorContext"
<ContextBoundary ContextRecord="ContextFacts.ActiveContextsContext"
ClassCssString="luth_ide_active-contexts"
StyleCssString="height: 100%">

Expand Down
72 changes: 53 additions & 19 deletions Source/Lib/Luthetus.Ide.RazorLib/LuthetusIdeInitializer.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ private async Task InitializeCompilerServiceExplorerStateAsync()
/// </summary>
private void InitializeGlobalContext()
{
var keymapArgument = new KeymapArgument(
{
var keymapArgument = new KeymapArgument(
"KeyZ",
null,
false,
Expand All @@ -300,26 +301,59 @@ private void InitializeGlobalContext()
false,
false);

// The <byte> generic type here is because I'm using closure for everything in this specific case.
var command = new Command(
async () =>
{
var success = await JsRuntime.InvokeAsync<bool>(
"luthetusIde.tryFocusHtmlElementById",
ContextFacts.GlobalContext.ContextElementId);

if (success)
var command = new Command(
async () =>
{
// TODO: Add a 'reveal' Func to perhaps set an active panel tab if needed,
// then invoke javascript one last time to try again.
}
},
"Focus Context Element",
"focus-context-element",
var success = await JsRuntime.InvokeAsync<bool>(
"luthetusIde.tryFocusHtmlElementById",
ContextFacts.GlobalContext.ContextElementId);

if (success)
{
// TODO: Add a 'reveal' Func to perhaps set an active panel tab if needed,
// then invoke javascript one last time to try again.
}
},
"Focus Context Element",
"focus-context-element",
false);

ContextFacts.GlobalContext.Keymap.Map.Add(
keymapArgument,
command);
}

{
var keymapArgument = new KeymapArgument(
"KeyX",
null,
false,
false,
true,
true,
false,
false);

ContextFacts.GlobalContext.Keymap.Map.Add(
keymapArgument,
command);
var command = new Command(
async () =>
{
var success = await JsRuntime.InvokeAsync<bool>(
"luthetusIde.tryFocusHtmlElementById",
ContextFacts.ActiveContextsContext.ContextElementId);

if (success)
{
// TODO: Add a 'reveal' Func to perhaps set an active panel tab if needed,
// then invoke javascript one last time to try again.
}
},
"Focus Context Element",
"focus-context-element",
false);

ContextFacts.GlobalContext.Keymap.Map.Add(
keymapArgument,
command);
}
}
}