1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Various improvements

This commit is contained in:
Laurent Cozic 2017-10-08 18:50:43 +01:00
parent dc219141fa
commit 3704f5be27
7 changed files with 64 additions and 32 deletions

View File

@ -49,11 +49,11 @@ class AppGui {
buildUi() {
this.rootWidget_ = new ReduxRootWidget(this.store_);
this.rootWidget_.setName('rootWidget');
this.rootWidget_.name = 'rootWidget';
const folderList = new FolderListWidget();
folderList.setStyle({ borderBottomWidth: 1 });
folderList.setName('folderList');
folderList.name = 'folderList';
folderList.setVStretch(true);
folderList.on('currentItemChange', async () => {
const folder = folderList.currentItem;
@ -78,7 +78,7 @@ class AppGui {
}
return label;
});
noteList.setName('noteList');
noteList.name = 'noteList';
noteList.setVStretch(true);
noteList.setStyle({
borderBottomWidth: 1,
@ -101,7 +101,7 @@ class AppGui {
const noteText = new NoteWidget();
noteText.setVStretch(true);
noteText.setName('noteText');
noteText.name = 'noteText';
noteText.setStyle({ borderBottomWidth: 1 });
this.rootWidget_.connect(noteText, (state) => {
return { noteId: state.selectedNoteId };
@ -109,25 +109,25 @@ class AppGui {
const consoleWidget = new ConsoleWidget();
consoleWidget.setHStretch(true);
consoleWidget.setName('console');
consoleWidget.name = 'console';
consoleWidget.on('accept', (event) => {
this.processCommand(event.input);
this.processCommand(event.input, 'console');
});
const hLayout = new HLayoutWidget();
hLayout.setName('hLayout');
hLayout.name = 'hLayout';
hLayout.addChild(folderList, { type: 'stretch', factor: 1 });
hLayout.addChild(noteList, { type: 'stretch', factor: 1 });
hLayout.addChild(noteText, { type: 'stretch', factor: 1 });
const vLayout = new VLayoutWidget();
vLayout.setName('vLayout');
vLayout.name = 'vLayout';
vLayout.addChild(hLayout, { type: 'stretch', factor: 1 });
vLayout.addChild(consoleWidget, { type: 'fixed', factor: 5 });
const win1 = new WindowWidget();
win1.addChild(vLayout);
win1.setName('mainWindow');
win1.name = 'mainWindow';
this.rootWidget_.addChild(win1);
}
@ -135,10 +135,36 @@ class AppGui {
setupShortcuts() {
const shortcuts = {};
const consoleWidget = this.widget('console');
shortcuts['DELETE'] = 'rm $n';
shortcuts['t'] = 'todo toggle $n';
shortcuts['c'] = () => { this.widget('console').focus(); };
shortcuts[' '] = 'edit $n';
shortcuts[' '] = 'todo toggle $n';
shortcuts['c'] = () => {
consoleWidget.focus();
}
shortcuts['ENTER'] = () => {
const w = this.widget('mainWindow').focusedWidget();
if (w.name == 'folderList') {
this.widget('noteList').focus();
} else if (w.name == 'noteList') {
this.processCommand('edit $n');
}
}
shortcuts[':nn'] = () => {
consoleWidget.focus('mknote ');
}
shortcuts[':nt'] = () => {
consoleWidget.focus('mktodo ');
}
shortcuts[':nb'] = () => {
consoleWidget.focus('mkbook ');
}
return shortcuts;
}
@ -167,7 +193,7 @@ class AppGui {
const widget = this.widget('mainWindow').focusedWidget();
if (!widget) return null;
if (widget.name() == 'noteList' || widget.name() == 'folderList') {
if (widget.name == 'noteList' || widget.name == 'folderList') {
return widget.currentItem;
}
@ -194,9 +220,7 @@ class AppGui {
const consoleWidget = this.widget('console');
const metaCmd = cmd.substr(0, 2);
if (metaCmd === ':m') {
if (cmd === ':m') {
if (consoleWidget.isMaximized__ === undefined) {
consoleWidget.isMaximized__ = false;
}
@ -211,6 +235,11 @@ class AppGui {
this.widget('vLayout').setWidgetConstraints(consoleWidget, constraints);
return;
} else if (cmd[0] === ':') {
if (this.shortcuts_[cmd]) {
this.shortcuts_[cmd]();
return;
}
}
let note = this.widget('noteList').currentItem;
@ -218,10 +247,10 @@ class AppGui {
let args = cliUtils.splitCommandString(cmd);
for (let i = 0; i < args.length; i++) {
if (note && args[i] == '$n') {
args[i] = note.id;
} else if (folder && args[i] == '$b') {
args[i] = folder.id;
if (args[i] == '$n') {
args[i] = note ? note.id : '';
} else if (args[i] == '$b') {
args[i] = folder ? folder.id : '';
} else if (args[i] == '$c') {
const item = this.activeListItem();
args[i] = item ? item.id : '';
@ -263,8 +292,6 @@ class AppGui {
const consoleWidget = this.widget('console');
//await this.updateFolderList();
term.grabInput();
term.on('key', async (name, matches, data) => {
@ -276,7 +303,9 @@ class AppGui {
}
if (!consoleWidget.hasFocus()) {
if (name in this.shortcuts_) {
if (name == ':') {
consoleWidget.focus(':');
} else if (name in this.shortcuts_) {
const cmd = this.shortcuts_[name];
if (typeof cmd === 'function') {
cmd();

View File

@ -83,9 +83,12 @@ class Application {
answers[i + 1] = output[i].title;
}
let msg = _('More than one item match "%s". Please select one:', pattern);
const response = await cliUtils.promptMcq(msg, answers);
if (!response) return null;
// Not really useful with new UI?
throw new Error(_('More than one item match "%s". Please narrow down your query.', pattern));
// let msg = _('More than one item match "%s". Please select one:', pattern);
// const response = await cliUtils.promptMcq(msg, answers);
// if (!response) return null;
return output[response - 1];
} else {

View File

@ -42,7 +42,7 @@ class Command extends BaseCommand {
let note = await app().loadItem(BaseModel.TYPE_NOTE, title);
if (!note) {
const ok = await cliUtils.promptConfirm(_('Note does not exist: "%s". Create it?', title));
const ok = await this.prompt(_('Note does not exist: "%s". Create it?', title));
if (!ok) return;
newNote = await Note.save({ title: title, parent_id: app().currentFolder().id });
note = await Note.load(newNote.id);
@ -76,7 +76,7 @@ class Command extends BaseCommand {
updatedNote = await Note.unserializeForEdit(updatedNote);
updatedNote.id = note.id;
await Note.save(updatedNote);
process.stdout.write('.');
//process.stdout.write('.');
watchTimeout = null;
}, 200);
});

View File

@ -32,7 +32,7 @@ class Command extends BaseCommand {
if (!folderTitle) folderTitle = filename(filePath);
folder = await Folder.loadByField('title', folderTitle);
const msg = folder ? _('File "%s" will be imported into existing notebook "%s". Continue?', basename(filePath), folderTitle) : _('New notebook "%s" will be created and file "%s" will be imported into it. Continue?', folderTitle, basename(filePath));
const ok = force ? true : await cliUtils.promptConfirm(msg);
const ok = force ? true : await this.prompt(msg);
if (!ok) return;
let options = {

View File

@ -19,7 +19,7 @@ msgid "[Cancel]"
msgstr ""
#, javascript-format
msgid "More than one item match \"%s\". Please select one:"
msgid "More than one item match \"%s\". Please narrow down your query."
msgstr ""
msgid "No notebook selected."

View File

@ -20,7 +20,7 @@ msgid "[Cancel]"
msgstr "Annulation..."
#, javascript-format
msgid "More than one item match \"%s\". Please select one:"
msgid "More than one item match \"%s\". Please narrow down your query."
msgstr ""
msgid "No notebook selected."

View File

@ -19,7 +19,7 @@ msgid "[Cancel]"
msgstr ""
#, javascript-format
msgid "More than one item match \"%s\". Please select one:"
msgid "More than one item match \"%s\". Please narrow down your query."
msgstr ""
msgid "No notebook selected."