Skip to content

Commit

Permalink
Merge pull request #63 from Luthetus/dev
Browse files Browse the repository at this point in the history
Got keymaps for swapping focus between two contexts. I need to leave …
  • Loading branch information
Luthetus authored Sep 10, 2023
2 parents 3ec1eca + 0e80fa0 commit 149b7b9
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 20 deletions.
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);
}
}
}

0 comments on commit 149b7b9

Please sign in to comment.