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
5 changes: 3 additions & 2 deletions locales/en.catkeys
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1 English x-vnd.KapiX-Koder 4193593144
1 English x-vnd.KapiX-Koder 771836523
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 Down Expand Up @@ -50,6 +50,7 @@ Match case FindWindow Match case
Distributed on MIT license terms. App Distributed on MIT license terms.
Couldn't find style files. Make sure you have them installed in one of your data directories. Styler Couldn't find style files. Make sure you have them installed in one of your data directories.
Find: FindWindow Find:
Block AppPreferencesWindow Cursor width or style Block
View EditorWindow View
Neil Hodgson, for Scintilla editing component and SciTE editor. App Neil Hodgson, for Scintilla editing component and SciTE editor.
Reached the end of the target. No results found. EditorWindow Reached the end of the target. No results found.
Expand Down Expand Up @@ -155,6 +156,7 @@ Preferences… EditorWindow Preferences…
Go to line GoToLineWindow Go to line
Reload EditorWindow Reload
There are unsaved changes.\nSelect the files to save. QuitAlert There are unsaved changes.\nSelect the files to save.
Cursor width (pixels) AppPreferencesWindow Cursor width (pixels)
The file has been removed. What to do? EditorWindow The file has been removed. What to do?
Enormous AppPreferencesWindow Toolbar icon size Enormous
Trim trailing whitespace EditorWindow Trim trailing whitespace
Expand All @@ -176,7 +178,6 @@ File modified EditorWindow File modified
Highlight braces AppPreferencesWindow Highlight braces
Save selected QuitAlert Save selected
Max. characters per line: AppPreferencesWindow Max. characters per line:
Use block cursor AppPreferencesWindow Use block cursor
Highlight trailing whitespace AppPreferencesWindow Highlight trailing whitespace
Up to the next/previous non-empty line AppPreferencesWindow Up to the next/previous non-empty line
Show indentation guides AppPreferencesWindow Show indentation guides
Expand Down
8 changes: 6 additions & 2 deletions src/editor/EditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1331,8 +1331,12 @@ EditorWindow::_SyncWithPreferences()
fEditor->SendMessage(SCI_SETCARETLINEVISIBLE, fPreferences->fLineHighlighting, 0);
fEditor->SendMessage(SCI_SETCARETLINEVISIBLEALWAYS, true, 0);
fEditor->SendMessage(SCI_SETCARETLINEFRAME, fPreferences->fLineHighlightingMode ? 2 : 0);
fEditor->SendMessage(SCI_SETCARETSTYLE,
fPreferences->fUseBlockCursor ? (CARETSTYLE_BLOCK | CARETSTYLE_BLOCK_AFTER) : CARETSTYLE_LINE);
if(fPreferences->fCursorWidth == UINT8_MAX) {
fEditor->SendMessage(SCI_SETCARETSTYLE, (CARETSTYLE_BLOCK | CARETSTYLE_BLOCK_AFTER));
} else {
fEditor->SendMessage(SCI_SETCARETSTYLE, CARETSTYLE_LINE);
fEditor->SendMessage(SCI_SETCARETWIDTH, fPreferences->fCursorWidth);
}

