applidium / Vim

Port of the Vim text editor to the iOS
https://applidium.com/en
535 stars 99 forks source link

Implement a completely new custom keyboard replacing the system-provided one. #20

Closed broomdodger closed 7 years ago

broomdodger commented 11 years ago

Download 'Free Writing' and look what they have done with a custom keyboard.

Their keyboard works well, clean display, gestures, but editing...

Need vim!

Ecco commented 11 years ago

Spammy message. Feel free to contribute a custom keyboard if you want.

broomdodger commented 11 years ago

Hello Romain

I was not spamming. I am a vim user on MacOS, Linux, and WinXP. I work as an embedded systems programmer. I have been trying many editors for ios. None work as well as vim. All editors except 'Free Writing' use Apple's onscreen keyboards. I do not know how to program vim or keyboards, but was hoping to start a keyboard discussion.

Bill Muench Santa Cruz California

Ecco commented 11 years ago

Oh, ok. I thought you were advertising free writing. Sorry!

I updated the title of the issue, and re-opened it. Thanks for your suggestion!

Now, regarding this issue: I can see why it would be beneficial, but at the same time it is a huge amount of work. Think different keyboard layouts (being French I grew up learning an azerty layout and stuck to it ever since).

So Applidium is extremely unlikely to ever commit any effort in that direction. But if someone else comes up with some solid keyboard code, I'll happily merge it. At least as long as you can still use the default OS-wide keyboard, which I think should remain available no matter what.

jridgewell commented 11 years ago

The Google Chrome app also uses an custom keyboard (click the URL bar and you'll see it), but nothing like Free Writing. How hard would it be to do just a custom top bar to provide access to the control/meta and esc keys?

broomdodger commented 11 years ago

Would it be possible to add a set of emoji that have vim key sequences, such as escape, as well as 'function keys'?

In ios6: Settings > General > International > Keyboards > Emoji

Bill

au-phiware commented 11 years ago

Thank you Applidium for this great port of vim. I think that's it's highly commendable that you stuck to the system keyboard. You are absolutely right to say "Vim was flexible enough to work with only the system keyboard."

There are a number of very good reasons to use the system keyboard:

As to lack of meta keys my solution is to use never used characters (not speaking any language other than English means that there are a lot of these). For instance, I map ź to and by adding an extra keyboard (I chose Greek! YMMV) I have mapped ς to and φ to (notice the relative positions of the Greek characters to the Latin characters).

sukima commented 10 years ago

So I'm torn here. To me there are two main issues:

  1. VIM is designed as a modal interface (normal, insert, visual, etc. modes).
  2. Apple's keyboard is designed as a modal interface (alpha characters, non-alpha characters, extended non-alpha characters).

The intersection between the two means we have over 9 modes to manage! :scream:

I understand the advantage of having a modal keyboard allows a larger screen real estate to press buttons. I've seen other custom keyboards (iSSH) which attempt to merge all the modes into a full keyboard at the price of smaller buttons almost rendering the input impossible on an iPhone.

My personal preference would be to manage VIMs modes separate from the keyboard. Unlike the desktop version whose design was to prevent the user from moving their fingers from the home row of the keyboard the iPhone and iPad merge the user's pointer input into the same input device as the virtual keyboard. This distinction between the two environments is worth embracing. Here is a rather ad hoc comparison:

Desktop iOS
Modes managed by ESC key and normal mode commands The use of gestures and touch events allows access to possible mode management
Keyboard never changes Keyboard changes based on it's mode
Most all keys are easily accessible without moving fingers to far from home row There is no home row and input is down to one to two fingers at a time

To embrace both philosophies my proposal would be to separate VIM's mode switch from the keyboard like it is on the Desktop and leave the keyboard mode switching in Apple's hands. A possible example of this might be a tool bar above the Apple keyboard giving access to ESC and CTRL keys or maybe normal, insert buttons. Finally since selection is difficult you could use a click on the main screen (outside the keyboard) as a mode switcher. And or have mouse selection be it's own mode that you must enter to use while when not in mouse mode it is a simple ESC key.

My final note is that Apple will introduce custom keyboards in iOS 8. I imagine one day a custom keyboard that embraces the modal design philosophies that VI and VIM embrace. Maybe bridging out VI key bindings outside of the gVIM app and into all apps that use a keyboard. Assuming a clever keyboard design made that convenient.

joebologna commented 10 years ago

I'm not sure what to do about the 9 modes. However, the best keyboard I've seen implemented is: https://github.com/adamhoracek/KOKeyboard, it's used in both of their iPad apps: http://www.becomekodiak.com. I'm not sure it works on an iPhone. I think it's might make your life a lot easier vs. trying to implement one from scratch.

sukima commented 10 years ago

Thinking about this further I think having a swipe gesture would be awesome. swipe left for insert, right for normal. The status bar changes color and your pretty set. Mappings stay. Touch and drag still work. but you don't have to hunt down some meta key in a Greek or Emoji keyboard to navigate the modes of VIM. This could be easily manipulated by internally translating swipe events into some Meta key combo that your VIM instance can then map to whatever the user wishes. Or go a step further and add a <Swipe-Right> and <Swipe-Left> input keys into the VIM source.

sukima commented 10 years ago

@joebologna That keyboard looks awesome! The only thing that I'd comment is it's lack of the ESC key which in VIM is an integral key even more so then the Tab key. Adding this keyboard would defiantly enhance the input of VIM but with two disadvantages: It lessens the screen real estate for the VIM screen (on iPhone this is an issue). And it does not handle the ESC key for mode switching which would still have to be addressed as I described above.

joebologna commented 10 years ago

ESC has always been a problem. I've use a bluetooth keyboard a lot. I think ^[ works sometimes.

I looked at it a little bit. I'm thinking that whenever the keyboard is dismissed it could be the equivalent of exiting edit mode (i.e. sending an ESC). This is quite easy on an iPad, the keyboard has a dismiss button. I've seen programs use the gesture to slide the keyboard down as a way to dismiss it. The iOS Messaging app is an example of this.

nicolasbraun commented 7 years ago

We are gonna close this one and see if we can use an inputAccessoryView to add custom buttons