Skip to content

Commit c05fe36

Browse files
committed
Update user guide
* Mention the new "Edit file" button and drag'n'drop of a script file to set the command. * Updated screenshot. * Optimized all PNGs.
1 parent 4be20ff commit c05fe36

File tree

9 files changed

+24
-6
lines changed

9 files changed

+24
-6
lines changed
-6.27 KB
Loading
-6.47 KB
Loading
-24.1 KB
Loading
-1.7 KB
Loading
-22.6 KB
Loading
-1.33 KB
Loading

Assets/UserGuide/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ Command Management Window
6060

6161

6262
The command management window allows you to add/edit/remove/sort shortcuts.
63+
You can drag'n'drop a script to replace the currently shown command path.
64+
If the command is a script, the `Edit file` button will open it in a text editor.
65+
6366

6467

6568
Command List

Source/CommandsWindow.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <Roster.h>
2424
#include <ScrollView.h>
2525
#include <StringView.h>
26+
#include <cstdio>
2627
#include <private/shared/ToolBar.h>
2728

2829

@@ -84,7 +85,7 @@ CommandsWindow::CommandsWindow(BString& title)
8485
.SetInsets(0)
8586
.Add(fBrowseButton = new BButton("Browse" B_UTF8_ELLIPSIS, new BMessage(kBrowseCommandAction)))
8687
.AddGlue()
87-
.Add(fEditButton = new BButton("Edit" B_UTF8_ELLIPSIS, new BMessage(kEditCommandAction)))
88+
.Add(fEditButton = new BButton("Edit file" B_UTF8_ELLIPSIS, new BMessage(kEditCommandAction)))
8889
.End()
8990
.Add(fTerminalCheckBox, 1, 3)
9091
.End()
@@ -184,17 +185,18 @@ CommandsWindow::_BrowseCommand()
184185
void
185186
CommandsWindow::_EditCommand()
186187
{
187-
if (_CommandIsScript()) {
188-
const char* argv[] = { fCommandControl->Text(), NULL };
189-
be_roster->Launch("text/x-source-code", 1, argv);
190-
}
188+
BString file = _Deescape(fCommandControl->Text());
189+
const char* argv[] = { file.String(), NULL };
190+
printf("argv: %s\n\n", *argv);
191+
192+
be_roster->Launch("text/x-source-code", 1, argv);
191193
}
192194

193195

194196
bool
195197
CommandsWindow::_CommandIsScript()
196198
{
197-
BPath path = fCommandControl->Text();
199+
BPath path = _Deescape(fCommandControl->Text());
198200
if (path.InitCheck() != B_OK)
199201
return false;
200202

@@ -207,6 +209,18 @@ CommandsWindow::_CommandIsScript()
207209
return false;
208210
}
209211

212+
213+
const char*
214+
CommandsWindow::_Deescape(const char* path)
215+
{
216+
BString text(path);
217+
printf("original: %s\n", path);
218+
text.CharacterDeescape('\\');
219+
printf("deescaped: %s\n", text.String());
220+
return text.String();
221+
}
222+
223+
210224
void
211225
CommandsWindow::_InitNewCommand()
212226
{

Source/CommandsWindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class CommandsWindow : public BWindow {
3535
void _BrowseCommand();
3636
void _EditCommand();
3737
bool _CommandIsScript();
38+
const char* _Deescape(const char* path);
3839
void _RefsReceived(BMessage* message);
3940
status_t _LoadCommands();
4041
status_t _SaveCommands();

0 commit comments

Comments
 (0)