I copied the modelist.js file from the kitchen sink demo and added doc
comments to the exported methods.
This module would be extremely helpful to anyone implementing a menu
system or who wanted to programatically switch rendering modes based on
the file extension of the file loaded into ace. I can think of several
use cases for it already. (1) in the settingsMenu branch. (2) in
supporting theme switching for anyone implementing drag and drop support
for loading files into the editor (3) in supporting theme switching for
sites implementing their own file picker dialogues and loading content
into ace through xmlhttprequest (4) in supporting filebrowser / editor
applications where a server could be set up to display file contents in
an ace editor as users browsed to arbitrary files. (5) etc. etc.
Had I known about it when I began writing the settingsMenu branch I
would have used it.
This branch now depends on the modelist being pulled in as a module. I'm
using the modelist to generate the menu options for switching modes
because it's redundant to have the same massive list in two places.
The modelist module also has some awesome features so I choose it over
my silly list. :D
When the editor takes up the entire window and the window is only half
the size of my screen, the menus get crunched up horribly. I'll provide
for closing the overlay by pressing esc in case the overlay's contents
take up the entire screen.
If ace is to be used in very small frames then implementors will need to
provide styling information in css to control how the settings menu
looks.
The overlay menu should remain visible when scrolling a long page. The
intention is to present information on demand and not leave the menu on
screen. If allowed to scroll away the remaining element could interfere
with the page.
I pulled the code for generating the menu out into its own module called
overlay_page. I pulled the code for generating a menu, using
overlay_page, out into its own module called show_keyboard_shortcuts.
The logic for getting a list of keyboard shortcuts pertinent to the
current operating system is by itself in the module
get_editor_keyboard_shortcuts. This should make it easy for anyone to
change the appearance of the menu without worrying about breaking the
code which fetches the data.
I'm not set on the keybinding or the aesthetics of this. please change
them at will. The main goal here is to provide some method to list all
the keyboard shortcuts dynamically. I mean that when new shortcuts are
added they should automatically be put into this menu without anyone
writing any extra code. The menu provides a way for end users to easily
discover the many built in functions accessible through the keyboard.
Admittedly the current keybinding to display this menu is not very
convenient or easily guessed. I like the way that the textarea version
of ace presents a single clickable corner that is easily identified by
users. It would be cool to make this pretty and obvious.