add: inc and dec without args

This commit is contained in:
starnakin 2023-08-02 17:51:17 +02:00
parent 6fa0ea91bd
commit 6b14c50e65
3 changed files with 18 additions and 0 deletions

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;
}

View File

@ -172,6 +172,10 @@ main()
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
error(data, "cmd not foud");
}