diff --git a/apps/python-dsl/src/projections/incrementProjection.ts b/apps/python-dsl/src/projections/incrementProjection.ts index 7c0c7864..c5e104bd 100644 --- a/apps/python-dsl/src/projections/incrementProjection.ts +++ b/apps/python-dsl/src/projections/incrementProjection.ts @@ -1,15 +1,14 @@ import { arg, block, contextVariable } from "@puredit/parser"; import type { Projection } from "@puredit/projections/types"; import { pythonParser } from "./parser"; -import { simpleProjection } from "@puredit/simple-projection"; +import { noSpacing, simpleProjection } from "@puredit/simple-projection"; const var_x = arg("var_x", "identifier"); export const [pattern, draft] = pythonParser.statementPattern` ${var_x} += 1 `; -// todo: fix unnecessary indent -export const widget = simpleProjection([var_x, "++"]); +export const widget = simpleProjection([noSpacing(var_x), "++"]); // alternative: explicit and long projection definion // import { svelteProjection } from "@puredit/projections/svelte"; diff --git a/apps/python-dsl/src/projections/putsProjection.ts b/apps/python-dsl/src/projections/putsProjection.ts index 4e717d01..bcce42eb 100644 --- a/apps/python-dsl/src/projections/putsProjection.ts +++ b/apps/python-dsl/src/projections/putsProjection.ts @@ -12,7 +12,7 @@ export const [pattern, draft] = pythonParser.statementPattern` print(${anything}, end="") `; -export const widget = simpleProjection(["puts ", anything]); +export const widget = simpleProjection(["puts", anything]); // alternative projection def: explicit and long projection definion // import { svelteProjection } from "@puredit/projections/svelte"; diff --git a/apps/python-dsl/src/projections/timesProjection.ts b/apps/python-dsl/src/projections/timesProjection.ts index 6b97f684..bdf09843 100644 --- a/apps/python-dsl/src/projections/timesProjection.ts +++ b/apps/python-dsl/src/projections/timesProjection.ts @@ -1,7 +1,7 @@ import { arg, block } from "@puredit/parser"; import type { Projection } from "@puredit/projections/types"; import { pythonParser } from "./parser"; -import { simpleProjection } from "@puredit/simple-projection"; +import { noSpacing, simpleProjection } from "@puredit/simple-projection"; const times_var = arg("times_var", "identifier"); const times_value = arg("times_value", "identifier"); @@ -11,11 +11,10 @@ for ${times_var} in range(${times_value}): ${block({})} `; -// todo: fix unnecessary indent export const widget = simpleProjection([ - times_value, + noSpacing(times_value), ".times with ", - times_var, + noSpacing(times_var), ":", ]); diff --git a/packages/projections/TextInput.svelte b/packages/projections/TextInput.svelte index 60634371..01ef402e 100644 --- a/packages/projections/TextInput.svelte +++ b/packages/projections/TextInput.svelte @@ -17,6 +17,7 @@ export let className: string | null = null; export let placeholder = "text"; export let focusGroup: FocusGroup | null = null; + export let noSpacing: boolean | undefined = undefined; export let codeToValue = (code: string) => code; export let valueToCode = (value: string) => value; @@ -157,6 +158,7 @@