Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion locales/en.catkeys
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1 English x-vnd.KapiX-Koder 3292494141
1 English x-vnd.KapiX-Koder 2982779499
Something wrong has happened while opening the configuration file. Your personal settings will not be %s%. Preferences Something wrong has happened while opening the configuration file. Your personal settings will not be %s%.
Access denied EditorWindow Access denied
Line endings EditorWindow Line endings
Expand All @@ -24,6 +24,7 @@ Special symbols EditorWindow Special symbols
Show line endings EditorWindow Show line endings
Undo EditorWindow Undo
Comment line EditorWindow Comment line
Open project website EditorWindow Open project website
Show full path in title AppPreferencesWindow Show full path in title
Close EditorWindow Close
Spaces per tab: AppPreferencesWindow Spaces per tab:
Expand Down Expand Up @@ -76,6 +77,7 @@ save Preferences to _ the configuration save
Up to the next non-empty line AppPreferencesWindow Up to the next non-empty line
Replace all FindWindow Replace all
Koder System name Koder
View or submit bug reports EditorWindow View or submit bug reports
Extra large AppPreferencesWindow Toolbar icon size Extra large
Stack new windows AppPreferencesWindow Stack new windows
Find selection EditorWindow Find selection
Expand Down Expand Up @@ -116,6 +118,7 @@ Quit EditorWindow Quit
Redo EditorWindow Redo
Go to line: GoToLineWindow Go to line:
Editor settings Preferences Editor settings
Windows EditorWindow Windows
You don't have sufficient permissions to edit this file. EditorWindow You don't have sufficient permissions to edit this file.
Convert tabs to spaces AppPreferencesWindow Convert tabs to spaces
Search EditorWindow Search
Expand All @@ -134,6 +137,7 @@ Untitled EditorWindow Untitled
Unknown error. Preferences Unknown error.
Find FindWindow Find
Delete BookmarksListView Delete
Preferences… EditorWindow Preferences…
Reload EditorWindow Reload
Go to line GoToLineWindow Go to line
There are unsaved changes.\nSelect the files to save. QuitAlert There are unsaved changes.\nSelect the files to save.
Expand Down
6 changes: 6 additions & 0 deletions src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ App::MessageReceived(BMessage* message)
case SUPPRESS_INITIAL_WINDOW: {
fSuppressInitialWindow = true;
} break;
case ACTIVATE_WINDOW: {
BWindow* window = nullptr;
if(message->FindPointer("window", (void**) &window) == B_OK && window != nullptr) {
window->Activate();
}
} break;
case ACTIVE_WINDOW_CHANGED: {
if(message->FindPointer("window", (void**) &fLastActiveWindow) != B_OK) {
fLastActiveWindow = nullptr;
Expand Down
3 changes: 2 additions & 1 deletion src/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class Styler;

enum {
SUPPRESS_INITIAL_WINDOW = 'Siwn',
WINDOW_NEW_WITH_QUIT_REPLY = 'NWwn'
WINDOW_NEW_WITH_QUIT_REPLY = 'NWwn',
ACTIVATE_WINDOW = 'actw'
};


Expand Down
55 changes: 51 additions & 4 deletions src/editor/EditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <String.h>
#include <StringFormat.h>
#include <ToolBar.h>
#include <Url.h>
#include <kernel/fs_attr.h>

#include "App.h"
Expand All @@ -37,6 +38,7 @@
#include "FindReplaceHandler.h"
#include "FindWindow.h"
#include "GoToLineWindow.h"
#include "IconMenuItem.h"
#include "Languages.h"
#include "Preferences.h"
#include "ScintillaUtils.h"
Expand Down Expand Up @@ -85,8 +87,20 @@ EditorWindow::EditorWindow(bool stagger)
fOpenPanel->SetMessage(&openMessage);
fSavePanel = new BFilePanel(B_SAVE_PANEL, windowMessenger, nullptr, 0, false);

BMenu* appMenu = new BMenu("");
fWindowsMenu = new BMenu(B_TRANSLATE("Windows"));
BLayoutBuilder::Menu<>(appMenu)
.AddItem(B_TRANSLATE("About" B_UTF8_ELLIPSIS), B_ABOUT_REQUESTED)
.AddSeparator()
.AddMenu(fWindowsMenu)
.End()
.AddItem(B_TRANSLATE("Preferences" B_UTF8_ELLIPSIS), MAINMENU_EDIT_APP_PREFERENCES)
.AddSeparator()
.AddItem(B_TRANSLATE("Quit"), MAINMENU_FILE_QUIT, 'Q');

fMainMenu = new BMenuBar("MainMenu");
BLayoutBuilder::Menu<>(fMainMenu)
.AddItem(new IconMenuItem(appMenu, nullptr, gAppMime, B_MINI_ICON))
.AddMenu(B_TRANSLATE("File"))
.AddItem(B_TRANSLATE("New"), MAINMENU_FILE_NEW, 'N')
.AddSeparator()
Expand All @@ -101,7 +115,6 @@ EditorWindow::EditorWindow(bool stagger)
.AddItem(B_TRANSLATE("Open partner file"), MAINMENU_FILE_OPEN_CORRESPONDING, 'O', B_OPTION_KEY)
.AddSeparator()
.AddItem(B_TRANSLATE("Close"), B_QUIT_REQUESTED, 'W')
.AddItem(B_TRANSLATE("Quit"), MAINMENU_FILE_QUIT, 'Q')
.End()
.AddMenu(B_TRANSLATE("Edit"))
.AddItem(B_TRANSLATE("Undo"), B_UNDO, 'Z')
Expand All @@ -123,9 +136,8 @@ EditorWindow::EditorWindow(bool stagger)
.AddItem(B_TRANSLATE("Windows format"), MAINMENU_EDIT_CONVERTEOLS_WINDOWS)
.AddItem(B_TRANSLATE("Old Mac format"), MAINMENU_EDIT_CONVERTEOLS_MAC)
.End()
.AddSeparator()
//.AddSeparator()
//.AddItem(B_TRANSLATE("File preferences" B_UTF8_ELLIPSIS), MAINMENU_EDIT_FILE_PREFERENCES)
.AddItem(B_TRANSLATE("Koder preferences" B_UTF8_ELLIPSIS), MAINMENU_EDIT_APP_PREFERENCES)
.End()
.AddMenu(B_TRANSLATE("View"))
.AddMenu(B_TRANSLATE("Special symbols"))
Expand Down Expand Up @@ -153,7 +165,8 @@ EditorWindow::EditorWindow(bool stagger)
.AddItem("Dummy", MAINMENU_LANGUAGE)
.End()
.AddMenu(B_TRANSLATE("Help"))
.AddItem(B_TRANSLATE("About" B_UTF8_ELLIPSIS), B_ABOUT_REQUESTED)
.AddItem(B_TRANSLATE("Open project website"), MAINMENU_HELP_PROJECT)
.AddItem(B_TRANSLATE("View or submit bug reports"), MAINMENU_HELP_ISSUES)
.End();

// When changing this shortcut remember to update one in StatusView as well
Expand Down Expand Up @@ -673,6 +686,12 @@ EditorWindow::MessageReceived(BMessage* message)
fEditor->SendMessage(SCI_SETWRAPMODE, fPreferences->fWrapLines ?
SC_WRAP_WORD : SC_WRAP_NONE, 0);
} break;
case MAINMENU_HELP_PROJECT: {
BUrl("https://github.com/KapiX/Koder", true).OpenWithPreferredApplication();
} break;
case MAINMENU_HELP_ISSUES: {
BUrl("https://github.com/KapiX/Koder/issues", true).OpenWithPreferredApplication();
} break;
case MAINMENU_LANGUAGE: {
_SetLanguage(message->GetString("lang", "text"));
} break;
Expand Down Expand Up @@ -932,6 +951,34 @@ EditorWindow::Show()
}


