Skip to content
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

Merged
merged 4 commits into from
Aug 6, 2018

Conversation

poire-z
Copy link
Contributor

@poire-z poire-z commented Aug 4, 2018

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.

image

image

image

(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 in More 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 and add_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.

image

image

Related changes to PathChooser in #4133 were made for more convenient file selection. To be merged with this PR.
Closes #4033. Closes #1719.

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.
@poire-z poire-z mentioned this pull request Aug 4, 2018
Propagate changes to subclassing widgets.
Fix non-editability on InputDialog with input_type = "number"
(eg: Statistics plugin)
@poire-z poire-z merged commit 6e35e68 into koreader:master Aug 6, 2018
@poire-z poire-z deleted the text_editor branch August 6, 2018 19:16
@poire-z
Copy link
Contributor Author

poire-z commented Aug 6, 2018

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"),
Copy link
Member

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

Copy link
Contributor Author

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"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is Lua lowercase?

Copy link
Contributor Author

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?]]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proceed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants