hundredrabbits / Orca-c

Live Programming Environment(C Port)
http://wiki.xxiivv.com/orca
MIT License
485 stars 48 forks source link

Backspace character deletion #51

Closed linearsunrise closed 4 years ago

linearsunrise commented 4 years ago

added deletion behavior for backspace key.

backspace is implemented as it needed to be: the cursor deletes characters before the cursor's position in append mode.

case KEY_BACKSPACE:
      if (ged_state.input_mode == Ged_input_mode_append) {
        ged_dir_input(&ged_state, Ged_dir_left, 1);
        ged_input_character(&ged_state, '.');
        ged_dir_input(&ged_state, Ged_dir_left, 1);
      } else {
        ged_input_character(&ged_state, '.');
      }
      break;

but i noticed that in js version there the cursor is right on the character, and in c it would look like this

case KEY_BACKSPACE:
      ged_input_character(&ged_state, '.');
      if (ged_state.input_mode == Ged_input_mode_append) {
        ged_dir_input(&ged_state, Ged_dir_left, 2);
      }
      break;
npisanti commented 4 years ago

thanks! it seems fine to me, can you please squash rebase your commits into a single one so we are sure there are no modifications other than in the tui_main.c file ?

randrew commented 4 years ago

Is this the behavior we actually want? It seems to make typing in something horizontally kind of weird... I didn't know the JS version worked like that. But is it actually good?

linearsunrise commented 4 years ago

Is this the behavior we actually want? It seems to make typing in something horizontally kind of weird... I didn't know the JS version worked like that. But is it actually good?

hello. yeah, i understand. but i just wanted to add a backspace key so it would work for character deletion (i mean, adding the dot character), and in append mode it would work as in all usual text editors. for example, i want to use halts (or '#') as comment lines and type some support info in the patch. like i said, in orcaJS the cursor should be on a character, and in my opinion it's kind of inconvenient, because then i should press backspace one more time, before it would start to delete characters.

linearsunrise commented 4 years ago

i'm so sorry, i'm not figured out how to push rebased commits properly. @npisanti could you please cherrypick this commit? its link is https://github.com/hundredrabbits/Orca-c/commit/36421766d0c25f02fee17ead6faedd4983d6bec0

npisanti commented 4 years ago

Is this the behavior we actually want? It seems to make typing in something horizontally kind of weird... I didn't know the JS version worked like that. But is it actually good?

It goes backward when deleting only in append mode, i tested it and it feels very natural, expecially when writing out sequences inside T. Just checked the latest version of orcaJS and it also has the same functionality.

randrew commented 4 years ago

OK. If you think the behavior is better, then it's fine with me. You guys use it a lot more than I do.

npisanti commented 4 years ago

merged!