-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added projection times, tuned others
- Loading branch information
Showing
6 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script lang="ts"> | ||
import { onMount } from "svelte"; | ||
import { tags } from "@lezer/highlight"; | ||
import type { EditorState } from "@codemirror/state"; | ||
import type { EditorView } from "@codemirror/view"; | ||
import { highlightingFor } from "@codemirror/language"; | ||
import type { Match } from "@puredit/parser"; | ||
import type { FocusGroup } from "@puredit/projections/focus"; | ||
import TextInput from "@puredit/projections/TextInput.svelte"; | ||
// import { validateFromList } from "@puredit/projections/shared"; | ||
// import type { ContextGlobal } from "./context"; | ||
export let isNew: boolean; | ||
export let view: EditorView | null; | ||
export let match: Match; | ||
export let state: EditorState; | ||
export let focusGroup: FocusGroup; | ||
onMount(() => { | ||
if (isNew) { | ||
requestAnimationFrame(() => { | ||
focusGroup.first(); | ||
}); | ||
} | ||
}); | ||
</script> | ||
|
||
<span class="inline-flex"> | ||
<span class="noindent" /> | ||
<TextInput | ||
className={highlightingFor(state, [tags.atom])} | ||
node={match.args.times_value} | ||
{state} | ||
{view} | ||
{focusGroup} | ||
placeholder="# times" | ||
/> | ||
<span class="boundleft">.times:</span> | ||
</span> | ||
|
||
<style> | ||
.boundleft { | ||
margin-left: -10px; | ||
} | ||
.noindent { | ||
margin-left: -10px; | ||
} | ||
.text-right { | ||
text-align: right; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { Text } from "@codemirror/state"; | ||
import { arg, block, contextVariable } from "@puredit/parser"; | ||
import type { Match } from "@puredit/parser"; | ||
import { stringLiteralValue } from "@puredit/projections/shared"; | ||
import { svelteProjection } from "@puredit/projections/svelte"; | ||
import type { Projection } from "@puredit/projections/types"; | ||
import TimesProjection from "./TimesProjection.svelte"; | ||
// import type { ContextColumns, ContextTables } from "./context"; | ||
import { pythonParser } from "./parser"; | ||
|
||
const times_value = arg("times_value", "integer"); | ||
|
||
export const [pattern, draft] = pythonParser.statementPattern` | ||
for index in range(${times_value}): | ||
${block({})} | ||
`; | ||
|
||
export const widget = svelteProjection(TimesProjection); | ||
|
||
export const timesProjection: Projection = { | ||
name: "times", | ||
description: "Loop a block X times", | ||
pattern, | ||
draft, | ||
requiredContextVariables: [], | ||
widgets: [widget], | ||
}; |