void
EditorWindow::MenusBeginning()
{
if(fWindowsMenu == nullptr) {
return;
}
for(int32 x = fWindowsMenu->CountItems() - 1; x >= 0; x--) {
delete fWindowsMenu->ItemAt(x);
}
for(int32 x = 0; x < be_app->CountWindows(); x++) {
// use a dynamic_cast to filter out other window types (find, save, bookmarks, ...)
EditorWindow* window = dynamic_cast<EditorWindow*>(be_app->WindowAt(x));
if(window == nullptr)
continue;

BMessage* message = new BMessage(ACTIVATE_WINDOW);
message->AddPointer("window", window);
BMenuItem* menuItem = new BMenuItem(window->Title(), message);
if(window == this) {
menuItem->SetEnabled(false);
menuItem->SetMarked(true);
}
fWindowsMenu->AddItem(menuItem);
}
fWindowsMenu->SetTargetForItems(be_app);
}


const char*
EditorWindow::OpenedFilePath()
{
Expand Down
5 changes: 5 additions & 0 deletions src/editor/EditorWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ enum {
MAINMENU_SEARCH_PREVBOOKMARK = 'mpbk',
MAINMENU_SEARCH_GOTOLINE = 'msgl',

MAINMENU_HELP_PROJECT = 'hlpp',
MAINMENU_HELP_ISSUES = 'hlpi',

MAINMENU_LANGUAGE = 'ml00',
MAINMENU_OPEN_RECENT = 'mr00',

Expand Down Expand Up @@ -114,6 +117,7 @@ class EditorWindow : public BWindow {
void WindowActivated(bool active);
void FrameMoved(BPoint origin);
void Show();
void MenusBeginning();

bool IsModified() { return fModified; }
const char* OpenedFilePath();
Expand Down Expand Up @@ -148,6 +152,7 @@ class EditorWindow : public BWindow {
BFilePanel* fSavePanel;
BMenu* fOpenRecentMenu;
BMenu* fLanguageMenu;
BMenu* fWindowsMenu;
std::string fCurrentLanguage;
ToolBar* fToolbar;
StatusView* fStatusView;
Expand Down
Loading