-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text editor plugin, InputDialog enhancements #4135
Conversation
This plugin mostly sets up a "Text editor>" submenu, that allows browsing files, creating a new file, and managing a history of previously opened file for easier re-opening. It restore previous scroll and cursor positions on re-opening. Additional "Check lua" syntax button is added when editing a .lua file, and prevent saving if errors. The text editing is mainly provided by the enhanced InputDialog. InputDialog: added a few more options, the main one being 'save_callback', which will add a Save and Close buttons and manage saving/discarding/exiting. If "fullscreen" and "add_nav_bar", will add a show/hide keyboard button to it. Moved the preset buttons setup code in their own InputDialog methods for clarity of the main init code. Buttons are now enabled/disabled depending on context for feedback (eg: Save is disabled as long as text has not been modified). Added util.checkLuaSyntax(lua_string), might be useful elsewhere.
Propagate changes to subclassing widgets. Fix non-editability on InputDialog with input_type = "number" (eg: Statistics plugin)
I'll correct my akward english wording in another PR if need be :) |
onConfirm = function(dir_path) | ||
local file_input | ||
file_input = InputDialog:new{ | ||
title = _("Enter new file filename"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new file filename? just new filename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's about giving a birth name to a new file. Not about giving a new filename to an existing file (that new filename evokes for me). Will use this alternative so none of us is shocked :)
- First select a directory
- Then enter a name for the new file
- And start editing it
title = _("Enter filename")
buttons = is_lua and {{ | ||
-- First button on first row, that will be filled with Reset|Save|Close | ||
{ | ||
text = _("Check lua"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is Lua lowercase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember there was something about lua, thought it was meant to be lowercase. But no, it's just not to be made uppercase :| Correcting.
- Then type the new file filename | ||
- And start editing it | ||
|
||
Do you want to proceeed?]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proceed
Fix review comments around #4135 (comment)
Followup of initial idea and implementation by @mwoz123 in #4070.
The nice thing is we will now be able to read crash.log and do small mods to style tweaks, lua code, font or element sizes, for testing, from koreader itself.
And obviously to read koreader own code in koreader, cause there is no reading more interesting than that :)
This plugin mostly sets up a
Text editor>
submenu, that allows browsing files, creating a new file, and managing a history of previously opened file for easier re-access.(I added
Text editor>
as a first level of the Tools top menu icon, for easier re-access when viewing multiple files. Dunno if we should hide it inMore plugins
because it can be a powerful tool and allow users to break their device, as we're running as root and can edit anything).It restores previous scroll and cursor positions on re-opening.
Additional
Check lua
syntax button is added when editing a .lua file, and prevent saving if errors.The text editing is mainly provided by the enhanced InputDialog.
InputDialog: added a few more options, the main one being
save_callback
, which will add a Save and Close buttons and manage saving/discarding/exiting. (Existing uses of InputDialog could be modified and benefit from it).If
fullscreen
andadd_nav_bar
options are enabled, it will add a show/hide keyboard button to it.Moved the preset buttons setup code in their own InputDialog methods for clarity of the main init code.
Buttons are now enabled/disabled depending on context for feedback (eg:
Save
is disabled as long as text has not been modified).Added
util.checkLuaSyntax(lua_string)
, might be useful elsewhere.Related changes to PathChooser in #4133 were made for more convenient file selection. To be merged with this PR.
Closes #4033. Closes #1719.