Compare commits

...

6 Commits

Author SHA1 Message Date
573a366766 Add README.md 2023-10-03 18:03:57 +02:00
6b14c50e65 add: inc and dec without args 2023-08-02 17:51:17 +02:00
6fa0ea91bd fix: %n 2023-08-02 17:37:12 +02:00
4e15cb9ff1 add: write 2023-08-02 17:36:03 +02:00
1f1a11f886 fix: $ 2023-07-29 20:24:46 +02:00
2d1c5ee458 update irongolem 2023-07-29 20:19:06 +02:00
6 changed files with 54 additions and 4 deletions

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# GolemED
A clone of the famous ED text editor in ![golem](https://golem.re/)

7
src/commands/dec.🗿 Normal file
View File

@ -0,0 +1,7 @@
cmd_dec(data, args)
{
if ([data + LOCATION_CURRENT_LINE] != 0)
error("no line");
else
[data + LOCATION_CURRENT_LINE] = [data + LOCATION_CURRENT_LINE] - 1;
}

7
src/commands/inc.🗿 Normal file
View File

@ -0,0 +1,7 @@
cmd_inc(data, args)
{
if ([data + LOCATION_CURRENT_LINE] == [data + LOCATION_LENGTH])
error(data, "no line");
else
[data + LOCATION_CURRENT_LINE] = [data + LOCATION_CURRENT_LINE] + 1;
}

28
src/commands/write.🗿 Normal file
View File

@ -0,0 +1,28 @@
puterr(str)
{
local ptr = str;
loop
{
if ([ptr] == 0)
break;
err [ptr];
ptr++;
}
err '\n';
}
cmd_write(data, args)
{
local i = 0;
if ([data + LOCATION_LENGTH] == 0)
return 0;
loop
{
if (i == [data + LOCATION_LENGTH])
return 0;
puterr([[[data + LOCATION_ARRAY] + i] + MAP_VALUE]);
i++;
}
}

View File

@ -45,9 +45,9 @@ get_number(data, str)
if ([[str]] == '$') if ([[str]] == '$')
{ {
if (start == 0 - 1) if (start == 0 - 1)
start = data + LOCATION_LENGTH; start = [data + LOCATION_LENGTH] - 1;
else else
stop = data + LOCATION_LENGTH; stop = [data + LOCATION_LENGTH] - 1;
[str] = [str] + 1; [str] = [str] + 1;
} }
else if (isdigit([[str]])) else if (isdigit([[str]]))
@ -170,12 +170,18 @@ main()
cmd_delete(data, NULL); cmd_delete(data, NULL);
else if (strcmp(cmd, "h") == 0) else if (strcmp(cmd, "h") == 0)
cmd_help(data, NULL); cmd_help(data, NULL);
else if (strcmp(cmd, "w") == 0)
cmd_write(data, NULL);
else if (strcmp(cmd, "+") == 0)
cmd_inc(data, NULL);
else if (strcmp(cmd, "-") == 0)
cmd_dec(data, NULL);
else else
error(data, "cmd not foud"); error(data, "cmd not foud");
free(cmd);
} }
i++; i++;
} }
free(cmd);
free(ranges); free(ranges);
} }
} }