if(fFilePreferences.fEOLMode) {
fEditor->SendMessage(SCI_SETEOLMODE, fFilePreferences.fEOLMode.value_or(SC_EOL_LF), 0);
Expand Down
35 changes: 31 additions & 4 deletions src/preferences/AppPreferencesWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,12 @@ AppPreferencesWindow::MessageReceived(BMessage* message)
fPreferences->fBracesHighlighting = IsChecked(fBracesHighlightingCB);
_PreferencesModified();
} break;
case Actions::CURSOR_WIDTH: {
fPreferences->fCursorWidth = std::stoi(fCursorWidthMF->Menu()->FindMarked()->Label());
_PreferencesModified();
} break;
case Actions::BLOCK_CURSOR: {
fPreferences->fUseBlockCursor = IsChecked(fBlockCursorCB);
fPreferences->fCursorWidth = UINT8_MAX;
_PreferencesModified();
} break;
case Actions::EDITOR_STYLE: {
Expand Down Expand Up @@ -341,7 +345,18 @@ AppPreferencesWindow::_InitInterface()
fIndentGuidesBox->SetLabel(fIndentGuidesShowCB);

fBracesHighlightingCB = new BCheckBox("bracesHighlighting", B_TRANSLATE("Highlight braces"), new BMessage((uint32) Actions::BRACES_HIGHLIGHTING));
fBlockCursorCB = new BCheckBox("blockCursor", B_TRANSLATE("Use block cursor"), new BMessage((uint32) Actions::BLOCK_CURSOR));

BPopUpMenu* cursorMenu = new BPopUpMenu("cursorMenu");
auto menuBuilder = BLayoutBuilder::Menu<>(cursorMenu);
for(int32 x = 1; x < 6; x++) {
BString label;
label << x;
menuBuilder.AddItem(label.String(), CURSOR_WIDTH);
}
menuBuilder
.AddSeparator()
.AddItem(B_TRANSLATE_COMMENT("Block", "Cursor width or style"), BLOCK_CURSOR);
fCursorWidthMF = new BMenuField("cursorWidth", B_TRANSLATE("Cursor width (pixels)"), cursorMenu);

fEditorStyleMenu = new BPopUpMenu("style");
fEditorStyleMF = new BMenuField("style", B_TRANSLATE("Style"), fEditorStyleMenu);
Expand Down Expand Up @@ -380,7 +395,7 @@ AppPreferencesWindow::_InitInterface()
.Add(fCompactLangMenuCB)
.Add(fFullPathInTitleCB)
.Add(fBracesHighlightingCB)
.Add(fBlockCursorCB)
.Add(fCursorWidthMF)
.Add(fToolbarBox)
.AddStrut(B_USE_HALF_ITEM_SPACING)
.Add(fLineLimitBox)
Expand Down Expand Up @@ -485,8 +500,20 @@ AppPreferencesWindow::_SyncPreferences(Preferences* preferences)
fFontSizeSpinner->SetMessage(new BMessage((uint32) Actions::FONT_SIZE_CHANGED));
_UpdateFontMenu();

BMenu* cursorMenu = fCursorWidthMF->Menu();
BMenuItem* cursorItem = nullptr;
if(preferences->fCursorWidth == UINT8_MAX) {
cursorItem = cursorMenu->FindItem(BLOCK_CURSOR);
} else {
BString label;
label << preferences->fCursorWidth;
cursorItem = cursorMenu->FindItem(label.String());
}
if(cursorItem != nullptr) {
cursorItem->SetMarked(true);
}

SetChecked(fBracesHighlightingCB, preferences->fBracesHighlighting);
SetChecked(fBlockCursorCB, preferences->fUseBlockCursor);
SetChecked(fAttachNewWindowsCB, preferences->fOpenWindowsInStack);
SetChecked(fHighlightTrailingWSCB, preferences->fHighlightTrailingWhitespace);
SetChecked(fTrimTrailingWSOnSaveCB, preferences->fTrimTrailingWhitespaceOnSave);
Expand Down
3 changes: 2 additions & 1 deletion src/preferences/AppPreferencesWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class AppPreferencesWindow : public BWindow {
TOOLBAR = 'tlbr',
TOOLBAR_ICON_SIZE = 'tlis',
FULL_PATH_IN_TITLE = 'fpit',
CURSOR_WIDTH = 'crwd',
BLOCK_CURSOR = 'bloc',
TABS_TO_SPACES = 'ttsp',
TAB_WIDTH = 'tbwd',
Expand Down Expand Up @@ -137,7 +138,7 @@ class AppPreferencesWindow : public BWindow {
BRadioButton* fIndentGuidesLookBothRadio;

BCheckBox* fBracesHighlightingCB;
BCheckBox* fBlockCursorCB;
BMenuField* fCursorWidthMF;

BPopUpMenu* fEditorStyleMenu;
BMenuField* fEditorStyleMF;
Expand Down
6 changes: 3 additions & 3 deletions src/preferences/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Preferences::Load(const char* filename)
fLineLimitColumn = storage.GetUInt32("lineLimitColumn", 80);
fWrapLines = storage.GetBool("wrapLines", false);
fBracesHighlighting = storage.GetBool("bracesHighlighting", true);
fUseBlockCursor = storage.GetBool("useBlockCursor", false);
fCursorWidth = storage.GetUInt8("cursorWidth", 1);
fFullPathInTitle = storage.GetBool("fullPathInTitle", true);
fCompactLangMenu = storage.GetBool("compactLangMenu", true);
fToolbar = storage.GetBool("toolbar", true);
Expand Down Expand Up @@ -148,7 +148,7 @@ Preferences::Save(const char* filename)
storage.AddUInt32("lineLimitColumn", fLineLimitColumn);
storage.AddBool("wrapLines", fWrapLines);
storage.AddBool("bracesHighlighting", fBracesHighlighting);
storage.AddBool("useBlockCursor", fUseBlockCursor);
storage.AddUInt8("cursorWidth", fCursorWidth);
storage.AddBool("fullPathInTitle", fFullPathInTitle);
storage.AddBool("compactLangMenu", fCompactLangMenu);
storage.AddBool("toolbar", fToolbar);
Expand Down Expand Up @@ -193,7 +193,7 @@ Preferences::operator =(Preferences& p)
fLineLimitColumn = p.fLineLimitColumn;
fWrapLines = p.fWrapLines;
fBracesHighlighting = p.fBracesHighlighting;
fUseBlockCursor = p.fUseBlockCursor;
fCursorWidth = p.fCursorWidth;
fFullPathInTitle = p.fFullPathInTitle;
fCompactLangMenu = p.fCompactLangMenu;
fToolbar = p.fToolbar;
Expand Down
2 changes: 1 addition & 1 deletion src/preferences/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Preferences {
uint32 fLineLimitColumn;
bool fWrapLines;
bool fBracesHighlighting;
bool fUseBlockCursor;
uint8 fCursorWidth;
bool fFullPathInTitle;
bool fCompactLangMenu;
bool fToolbar;
Expand Down