├── .editorconfig
├── .gitignore
├── CHANGELOG.md
├── Koder.rdef
├── LICENSE
├── Makefile
├── README.md
├── artwork
├── Bookmark_next.iom
├── Bookmark_prev.iom
├── Bookmarks.iom
├── Find.iom
├── Koder.iom
├── Koder.png
├── Koder_icon_64.png
├── Open_file.iom
├── Preferences.iom
├── Redo.iom
├── Reload.iom
├── Save_file.iom
├── Save_file_as.iom
├── Softwrap_off.iom
├── Softwrap_on.iom
├── Undo.iom
├── Whitespaces_off.iom
└── Whitespaces_on.iom
├── data
├── languages.yaml
├── languages
│ ├── awk.yaml
│ ├── bash.yaml
│ ├── c.yaml
│ ├── cmake.yaml
│ ├── cpp.yaml
│ ├── css.yaml
│ ├── diff.yaml
│ ├── gdscript.yaml
│ ├── html.yaml
│ ├── jam.yaml
│ ├── javascript.yaml
│ ├── lua.yaml
│ ├── makefile.yaml
│ ├── markdown.yaml
│ ├── ocaml.yaml
│ ├── perl.yaml
│ ├── php.yaml
│ ├── python.yaml
│ ├── rdef.yaml
│ ├── recipe.yaml
│ ├── ruby.yaml
│ ├── rust.yaml
│ ├── text.yaml
│ ├── xml.yaml
│ ├── yab.yaml
│ └── yaml.yaml
└── styles
│ ├── dark.yaml
│ ├── default.yaml
│ ├── dimmed.yaml
│ ├── mono.yaml
│ └── purpleriot.yaml
├── locales
├── ca.catkeys
├── de.catkeys
├── el.catkeys
├── en.catkeys
├── en_AU.catkeys
├── en_GB.catkeys
├── es.catkeys
├── es_419.catkeys
├── fi.catkeys
├── fr.catkeys
├── fur.catkeys
├── hu.catkeys
├── id.catkeys
├── it.catkeys
├── ja.catkeys
├── lt.catkeys
├── nl.catkeys
├── pl.catkeys
├── pt.catkeys
├── ro.catkeys
├── ru.catkeys
├── sv.catkeys
├── tr.catkeys
├── uk.catkeys
└── zh_Hans.catkeys
├── src
├── App.cpp
├── App.h
├── bookmarks
│ ├── BookmarksListView.cpp
│ ├── BookmarksListView.h
│ ├── BookmarksWindow.cpp
│ └── BookmarksWindow.h
├── controls
│ ├── StatusView.cpp
│ ├── StatusView.h
│ ├── ToolBar.cpp
│ └── ToolBar.h
├── editor
│ ├── Editor.cpp
│ ├── Editor.h
│ ├── EditorStatusView.cpp
│ ├── EditorStatusView.h
│ ├── EditorWindow.cpp
│ ├── EditorWindow.h
│ ├── FindReplaceHandler.cpp
│ ├── FindReplaceHandler.h
│ ├── GoToLineWindow.cpp
│ ├── GoToLineWindow.h
│ ├── QuitAlert.cpp
│ └── QuitAlert.h
├── find
│ ├── FindScintillaView.cpp
│ ├── FindScintillaView.h
│ ├── FindStatusView.cpp
│ ├── FindStatusView.h
│ ├── FindWindow.cpp
│ └── FindWindow.h
├── main.cpp
├── preferences
│ ├── AppPreferencesWindow.cpp
│ ├── AppPreferencesWindow.h
│ ├── Preferences.cpp
│ └── Preferences.h
└── support
│ ├── Editorconfig.cpp
│ ├── Editorconfig.h
│ ├── File.cpp
│ ├── File.h
│ ├── Languages.cpp
│ ├── Languages.h
│ ├── ScintillaUtils.h
│ ├── Styler.cpp
│ ├── Styler.h
│ ├── Utils.cpp
│ └── Utils.h
└── test
├── TestFindReplace.cpp
├── TestUtils.cpp
└── main.cpp
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*]
2 | indent_size = 4
3 |
4 | [*.yaml]
5 | indent_style = space
6 |
7 | [*.{h,cpp,c}]
8 | indent_style = tab
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 | *.obj
6 |
7 | # Precompiled Headers
8 | *.gch
9 | *.pch
10 |
11 | # Compiled Dynamic libraries
12 | *.so
13 | *.dylib
14 | *.dll
15 |
16 | # Fortran module files
17 | *.mod
18 |
19 | # Compiled Static libraries
20 | *.lai
21 | *.la
22 | *.a
23 | *.lib
24 |
25 | # Executables
26 | *.exe
27 | *.out
28 | *.app
29 |
30 | objects.*/
31 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 0.7.0 - TBD
4 |
5 | ## [0.6.0] - 2023-05-14
6 |
7 | * Add Find/Replace history.
8 | * Add --wait switch to block when used from command line.
9 | * Make Find/Replace field follow system colors.
10 | * Reworked Find/Replace logic to be more robust and bug-free.
11 | * Fix crash when URL is passed as file argument.
12 | * Add support for Lua.
13 | * Fix context menu position.
14 | * Add "Open recent" menu.
15 | * Fix Esc key not closing Find/Replace window.
16 | * Change selection highlight to be more consistent with the OS.
17 | * Fix hardcoded sizes for views dependent on scroll bar size (HiDPI awareness).
18 |
19 | ## [0.5.4] - 2021-10-10
20 |
21 | * Update translations.
22 |
23 | ## [0.5.3] - 2020-06-27
24 |
25 | * Fix crash on nested brackets in .editorconfig file.
26 | * Update translations.
27 |
28 | ## [0.5.2] - 2020-01-08
29 |
30 | * Fix crash when opening Preferences.
31 | * Fix garbage button text in file modified warning.
32 |
33 | ## [0.5.1] - 2019-05-11
34 |
35 | * Fix crash when external lexer is not found.
36 | * Enable folding for Python.
37 | * Fix crash when invoking incremental search twice.
38 | * Fix read-only detection for volumes mounted as read-only.
39 | * Highlight syntax for the entire file on language change.
40 |
41 | ## [0.5.0] - 2019-04-01
42 |
43 | * Make preferences update automatically.
44 | * Add Open Terminal shortcut.
45 | * Update line number margin on preferences change.
46 | * Add support for loading external lexers.
47 | * Add support for Jamfile, HaikuPorts recipe, YAB, RDef and Markdown.
48 | * Remove read-only warning when opening a file.
49 | * Fix automatic color updates for status bar.
50 | * Highlight system constants in C++ mode.
51 | * Change fold markers and highlight active folding block.
52 | * Fix save and reload toolbar buttons state after external modification and file removal.
53 | * Add bookmarks support.
54 | * Add settings for margin visibility.
55 | * Hide fold margin if folding is not enabled.
56 | * Fixed caret position resetting when corresponding file was opened.
57 | * Add option to automatically insert new line at the end on save.
58 | * Add option to change toolbar icon size.
59 | * Backup files before saving.
60 | * Fix window resizing after changing toolbar visibility.
61 | * Fix fold margin not appearing on language change.
62 | * Fix observing wrong file after Save as operation.
63 | * Fix opening non-existent files.
64 | * Make sure caret is in top quarter of the view when opening a file.
65 | * Add two new themes by Mikael Konradsson and dimmed theme by Humdinger.
66 |
67 | ## [0.4.1] - 2018-11-23
68 |
69 | * Fix crash in incremental search.
70 | * Fix saving of Spaces per tab setting.
71 |
72 | ## [0.4.0] - 2018-10-07
73 |
74 | * Find/Replace window can be closed with Esc now.
75 | * Fix for saving preferences.
76 | * Save Find window settings.
77 | * Limited .editorconfig support.
78 | * Stack all windows besides those from Tracker.
79 | * Add status bar.
80 | * Add dark theme by Mikael Konradsson.
81 | * Add support for HTML, CSS, JavaScript, PHP and OCaml.
82 | * Change styling system to make creating new themes easier.
83 | * Add quick search shortcuts.
84 | * Implement incremental search.
85 | * Fix horizontal scroll bar range.
86 | * Add setting for line highlighting mode.
87 | * Add option to always open files in new windows.
88 | * Add option to change font.
89 |
90 | ## [0.3.0] - 2018-03-20
91 |
92 | * New icon.
93 | * Add right-click menu.
94 | * Disable menu items according to editor state.
95 | * Fix multiple language entries in Language menu.
96 | * Show alert if styles not found.
97 | * Change shortcut for Go to line.
98 | * Add View->Wrap lines.
99 | * Add File->Reload.
100 | * Add tooltips to toolbar buttons.
101 | * Add option to attach windows to existing ones.
102 | * Cascade windows if necessary.
103 | * Open files in the same window only if it is new window and has not been modified.
104 | * Add option to highlight trailing whitespace.
105 | * Add option to trim trailing whitespace.
106 | * Add option to trim trailing whitespace automatically on save.
107 | * Use multiline controls in Find window.
108 | * Add support for regex in Find/Replace.
109 | * Fix keyboard navigation in Find/Replace.
110 | * Rearrange Find/Replace window interface.
111 | * Add "Open corresponding file" option.
112 | * Fix opening files from command line.
113 |
114 | ## [0.2.0] - 2017-04-15
115 |
116 | * Add icon.
117 | * Add translations.
118 | * Adjust whitespace size.
119 | * Fix crash when changing git branches with a file open.
120 | * Fix horizontal scrollbar on long lines.
121 | * Recolor the document on language change.
122 | * Handle drag and drop message.
123 | * Add jumping to specific position in file from command line. Handle parameters from /bin/open.
124 | * Add comment line/block feature.
125 | * Add indent guides highlighting.
126 | * Add editor style menu to preferences.
127 | * Add toolbar.
128 | * Put selection in Find window automatically.
129 | * Add AWK, Perl, Ruby and Rust support.
130 |
131 | ## [0.1.0] - 2017-01-01
132 |
133 | * Initial release.
134 |
135 | [0.5.1]: https://github.com/KapiX/Koder/releases/tag/0.5.1
136 | [0.5.0]: https://github.com/KapiX/Koder/releases/tag/0.5.0
137 | [0.4.1]: https://github.com/KapiX/Koder/releases/tag/0.4.1
138 | [0.4.0]: https://github.com/KapiX/Koder/releases/tag/0.4.0
139 | [0.3.0]: https://github.com/KapiX/Koder/releases/tag/0.3.0
140 | [0.2.0]: https://github.com/KapiX/Koder/releases/tag/0.2.0
141 | [0.1.0]: https://github.com/KapiX/Koder/releases/tag/0.1.0
142 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2014-2017 Kacper Kasper
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | ## Haiku Generic Makefile v2.6 ##
2 |
3 | NAME = Koder
4 | TYPE = APP
5 | APP_MIME_SIG = x-vnd.KapiX-Koder
6 |
7 | SRCS = \
8 | src/main.cpp \
9 | src/App.cpp \
10 | $(wildcard src/bookmarks/*.cpp) \
11 | $(wildcard src/controls/*.cpp) \
12 | $(wildcard src/editor/*.cpp) \
13 | $(wildcard src/find/*.cpp) \
14 | $(wildcard src/preferences/*.cpp) \
15 | $(wildcard src/support/*.cpp) \
16 |
17 | RDEFS = Koder.rdef
18 | LIBS = be tracker shared localestub scintilla yaml-cpp $(STDCPPLIBS)
19 |
20 | LIBPATHS = $(shell findpaths -e -a $(shell uname -p) B_FIND_PATH_DEVELOP_LIB_DIRECTORY)
21 | SYSTEM_INCLUDE_PATHS = \
22 | $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/interface) \
23 | $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/shared) \
24 | $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/storage) \
25 | $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/tracker) \
26 | $(shell findpaths -e -a $(shell uname -p) B_FIND_PATH_HEADERS_DIRECTORY scintilla) \
27 | $(shell findpaths -e -a $(shell uname -p) B_FIND_PATH_HEADERS_DIRECTORY lexilla)
28 |
29 | LOCAL_INCLUDE_PATHS = src/bookmarks src/controls src/editor src/find \
30 | src/preferences src/support
31 | LOCALES = ca de el en en_AU en_GB es es_419 fr fur hu it ja nl pl pt ro ru sv tr uk zh_Hans
32 |
33 | SYMBOLS := TRUE
34 | DEBUGGER := TRUE
35 | # -gno-column-info is a workaround for Debugger issue (#15159)
36 | COMPILER_FLAGS = -gno-column-info -std=c++17 -Werror
37 |
38 | ## Include the Makefile-Engine
39 | DEVEL_DIRECTORY := \
40 | $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY)
41 | include $(DEVEL_DIRECTORY)/etc/makefile-engine
42 |
43 | # TESTS
44 |
45 | TEST_DIR := test
46 |
47 | $(OBJ_DIR)/$(TEST_DIR)-%.o : $(TEST_DIR)/%.cpp
48 | $(C++) -c $< $(INCLUDES) $(CFLAGS) -o "$@"
49 |
50 | TEST_SRCS = \
51 | main.cpp \
52 | TestUtils.cpp \
53 | TestFindReplace.cpp
54 |
55 | TEST_OBJECTS = $(addprefix $(OBJ_DIR)/test-, $(addsuffix .o, $(foreach file, \
56 | $(TEST_SRCS), $(basename $(notdir $(file))))))
57 |
58 | TEST_TARGET = $(TARGET_DIR)/$(NAME)_tests
59 |
60 | TEST_BASE_OBJS = $(filter-out $(OBJ_DIR)/main.o,$(OBJS))
61 |
62 | $(TEST_TARGET): $(TEST_BASE_OBJS) $(TEST_OBJECTS)
63 | $(LD) -o "$@" $(TEST_BASE_OBJS) $(TEST_OBJECTS) $(LDFLAGS) -lgtest
64 |
65 | check : $(TEST_TARGET)
66 | $(TEST_TARGET)
67 |
68 | check-debug : $(TEST_TARGET)
69 | Debugger $(TEST_TARGET)
70 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # **** Koder
2 |
3 | Koder is a code editor built using Scintilla editing component.
4 |
5 | 
6 |
7 | ## Dependencies
8 |
9 | * Scintilla >= 5.1.4
10 | * Lexilla
11 | * yaml-cpp
12 | * [Additional lexers](https://github.com/KapiX/scintilla-haiku-lexers) for Haiku specific file types
13 | * GTest (to run the tests)
14 |
15 | ## Building
16 |
17 | Koder uses makefile_engine. Invoke make in root directory.
18 |
19 | ## Installation
20 |
21 | Copy all files from **data** directory to **Koder** directory in any non-packaged/data folder.
22 |
23 | ## Running tests
24 |
25 | ```
26 | make check
27 | ```
28 |
29 | ## Contributing
30 |
31 | This project follows Haiku coding guidelines (more or less).
32 |
33 | When implementing new features, bear in mind that Koder is an editor and not an IDE. A good benchmark for new features is whether it works on a file or a group of files. In Koder 1 window = 1 file.
34 |
35 | That being said, creating interfaces to talk with an IDE is fine. This approach comes from Haiku philosophy of having small programs doing one thing and talking to each other. Like in Unix, but with GUI.
36 |
37 | ## [Changelog](CHANGELOG.md)
38 |
39 | ## Release checklist
40 |
41 | - [ ] Check if all unit tests pass.
42 | - [ ] Update translations and credits in About window
43 | - [ ] Update README, changelog and screenshot
44 | - [ ] Create release branch
45 | - [ ] In release branch:
46 | - [ ] Change release date in changelog
47 | - [ ] Disable debug and symbols in makefile
48 | - [ ] Change version to final in rdef
49 | - [ ] Commit "Release {version}"
50 | - [ ] Create tag and a release
51 | - [ ] In master branch:
52 | - [ ] Change release date in changelog and add a new version
53 | - [ ] Bump version in rdef
54 | - [ ] Commit "Bump to {next-version}-dev"
55 |
--------------------------------------------------------------------------------
/artwork/Bookmark_next.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Bookmark_next.iom
--------------------------------------------------------------------------------
/artwork/Bookmark_prev.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Bookmark_prev.iom
--------------------------------------------------------------------------------
/artwork/Bookmarks.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Bookmarks.iom
--------------------------------------------------------------------------------
/artwork/Find.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Find.iom
--------------------------------------------------------------------------------
/artwork/Koder.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Koder.iom
--------------------------------------------------------------------------------
/artwork/Koder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Koder.png
--------------------------------------------------------------------------------
/artwork/Koder_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Koder_icon_64.png
--------------------------------------------------------------------------------
/artwork/Open_file.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Open_file.iom
--------------------------------------------------------------------------------
/artwork/Preferences.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Preferences.iom
--------------------------------------------------------------------------------
/artwork/Redo.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Redo.iom
--------------------------------------------------------------------------------
/artwork/Reload.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Reload.iom
--------------------------------------------------------------------------------
/artwork/Save_file.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Save_file.iom
--------------------------------------------------------------------------------
/artwork/Save_file_as.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Save_file_as.iom
--------------------------------------------------------------------------------
/artwork/Softwrap_off.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Softwrap_off.iom
--------------------------------------------------------------------------------
/artwork/Softwrap_on.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Softwrap_on.iom
--------------------------------------------------------------------------------
/artwork/Undo.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Undo.iom
--------------------------------------------------------------------------------
/artwork/Whitespaces_off.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Whitespaces_off.iom
--------------------------------------------------------------------------------
/artwork/Whitespaces_on.iom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KapiX/Koder/9646ed2c88a01abba5f122c2bfb8d0c3fd57a370/artwork/Whitespaces_on.iom
--------------------------------------------------------------------------------
/data/languages.yaml:
--------------------------------------------------------------------------------
1 | text:
2 | name: Text file
3 | extensions: [ txt ]
4 | awk:
5 | name: AWK
6 | extensions: [ awk ]
7 | bash:
8 | name: Bash
9 | extensions: [ sh, bash, bsh, csh, ksh, configure ]
10 | c:
11 | name: C
12 | extensions: [ c ]
13 | cmake:
14 | name: CMake
15 | extensions: [ cmake, CMakeLists.txt, CMakeCache.txt ]
16 | cpp:
17 | name: C++
18 | extensions: [ cc, cpp, cxx, h, hh, hpp, hxx, dox ]
19 | css:
20 | name: CSS
21 | extensions: [ css ]
22 | diff:
23 | name: Diff
24 | extensions: [ diff, patch, patchset ]
25 | gdscript:
26 | name: GDScript
27 | extensions: [ gd ]
28 | html:
29 | name: HTML
30 | extensions: [ html, htm, shtml, shtm, xhtml, xht, hta ]
31 | jam:
32 | name: Jam
33 | extensions: [ Jamfile, Jamrules, Jambase ]
34 | javascript:
35 | name: JavaScript
36 | extensions: [ js, jsm, json ]
37 | lua:
38 | name: Lua
39 | extensions: [ lua ]
40 | makefile:
41 | name: Makefile
42 | extensions: [ mk, mak, Makefile, Makefile.am, makefile ]
43 | markdown:
44 | name: Markdown
45 | extensions: [ md, markdown ]
46 | ocaml:
47 | name: OCaml
48 | extensions: [ ml, mli, sml, thy ]
49 | perl:
50 | name: Perl
51 | extensions: [ pl, pm, pod ]
52 | php:
53 | name: PHP
54 | extensions: [ php, php3, php4, php5, phps, phpt, phtml ]
55 | python:
56 | name: Python
57 | extensions: [ py, pyw ]
58 | rdef:
59 | name: RDef
60 | extensions: [ rdef ]
61 | recipe:
62 | name: Recipe
63 | extensions: [ recipe ]
64 | ruby:
65 | name: Ruby
66 | extensions: [ rb, rbw, rake, rjs, Rakefile ]
67 | rust:
68 | name: Rust
69 | extensions: [ rs ]
70 | yab:
71 | name: YAB
72 | extensions: [ yab ]
73 | xml:
74 | name: XML
75 | extensions: [ xml, xaml, xsl, xslt, xsd, xul, kml, svg, mxml, xsml, wsdl,
76 | xlf, xliff, xbl, sxbl, pimx, config, vsixmanifest, manifest,
77 | proj, csproj, vbproj, fsproj, vcproj, vcxproj, nproj, pyproj,
78 | javaproj, wixproj, filters, settings, testsettings, vsmdi,
79 | ruleset, rules, targets, props, vsprops, propdesc, resx,
80 | rdlc rdl swidtag gml gtt gpx ]
81 | yaml:
82 | name: YAML
83 | extensions: [ yml, yaml ]
84 |
--------------------------------------------------------------------------------
/data/languages/awk.yaml:
--------------------------------------------------------------------------------
1 | # AWK
2 | # adapted from SciTE
3 | lexer: perl
4 | keywords:
5 | 0: >
6 | BEGIN END
7 | if else while do for in break continue delete exit function return
8 | print printf sprintf
9 | system close getline next nextfile fflush
10 | atan2 cos exp int log rand sin sqrt srand
11 | asort asorti gensub sub gsub index length match split
12 | strtonum substr tolower toupper
13 | mktime strftime systime
14 | and compl lshift or rshift xor
15 | bindtextdomain dcgettext dcngettext
16 | ARGC ARGIND ARGV BINMODE CONVFMT ENVIRON ERRNO FIELDWIDTHS
17 | FILENAME FNR FS IGNORECASE LINT NF NR OFMT OFS ORS PROCINFO
18 | RS RT RSTART RLENGTH SUBSEP TEXTDOMAIN
19 | comments:
20 | line: "#"
21 | styles:
22 | 0: 32
23 | 1: 148
24 | 4: 104
25 | 5: 105
26 | 6: 106
27 | 7: 113
28 | 10: 32
29 | 17: 114
30 | 2: 101
31 | 8: 32
32 | 12: 152
33 | 13: 152
34 | 14: 103
35 | 15: 113
36 | 3: 32
37 | 19: 32
38 | 9: 109
39 | 20: 32
40 | 21: 113
41 | 18: 103
42 |
--------------------------------------------------------------------------------
/data/languages/bash.yaml:
--------------------------------------------------------------------------------
1 | # Bash
2 | lexer: bash
3 | properties:
4 | fold: 1
5 | fold.comment: 1
6 | keywords:
7 | 0: >
8 | alias ar asa awk banner basename bash bc bdiff break bunzip2 bzip2 cal
9 | calendar case cat cc cd chmod cksum clear cmp col comm compress continue
10 | cp cpio crypt csplit ctags cut date dc dd declare deroff dev df diff
11 | diff3 dircmp dirname do done du echo ed egrep elif else env esac eval
12 | ex exec exit expand export expr false fc fgrep fi file find fmt fold
13 | for function functions getarch getconf getopt getopts grep gres hash
14 | head help history iconv id if in integer jobs join kill local lc let
15 | line ln logname look ls m4 mail mailx make man mkdir more mt mv newgrp
16 | nl nm nohup ntps od pack paste patch pathchk pax pcat perl pg pr print
17 | printf ps pwd read readonly red return rev rm rmdir sed select set
18 | setarch sh shift size sleep sort spell split start stop strings strip
19 | stty sum suspend sync tail tar tee test then time times touch tr trap
20 | true tsort tty type typeset ulimit umask unalias uname uncompress
21 | unexpand uniq unpack unset until uudecode uuencode vi vim vpax wait wc
22 | whence which while who wpaste wstart xargs zcat
23 | comments:
24 | line: "#"
25 | styles:
26 | 0: 32
27 | 1: 148
28 | 3: 104
29 | 4: 105
30 | 5: 106
31 | 6: 106
32 | 7: 110
33 | 8: 32
34 | 9: 152
35 | 2: 101
36 | 10: 152
37 | 11: 151
38 | 12: 113
39 | 13: 113
40 |
--------------------------------------------------------------------------------
/data/languages/c.yaml:
--------------------------------------------------------------------------------
1 | # C
2 | lexer: cpp
3 | properties:
4 | fold: 1
5 | lexer.cpp.track.preprocessor: 0
6 | styling.within.preprocessor: 1
7 | keywords:
8 | 0: if else switch case default break goto return for while do continue typedef sizeof NULL
9 | 1: void struct union enum char short int long double float signed unsigned const static extern auto register volatile
10 | comments:
11 | line: //
12 | block: [ "/*", "*/" ]
13 | styles:
14 | 11: 32
15 | 10: 110
16 | 6: 106
17 | 7: 106
18 | 4: 104
19 | 5: 105
20 | 16: 105
21 | 1: 101
22 | 2: 101
23 | 3: 103
24 | 15: 103
25 | 17: 117
26 | 18: 117
27 | 19: 119
28 | 13: 113
29 | 14: 114
30 | 9: 109
31 |
--------------------------------------------------------------------------------
/data/languages/cmake.yaml:
--------------------------------------------------------------------------------
1 | # CMake
2 | lexer: cmake
3 | keywords:
4 | 0: add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library add_subdirectory add_test aux_source_directory build_command build_name cmake_minimum_required configure_file create_test_sourcelist else elseif enable_language enable_testing endforeach endif endmacro endwhile exec_program execute_process export_library_dependencies file find_file find_library find_package find_path find_program fltk_wrap_ui foreach get_cmake_property get_directory_property get_filename_component get_source_file_property get_target_property get_test_property if include include_directories include_external_msproject include_regular_expression install install_files install_programs install_targets link_directories link_libraries list load_cache load_command macro make_directory mark_as_advanced math message option output_required_files project qt_wrap_cpp qt_wrap_ui remove remove_definitions separate_arguments set set_directory_properties set_source_files_properties set_target_properties set_tests_properties site_name source_group string subdir_depends subdirs target_link_libraries try_compile try_run use_mangled_mesa utility_source variable_requires vtk_make_instantiator vtk_wrap_java vtk_wrap_python vtk_wrap_tcl while write_file
5 | 1: ABSOLUTE ABSTRACT ADDITIONAL_MAKE_CLEAN_FILES ALL AND APPEND ARGS ASCII BEFORE CACHE CACHE_VARIABLES CLEAR COMMAND COMMANDS COMMAND_NAME COMMENT COMPARE COMPILE_FLAGS COPYONLY DEFINED DEFINE_SYMBOL DEPENDS DOC EQUAL ESCAPE_QUOTES EXCLUDE EXCLUDE_FROM_ALL EXISTS EXPORT_MACRO EXT EXTRA_INCLUDE FATAL_ERROR FILE FILES FORCE FUNCTION GENERATED GLOB GLOB_RECURSE GREATER GROUP_SIZE HEADER_FILE_ONLY HEADER_LOCATION IMMEDIATE INCLUDES INCLUDE_DIRECTORIES INCLUDE_INTERNALS INCLUDE_REGULAR_EXPRESSION LESS LINK_DIRECTORIES LINK_FLAGS LOCATION MACOSX_BUNDLE MACROS MAIN_DEPENDENCY MAKE_DIRECTORY MATCH MATCHALL MATCHES MODULE NAME NAME_WE NOT NOTEQUAL NO_SYSTEM_PATH OBJECT_DEPENDS OPTIONAL OR OUTPUT OUTPUT_VARIABLE PATH PATHS POST_BUILD POST_INSTALL_SCRIPT PREFIX PREORDER PRE_BUILD PRE_INSTALL_SCRIPT PRE_LINK PROGRAM PROGRAM_ARGS PROPERTIES QUIET RANGE READ REGEX REGULAR_EXPRESSION REPLACE REQUIRED RETURN_VALUE RUNTIME_DIRECTORY SEND_ERROR SHARED SOURCES STATIC STATUS STREQUAL STRGREATER STRLESS SUFFIX TARGET TOLOWER TOUPPER VAR VARIABLES VERSION WIN32 WRAP_EXCLUDE WRITE APPLE MINGW MSYS CYGWIN BORLAND WATCOM MSVC MSVC_IDE MSVC60 MSVC70 MSVC71 MSVC80 CMAKE_COMPILER_2005 OFF ON HAIKU
6 | comments:
7 | line: "#"
8 | styles:
9 | 0: 32
10 | 1: 101
11 | 2: 106
12 | 3: 153
13 | 4: 154
14 | 5: 105
15 | 6: 152
16 | 7: 152
17 | 8: 113
18 | 9: 105
19 | 10: 105
20 | 11: 105
21 | 12: 117
22 | 13: 152
23 | 14: 104
24 |
--------------------------------------------------------------------------------
/data/languages/css.yaml:
--------------------------------------------------------------------------------
1 | # CSS
2 | lexer: css
3 | properties:
4 | keywords:
5 | 0: >
6 | background background-attachment background-color background-image
7 | background-position background-repeat border border-bottom
8 | border-bottom-width border-color border-left border-left-width
9 | border-right border-right-width border-style border-top
10 | border-top-width border-width clear color display float font
11 | font-family font-size font-style font-variant font-weight height
12 | letter-spacing line-height list-style list-style-image
13 | list-style-position list-style-type margin margin-bottom margin-left
14 | margin-right margin-top padding padding-bottom padding-left
15 | padding-right padding-top text-align text-decoration text-indent
16 | text-transform vertical-align white-space width word-spacing
17 | 1: >
18 | active checked disabled empty enabled first-child first-of-type focus
19 | hover in-range invalid lang last-child last-of-type link not nth-child
20 | nth-last-child nth-last-of-type nth-of-type only-of-type only-child
21 | optional out-of-range read-only read-write required root target valid
22 | visited
23 | 2: >
24 | azimuth border-bottom-color border-bottom-style border-collapse
25 | border-left-color border-left-style border-right-color
26 | border-right-style border-spacing border-top-color border-top-style
27 | bottom caption-side clip content counter-increment counter-reset cue
28 | cue-after cue-before cursor direction elevation empty-cells inline-table
29 | left ltr max-height max-width min-height min-width orphans outline
30 | outline-color outline-style outline-width overflow page-break-after
31 | page-break-before page-break-inside pause pause-after pause-before
32 | pitch pitch-range play-during position quotes richness right rtl
33 | speak speak-header speak-numeral speak-punctuation speech-rate stress
34 | table table-caption table-cell table-layout top unicode-bidi visibility
35 | voice-family volume widows z-index
36 | 3: >
37 | align-content align-items align-self animation animation-delay
38 | animation-direction animation-duration animation-fill-mode
39 | animation-iteration-count animation-name animation-play-state
40 | animation-timing-function backface-visibility background-clip
41 | background-origin background-size border-bottom-left-radius
42 | border-bottom-right-radius border-image border-image-outset
43 | border-image-repeat border-image-slice border-image-source
44 | border-image-width border-radius border-top-left-radius
45 | border-top-right-radius box-shadow box-sizing column-count column-fill
46 | column-gap column-rule column-rule-color column-rule-style
47 | column-rule-width column-span column-width columns flex flex-basis
48 | flex-direction flex-flow flex-grow flex-shrink flex-wrap
49 | font-size-adjust font-stretch justify-content opacity order
50 | outline-offset overflow-x overflow-y perspective perspective-origin
51 | resize tab-size text-align-last text-decoration-color
52 | text-decoration-line text-decoration-style text-justify
53 | text-overflow text-shadow transform transform-origin
54 | transform-style transition transition-delay transition-duration
55 | transition-property transition-timing-function word-break word-wrap
56 | 4: >
57 | after before first-letter first-line selection
58 | comments:
59 | block: [ "/*", "*/" ]
60 | styles:
61 | 0: 32
62 | 1: 155
63 | 2: 155
64 | 3: 155
65 | 4: 32
66 | 5: 32
67 | 6: 156
68 | 15: 156
69 | 17: 156
70 | 7: 32
71 | 8: 32
72 | 9: 101
73 | 10: 32
74 | 11: 148
75 | 12: 117
76 |
--------------------------------------------------------------------------------
/data/languages/diff.yaml:
--------------------------------------------------------------------------------
1 | # Diff
2 | lexer: diff
3 | styles:
4 | 0: 32
5 | 1: 101
6 | 2: 105
7 | 3: 152
8 | 4: 109
9 | 5: 165
10 | 6: 166
11 |
--------------------------------------------------------------------------------
/data/languages/html.yaml:
--------------------------------------------------------------------------------
1 | # HTML
2 | lexer: hypertext
3 | properties:
4 | fold: 1
5 | fold.html: 1
6 | keywords:
7 | 0: >
8 | a abbr acronym address applet area article aside audio b base basefont
9 | bdi bdo big blockquote body br button canvas caption center cite code
10 | col colgroup datalist dd del details dfn dialog dir div dl dt em embed
11 | fieldset figcaption figure font footer form frame frameset h1 h2 h3 h4
12 | h5 h6 head header hr html i iframe img input ins kbd keygen label legend
13 | li link main map mark menu menuitem meta meter nav noframes noscript
14 | object ol optgroup option output p param picture pre progress q rp rt
15 | ruby s samp script section select small source span strike strong style
16 | sub summary sup table tbody td textarea tfoot th thead time title tr
17 | track tt u ul var video wbr
18 | 1: >
19 | abstract arguments await boolean break byte case catch char class const
20 | continue debugger default delete do double else enum eval export extends
21 | false final finally float for function goto if implements import in
22 | instanceof int interface let long native new null package private
23 | protected public return short static super switch synchronized this
24 | throw throws transient true try typeof var void volatile while with
25 | yield
26 | 4: >
27 | __CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__
28 | __NAMESPACE__ __TRAIT__ __halt_compiler
29 | abstract and array as break callable case catch class
30 | clone const continue declare default die do echo else elseif empty
31 | enddeclare endfor endforeach endif endswitch endwhile eval exit extends
32 | final for foreach function global goto if implements include
33 | include_once instanceof insteadof interface isset list namespace new or
34 | parent print private protected public require require_once return self
35 | static switch throw trait try unset use var while xor
36 | comments:
37 | block: [ "" ]
38 | styles:
39 | 0: 32
40 | 12: 155
41 | 13: 155
42 | 9: 101
43 | 5: 104
44 | 6: 106
45 | 7: 106
46 | 1: 155
47 | 11: 155
48 | 2: 32
49 | 3: 156
50 | 4: 32
51 | 21: 161
52 | 17: 32
53 | 19: 32
54 | 10: 106
55 | 18: 117
56 | # JavaScript
57 | 41: 32
58 | 42: 101
59 | 43: 101
60 | 44: 103
61 | 45: 104
62 | 46: 32
63 | 47: 105
64 | 48: 106
65 | 49: 106
66 | 50: 32
67 | 51: 106
68 | 52: 114
69 | # PHP
70 | 118: 32
71 | 119: 106
72 | 126: 32
73 | 120: 106
74 | 121: 105
75 | 122: 104
76 | 123: 152
77 | 124: 101
78 | 125: 101
79 | 127: 32
80 |
--------------------------------------------------------------------------------
/data/languages/jam.yaml:
--------------------------------------------------------------------------------
1 | lexer: jam
2 | properties:
3 | fold: 1
4 | fold.comment: 1
5 | keywords:
6 | 0: >
7 | actions bind break case continue default else existing for if ignore in
8 | include jumptoeof local maxline on piecemeal quietly return rule switch
9 | together updated while
10 | identifiers:
11 | 6:
12 | - >
13 | As Bulk Cc C++ Clean File Fortran GenFile HardLink HdrRule
14 | InstallInto InstallBin InstallLib InstallFile InstallMan
15 | InstallShell Lex Library LibraryFromObjects LinkLibraries LocalClean
16 | LocalDepends Main MainFromObjects MakeLocate MkDir Object
17 | ObjectCcFlags ObjectC++Flags ObjectHdrs Objects RmTemps Setuid
18 | SoftLink SubDir SubDirCcFlags SubDirC++Flags SubDirHdrs SubInclude
19 | Shell Undefines UserObject Yacc
20 | FAppendSuffix FDirName FGrist FGristFiles FGristSourceFiles
21 | FIsPrefix FStripCommon FReverse FRelPath FSubDir
22 | Always Depends Echo Exit Includes NoCare NoUpdate NotFile Temporary
23 | comments:
24 | line: "#"
25 | styles:
26 | 0: 32
27 | 1: 101
28 | 2: 104
29 | 3: 106
30 | 4: 105
31 | 5: 110
32 | 6: 32
33 | 7: 152
34 | substyles:
35 | 6: [ 120 ]
36 |
--------------------------------------------------------------------------------
/data/languages/javascript.yaml:
--------------------------------------------------------------------------------
1 | # JavaScript
2 | lexer: cpp
3 | properties:
4 | fold: 1
5 | keywords:
6 | 0: >
7 | abstract arguments await boolean break byte case catch char class const
8 | continue debugger default delete do double else enum eval export extends
9 | false final finally float for function goto if implements import in
10 | instanceof int interface let long native new null package private
11 | protected public return short static super switch synchronized this
12 | throw throws transient true try typeof var void volatile while with
13 | yield
14 | comments:
15 | line: "//"
16 | block: [ "/*", "*/" ]
17 | styles:
18 | 11: 32
19 | 10: 32
20 | 6: 106
21 | 7: 106
22 | 4: 104
23 | 5: 105
24 | 16: 105
25 | 1: 101
26 | 2: 101
27 | 3: 103
28 | 15: 103
29 | 17: 117
30 | 18: 117
31 | 19: 119
32 | 13: 113
33 | 14: 114
34 | 9: 109
35 | 12: 106
36 |
--------------------------------------------------------------------------------
/data/languages/lua.yaml:
--------------------------------------------------------------------------------
1 | # Lua
2 | lexer: lua
3 | properties:
4 | fold: 1
5 | keywords:
6 | 0: >
7 | and break do else elseif end false for function if in local nil not or
8 | repeat return then true until while
9 | 1: >
10 | assert collectgarbage dofile error _G getfenv getmetatable ipairs load
11 | loadfile loadstring next pairs pcall print rawequal rawget rawset select
12 | setfenv setmetatable tonumber tostring type unpack _VERSION xpcall
13 | 2: >
14 | string.byte string.char string.dump string.find string.format
15 | string.gmatch string.gsub string.len string.lower string.match
16 | string.rep string.reverse string.sub string.upper
17 | table.concat table.insert table.maxn table.remove table.sort
18 | math.abs math.acos math.asin math.atan math.atan2 math.ceil math.cos
19 | math.cosh math.deg math.exp math.floor math.fmod math.frexp math.huge
20 | math.ldexp math.log math.log10 math.max math.min math.modf math.pi
21 | math.pow math.rad math.random math.randomseed math.sin math.sinh
22 | math.sqrt math.tan math.tanh
23 | 3: >
24 | coroutine.create coroutine.resume coroutine.running coroutine.status
25 | coroutine.wrap coroutine.yield
26 | io.close io.flush io.input io.lines io.open io.output io.popen io.read
27 | io.tmpfile io.type io.write
28 | os.clock os.date os.difftime os.execute os.exit os.getenv os.remove
29 | os.rename os.setlocale os.time os.tmpname
30 | comments:
31 | line: "--"
32 | block: [ "--[[", "]]" ]
33 | styles:
34 | 0: 32
35 | 1: 101
36 | 2: 101
37 | 3: 103
38 | 4: 104
39 | 5: 105
40 | 6: 106
41 | 7: 106
42 | 8: 106
43 | 9: 109
44 | 10: 110
45 | 11: 32
46 | 13: 120
47 | 14: 119
48 | 15: 121
49 | 20: 32
50 |
--------------------------------------------------------------------------------
/data/languages/makefile.yaml:
--------------------------------------------------------------------------------
1 | # Makefile
2 | lexer: makefile
3 | comments:
4 | line: "#"
5 | styles:
6 | 0: 32
7 | 1: 101
8 | 2: 109
9 | 3: 152
10 | 4: 32
11 | 5: 103
12 | 9: 32
13 |
--------------------------------------------------------------------------------
/data/languages/markdown.yaml:
--------------------------------------------------------------------------------
1 | # Markdown
2 | lexer: markdown
3 | styles:
4 | 0: 32
5 | 1: 32
6 | 2: 200
7 | 3: 200
8 | 4: 201
9 | 5: 201
10 | 6: 105
11 | 7: 105
12 | 8: 105
13 | 9: 105
14 | 10: 105
15 | 11: 105
16 | 12: 110
17 | 13: 110
18 | 14: 110
19 | 15: 104
20 | 16: 165
21 | 17: 110
22 | 18: 121
23 | 19: 106
24 | 20: 106
25 | 21: 106
26 |
--------------------------------------------------------------------------------
/data/languages/ocaml.yaml:
--------------------------------------------------------------------------------
1 | # OCaml
2 | lexer: caml
3 | keywords:
4 | 0: >
5 | and as assert begin class constraint do done downto else end exception
6 | external false for fun function functor if in include inherit
7 | initializer lazy let match method module mutable new object of open or
8 | private rec sig struct then to true try type val virtual when while with
9 | 1: >
10 | option Some None ignore ref lnot succ pred
11 | 2: >
12 | array bool char float int list string unit
13 | comments:
14 | block: [ "(*", "*)" ]
15 | styles:
16 | 0: 32
17 | 1: 32
18 | 2: 32
19 | 3: 105
20 | 4: 105
21 | 5: 105
22 | 6: 113
23 | 7: 32
24 | 8: 104
25 | 9: 106
26 | #10:
27 | 11: 106
28 | 12: 101
29 | 13: 101
30 | 14: 103
31 | 15: 103
32 |
--------------------------------------------------------------------------------
/data/languages/perl.yaml:
--------------------------------------------------------------------------------
1 | # Perl
2 | # adapted from SciTE
3 | lexer: perl
4 | keywords:
5 | 0: >
6 | NULL __FILE__ __LINE__ __PACKAGE__ __DATA__ __END__ AUTOLOAD
7 | BEGIN CORE DESTROY END EQ GE GT INIT LE LT NE CHECK abs accept
8 | alarm and atan2 bind binmode bless caller chdir chmod chomp chop
9 | chown chr chroot close closedir cmp connect continue cos crypt
10 | dbmclose dbmopen defined delete die do dump each else elsif endgrent
11 | endhostent endnetent endprotoent endpwent endservent eof eq eval
12 | exec exists exit exp fcntl fileno flock for foreach fork format
13 | formline ge getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname
14 | gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername
15 | getpgrp getppid getpriority getprotobyname getprotobynumber getprotoent
16 | getpwent getpwnam getpwuid getservbyname getservbyport getservent
17 | getsockname getsockopt glob gmtime goto grep gt hex if index
18 | int ioctl join keys kill last lc lcfirst le length link listen
19 | local localtime lock log lstat lt map mkdir msgctl msgget msgrcv
20 | msgsnd my ne next no not oct open opendir or ord our pack package
21 | pipe pop pos print printf prototype push quotemeta qu
22 | rand read readdir readline readlink readpipe recv redo
23 | ref rename require reset return reverse rewinddir rindex rmdir
24 | scalar seek seekdir select semctl semget semop send setgrent
25 | sethostent setnetent setpgrp setpriority setprotoent setpwent
26 | setservent setsockopt shift shmctl shmget shmread shmwrite shutdown
27 | sin sleep socket socketpair sort splice split sprintf sqrt srand
28 | stat study sub substr symlink syscall sysopen sysread sysseek
29 | system syswrite tell telldir tie tied time times truncate
30 | uc ucfirst umask undef unless unlink unpack unshift untie until
31 | use utime values vec wait waitpid wantarray warn while write
32 | xor
33 | given when default break say state UNITCHECK __SUB__ fc
34 | comments:
35 | line: "#"
36 | styles:
37 | 0: 32
38 | 1: 148
39 | 4: 104
40 | 5: 105
41 | 6: 106
42 | 7: 126
43 | 10: 32
44 | 17: 114
45 | 2: 101
46 | 8: 32
47 | 12: 152
48 | 13: 152
49 | 14: 103
50 | 15: 113
51 | 3: 32
52 | 19: 32
53 | 9: 109
54 | 20: 32
55 | 21: 113
56 | 18: 103
57 |
--------------------------------------------------------------------------------
/data/languages/php.yaml:
--------------------------------------------------------------------------------
1 | # PHP
2 | lexer: phpscript
3 | keywords:
4 | 4: >
5 | __CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__
6 | __NAMESPACE__ __TRAIT__ __halt_compiler
7 | abstract and array as break callable case catch class
8 | clone const continue declare default die do echo else elseif empty
9 | enddeclare endfor endforeach endif endswitch endwhile eval exit extends
10 | final for foreach function global goto if implements include
11 | include_once instanceof insteadof interface isset list namespace new or
12 | parent print private protected public require require_once return self
13 | static switch throw trait try unset use var while xor
14 | comments:
15 | line: "//"
16 | block: [ "/*", "*/" ]
17 | styles:
18 | 18: 117
19 | 118: 32
20 | 119: 106
21 | 126: 32
22 | 120: 106
23 | 121: 105
24 | 122: 104
25 | 123: 152
26 | 124: 101
27 | 125: 101
28 | 127: 32
29 |
--------------------------------------------------------------------------------
/data/languages/python.yaml:
--------------------------------------------------------------------------------
1 | # Python
2 | lexer: python
3 | properties:
4 | fold: 1
5 | keywords:
6 | 0: and as assert break class continue def del elif else except exec False finally for from global if import in is lambda None not or pass print raise return triple True try while with yield
7 | comments:
8 | line: "#"
9 | styles:
10 | 0: 32
11 | 1: 101
12 | 2: 104
13 | 3: 106
14 | 4: 106
15 | 5: 105
16 | 6: 126
17 | 7: 32
18 | 8: 32
19 | 9: 129
20 | 10: 32
21 | 11: 32
22 | 12: 101
23 | 13: 106
24 | 14: 32
25 | 15: 135
26 |
--------------------------------------------------------------------------------
/data/languages/rdef.yaml:
--------------------------------------------------------------------------------
1 | # RDef
2 | lexer: cpp
3 | properties:
4 | fold: 1
5 | keywords:
6 | 0: resource
7 | 1: vector_icon message array
8 | identifiers:
9 | 11:
10 | - >
11 | app_signature app_name_catalog_entry app_flags app_version
12 | file_types major middle minor variety internal short_info long_info
13 | - >
14 | B_SINGLE_LAUNCH B_EXCLUSIVE_LAUNCH B_MULTIPLE_LAUNCH
15 | B_APPV_DEVELOPMENT B_APPV_ALPHA B_APPV_BETA B_APPV_GAMMA
16 | B_APPV_GOLDEN_MASTER B_APPV_FINAL
17 | comments:
18 | line: //
19 | block: [ "/*", "*/" ]
20 | styles:
21 | 11: 32
22 | 10: 110
23 | 6: 106
24 | 7: 106
25 | 4: 104
26 | 5: 105
27 | 16: 105
28 | 1: 101
29 | 2: 101
30 | 3: 103
31 | 15: 103
32 | 17: 117
33 | 18: 117
34 | 19: 119
35 | 13: 113
36 | 14: 114
37 | 9: 109
38 | substyles:
39 | 11: [ 119, 120 ]
40 |
--------------------------------------------------------------------------------
/data/languages/recipe.yaml:
--------------------------------------------------------------------------------
1 | lexer: bash
2 | properties:
3 | fold: 1
4 | fold.comment: 1
5 | keywords:
6 | 0: >
7 | alias ar asa awk banner basename bash bc bdiff break bunzip2 bzip2 cal
8 | calendar case cat cc cd chmod cksum clear cmp col comm compress continue
9 | cp cpio crypt csplit ctags cut date dc dd declare deroff dev df diff
10 | diff3 dircmp dirname do done du echo ed egrep elif else env esac eval
11 | ex exec exit expand export expr false fc fgrep fi file find fmt fold
12 | for function functions getarch getconf getopt getopts grep gres hash
13 | head help history iconv id if in integer jobs join kill local lc let
14 | line ln logname look ls m4 mail mailx make man mkdir more mt mv newgrp
15 | nl nm nohup ntps od pack paste patch pathchk pax pcat perl pg pr print
16 | printf ps pwd read readonly red return rev rm rmdir sed select set
17 | setarch sh shift size sleep sort spell split start stop strings strip
18 | stty sum suspend sync tail tar tee test then time times touch tr trap
19 | true tsort tty type typeset ulimit umask unalias uname uncompress
20 | unexpand uniq unpack unset until uudecode uuencode vi vim vpax wait wc
21 | whence which while who wpaste wstart xargs zcat
22 | identifiers:
23 | 8:
24 | - >
25 | BUILD PATCH INSTALL TEST
26 | ADDITIONAL_FILES ARCHITECTURES BUILD_PACKAGE_ACTIVATION_PHASE
27 | BUILD_PACKAGE_ACTIVATION_FILE BUILD_PREREQUIRES BUILD_REQUIRES
28 | CHECKSUM_SHA256 CHECKSUM_SHA256_2
29 | CHECKSUM_SHA256_3 CHECKSUM_SHA256_4 CHECKSUM_SHA256_5
30 | CHECKSUM_SHA256_6 CHECKSUM_SHA256_7 CHECKSUM_SHA256_8
31 | CHECKSUM_SHA256_9 CONFLICTS COPYRIGHT DESCRIPTION
32 | DISABLE_SOURCE_PACKAGE FRESHENS GLOBAL_WRITABLE_FILES HOMEPAGE
33 | LICENSE MESSAGE PACKAGE_GROUPS PACKAGE_USERS PATCHES
34 | POST_INSTALL_SCRIPTS PROVIDES PROVIDES_devel REPLACES REQUIRES
35 | REQUIRES_devel REVISION SECONDARY_ARCHITECTURES
36 | SOURCE_DIR SOURCE_DIR_2 SOURCE_DIR_3
37 | SOURCE_DIR_4 SOURCE_DIR_5 SOURCE_DIR_6 SOURCE_DIR_7 SOURCE_DIR_8
38 | SOURCE_DIR_9 SOURCE_FILENAME SOURCE_URI SOURCE_URI_2 SOURCE_URI_3
39 | SOURCE_URI_4 SOURCE_URI_5 SOURCE_URI_6 SOURCE_URI_7 SOURCE_URI_8
40 | SOURCE_URI_9 SUMMARY SUPPLEMENTS TEST_REQUIRES USER_SETTINGS_FILES
41 | - >
42 | addAppDeskbarSymlink addPreferencesDeskbarSymlink
43 | addResourcesToBinaries checkedUnmount defineDebugInfoPackage
44 | extractDebugInfo fixDevelopLibDirReferences
45 | fixPkgconfig getPackagePrefix getTargetArchitectureCommand
46 | packageDebugInfos packageEntries prepareInstalledDevelLib
47 | prepareInstalledDevelLibs runConfigure symlinkRelative
48 | updateRevisionVariables
49 | 9:
50 | - >
51 | addOnsDir appsDir binDir buildArchitecture buildMachineTriple
52 | buildMachineTripleAsName configureDirArgs configureDirVariables
53 | crossSysrootDir dataDir dataRootDir debugInfoDir developDir
54 | developDocDir developLibDir docDir documentationDir fontsDir
55 | includeDir infoDir installDestDir isCrossRepository jobArgs
56 | jobs libDir libExecDir localStateDir manDir oldIncludeDir
57 | portBaseDir portDir portFullVersion portName
58 | portPackageLinksDir portRevision portRevisionedName portVersion
59 | portVersionedName postInstallDir preferencesDir prefix
60 | relativDebugInfoDir relativeAddOnsDir relativeAppsDir
61 | relativeBinDir relativeDataDir relativeDataRootDir
62 | relativeDevelopDir relativeDevelopDocDir relativeDevelopLibDir
63 | relativeDocDir relativeDocumentationDir relativeFontsDir
64 | relativeIncludeDir relativeInfoDir relativeLibDir
65 | relativeLibExecDir relativeLocalStateDir relativeManDir
66 | relativeOldIncludeDir relativePostInstallDir
67 | relativePreferencesDir relativeSbinDir relativeSettingsDir
68 | relativeSharedStateDir sbinDir secondaryArchSuffix settingsDir
69 | sharedStateDir sourceDir sourceDir2 sourceDir3 sourceDir4
70 | sourceDir5 sourceDir6 sourceDir7 sourceDir8 sourceDir9
71 | targetArchitecture targetMachineTriple targetMachineTripleAsName
72 | comments:
73 | line: "#"
74 | styles:
75 | 0: 32
76 | 1: 148
77 | 3: 104
78 | 4: 105
79 | 5: 106
80 | 6: 106
81 | 7: 110
82 | 8: 32
83 | 9: 152
84 | 2: 101
85 | 10: 152
86 | 11: 151
87 | 12: 113
88 | 13: 113
89 | substyles:
90 | 8: [ 180, 181 ]
91 | 9: [ 182 ]
92 |
--------------------------------------------------------------------------------
/data/languages/ruby.yaml:
--------------------------------------------------------------------------------
1 | # Ruby
2 | # adapted from SciTE
3 | lexer: ruby
4 | keywords:
5 | 0: >
6 | __FILE__ and def end in or self unless __LINE__ begin \
7 | defined? ensure module redo super until BEGIN break do false next rescue
8 | then when END case else for nil retry true while alias class elsif if
9 | not return undef yield
10 | comments:
11 | line: "#"
12 | styles:
13 | 0: 32
14 | 1: 148
15 | 2: 101
16 | 3: 32
17 | 4: 104
18 | 5: 105
19 | 6: 106
20 | 7: 106
21 | 8: 32
22 | 9: 129
23 | 10: 32
24 | 11: 32
25 | 12: 114
26 | 13: 152
27 | 14: 32
28 | 15: 109
29 | 16: 32
30 | 17: 32
31 | 18: 151
32 | 19: 113
33 | 24: 106
34 | 29: 105
35 |
--------------------------------------------------------------------------------
/data/languages/rust.yaml:
--------------------------------------------------------------------------------
1 | # Rust
2 | # adapted from SciTE
3 | lexer: rust
4 | keywords:
5 | 0: alignof as be box break const continue crate do else enum extern false fn for if impl in let loop match mod mut offsetof once priv proc pub pure ref return self sizeof static struct super trait true type typeof unsafe unsized use virtual while yield
6 | 1: bool char f32 f64 i16 i32 i64 i8 int str u16 u32 u64 u8 uint
7 | 2: Self
8 | comments:
9 | line: "//"
10 | block: [ "/*", "*/" ]
11 | styles:
12 | 0: 32
13 | 19: 109
14 | 20: 148
15 | 6: 105
16 | 7: 105
17 | 8: 105
18 | 9: 105
19 | 10: 105
20 | 11: 105
21 | 12: 105
22 | 5: 104
23 | 13: 106
24 | 14: 106
25 | 21: 106
26 | 22: 106
27 | 15: 106
28 | 23: 105
29 | 16: 32
30 | 18: 126
31 | 1: 101
32 | 2: 101
33 | 3: 103
34 | 4: 103
35 |
--------------------------------------------------------------------------------
/data/languages/text.yaml:
--------------------------------------------------------------------------------
1 | # Text file
2 | lexer: null
3 |
--------------------------------------------------------------------------------
/data/languages/xml.yaml:
--------------------------------------------------------------------------------
1 | # XML
2 | lexer: xml
3 | properties:
4 | fold: 1
5 | fold.html: 1
6 | html.tags.case.sensitive: 1
7 | comments:
8 | block: [ "" ]
9 | styles:
10 | 0: 32
11 | 12: 155
12 | 13: 155
13 | 9: 101
14 | 5: 104
15 | 6: 106
16 | 7: 106
17 | 1: 155
18 | 11: 155
19 | 2: 32
20 | 3: 156
21 | 4: 32
22 | 21: 161
23 | 17: 32
24 |
--------------------------------------------------------------------------------
/data/languages/yab.yaml:
--------------------------------------------------------------------------------
1 | # YAB
2 | lexer: yab
3 | properties:
4 | fold: 1
5 | keywords:
6 | 0: >
7 | and alert arraydim arraysize boxview break button case calendar
8 | checkbox chr$ circle clear clipboard close collapse color colorcontrol
9 | column columnbox compile continue copy count curve dim data date$
10 | default draw dropbox dropzone ellipse else elseif elsif end endif
11 | endsub eof eor error euler execute exit expand export false filepanel
12 | flush for frac getscreen$ glob gosub goto hashmarks hide if image
13 | import inkey$ input instr interrupt ismousein keyboard label layout
14 | left$ len let line listbox load$ local localize log loop lower$ ltrim$
15 | max menu message$ mid$ min mod mouse msg$ new next not on open option or
16 | paste$ pause peek peek$ pi poke popupmenu print printer putscreen
17 | radiobutton ran read reading rect rect redim remove repeat resize
18 | restore return reverse right$ rinstr rtrim$ save$ screen scrollbar seek
19 | select set setup show sig sin sleep slider sort soundplay spincontrol
20 | split split$ splitview sqr sqrt stackview static step str$ sub submenu
21 | subroutine svg switch system system$ tabview tan tell text textcontrol
22 | textedit texturl then time$ token token$ tooltip translate$ treebox
23 | trim$ true until upper$ using val view wait wend while window writing
24 | xor
25 | comments:
26 | line: "#"
27 | styles:
28 | 0: 32
29 | 7: 32
30 | 1: 101
31 | 2: 104
32 | 3: 105
33 | 4: 106
34 | 5: 109
35 | 6: 110
36 | 8: 103
37 |
--------------------------------------------------------------------------------
/data/languages/yaml.yaml:
--------------------------------------------------------------------------------
1 | # YAML
2 | lexer: yaml
3 | comments:
4 | line: "#"
5 | styles:
6 | 0: 32
7 | 1: 101
8 | 2: 32
9 | 3: 105
10 | 4: 104
11 | 5: 145
12 | 6: 32
13 | 7: 106
14 | 8: 148
15 |
--------------------------------------------------------------------------------
/data/styles/dark.yaml:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018 Mikael Konradsson
2 | # MIT licensed
3 |
4 | Global:
5 | Default:
6 | id: 32
7 | foreground: "#FFFCFF"
8 | background: "#282629"
9 | Current line:
10 | background: "#141414"
11 | Whitespace:
12 | foreground: "#66BFFF"
13 | Selected text:
14 | background: "#474247"
15 | Caret:
16 | foreground: "#FF4050"
17 | Edge:
18 | foreground: "#656066"
19 | Fold:
20 | foreground: "#282629"
21 | background: "#474247"
22 | Fold marker:
23 | foreground: "#e4e4e4"
24 | background: "#808080"
25 | Indent guideline:
26 | id: 37
27 | foreground: "#474247"
28 | background: "#474247"
29 | Brace highlight:
30 | id: 34
31 | foreground: "#26C99E"
32 | background: "#282629"
33 | style: [ bold ]
34 | Bad brace:
35 | id: 35
36 | foreground: "#FF4050"
37 | background: "#282629"
38 | style: [ bold ]
39 | Line number:
40 | id: 33
41 | foreground: "#656066"
42 | background: "#212022"
43 | Smart highlight:
44 | background: "#FF4050"
45 | Find mark:
46 | background: "#0000ff"
47 | Incremental highlight:
48 | background: "#00ffff"
49 | Tags match highlight:
50 | background: "#CC78FA"
51 | Tags attributes:
52 | background: "#F553BF"
53 | Bookmark marker:
54 | foreground: "#7694B2"
55 | background: "#7f9fbf"
56 | # C++
57 | Preprocessor:
58 | id: 109
59 | foreground: "#66BFFF"
60 | style: [ bold ]
61 | Keyword:
62 | id: 105
63 | foreground: "#66BFFF"
64 | style: [ bold ]
65 | Number:
66 | id: 104
67 | foreground: "#FFD24A"
68 | String:
69 | id: 106
70 | foreground: "#A4CC35"
71 | Operator:
72 | id: 110
73 | foreground: "#F553BF"
74 | Verbatim:
75 | id: 113
76 | foreground: "#F28144"
77 | Regexp:
78 | id: 114
79 | foreground: "#F28144"
80 | Global class:
81 | id: 119
82 | foreground: "#53A6E1"
83 | Constant:
84 | id: 120
85 | foreground: "#F97C31"
86 | Namespace:
87 | id: 121
88 | foreground: "#FF74F4"
89 | Comment:
90 | id: 101
91 | foreground: "#C1BCC2"
92 | Comment doc:
93 | id: 103
94 | foreground: "#66BFFF"
95 | Comment doc keyword:
96 | id: 117
97 | foreground: "#A45EEC"
98 | style: [ bold ]
99 | # Python/Ruby
100 | Triple:
101 | id: 126
102 | foreground: "#646464"
103 | Defname:
104 | id: 129
105 | foreground: "#66BFFF"
106 | style: [ bold ]
107 | Decorator:
108 | id: 135
109 | foreground: "#F28144"
110 | style: [ italic ]
111 | # YAML
112 | Reference:
113 | id: 145
114 | foreground: "#F28144"
115 | Error:
116 | id: 148
117 | foreground: "#F03E4D"
118 | # AWK/Bash/Diff/Makefile
119 | Backticks:
120 | id: 151
121 | foreground: "#CC78FA"
122 | style: [ bold ]
123 | Scalar/Array/Diff header:
124 | id: 152
125 | foreground: "#F28144"
126 | style: [ italic ]
127 | Recipe env variables:
128 | id: 180
129 | foreground: "#53A6E1"
130 | Recipe shell functions:
131 | id: 181
132 | foreground: "#E05900"
133 | style: [ bold ]
134 | Recipe Scalar:
135 | id: 182
136 | foreground: "#408080"
137 | style: [ italic ]
138 | Deleted:
139 | id: 165
140 | foreground: "#F03E4D"
141 | Added:
142 | id: 166
143 | foreground: "#1FC598"
144 | # CMake
145 | String L:
146 | id: 153
147 | foreground: "#A4CC35"
148 | style: [ italic ]
149 | String R:
150 | id: 154
151 | foreground: "#A4CC35"
152 | style: [ underline ]
153 | # HTML/XML/CSS
154 | Tag Start/End:
155 | id: 155
156 | foreground: "#F28144"
157 | Attribute:
158 | id: 156
159 | foreground: "#26C99E"
160 | SGML default:
161 | id: 161
162 | foreground: "#282629"
163 | background: "#1FC598"
164 |
--------------------------------------------------------------------------------
/data/styles/default.yaml:
--------------------------------------------------------------------------------
1 | # based on Eclipse theme for Notepad++
2 | # Copyright (c) 2009 Fesenko Alexander
3 | # MIT licensed
4 | Global:
5 | Default:
6 | id: 32
7 | foreground: "#000000"
8 | background: "#ffffff"
9 | Current line:
10 | background: "#e8f2fe"
11 | Whitespace:
12 | foreground: "#7f9fbf"
13 | Selected text:
14 | background: "#d4d4d4"
15 | Caret:
16 | foreground: "#000000"
17 | Edge:
18 | foreground: "#7f9fbf"
19 | Fold:
20 | foreground: "#e4e4e4"
21 | background: "#e4e4e4"
22 | Fold marker:
23 | foreground: "#e4e4e4"
24 | background: "#808080"
25 | Indent guideline:
26 | id: 37
27 | foreground: "#c0c0c0"
28 | background: "#ffffff"
29 | Brace highlight:
30 | id: 34
31 | foreground: "#0000ff"
32 | background: "#ffffff"
33 | style: [ bold ]
34 | Bad brace:
35 | id: 35
36 | foreground: "#ff0000"
37 | background: "#ffffff"
38 | style: [ bold ]
39 | Line number:
40 | id: 33
41 | foreground: "#808080"
42 | background: "#e4e4e4"
43 | Smart highlight:
44 | background: "#a3a3a3"
45 | Find mark:
46 | background: "#0000ff"
47 | Incremental highlight:
48 | background: "#00ffff"
49 | Tags match highlight:
50 | background: "#00ffff"
51 | Tags attributes:
52 | background: "#ffffff"
53 | Bookmark marker:
54 | foreground: "#7f9fbf"
55 | background: "#e8f2fe"
56 | # C++
57 | Preprocessor:
58 | id: 109
59 | foreground: "#7f7f9f"
60 | style: [ bold ]
61 | Keyword:
62 | id: 105
63 | foreground: "#7f0055"
64 | style: [ bold ]
65 | Number:
66 | id: 104
67 | foreground: "#af0f91"
68 | String:
69 | id: 106
70 | foreground: "#2a00ff"
71 | Operator:
72 | id: 110
73 | foreground: "#3f5fbf"
74 | Verbatim:
75 | id: 113
76 | foreground: "#646464"
77 | Regexp:
78 | id: 114
79 | foreground: "#646464"
80 | Global class:
81 | id: 119
82 | foreground: "#006600"
83 | Constant:
84 | id: 120
85 | foreground: "#552200"
86 | Namespace:
87 | id: 121
88 | foreground: "#408080"
89 | Comment:
90 | id: 101
91 | foreground: "#557f5f"
92 | Comment doc:
93 | id: 103
94 | foreground: "#3f55bf"
95 | Comment doc keyword:
96 | id: 117
97 | foreground: "#7f9fbf"
98 | style: [ bold ]
99 | # Python/Ruby
100 | Triple:
101 | id: 126
102 | foreground: "#646464"
103 | Defname:
104 | id: 129
105 | foreground: "#3f5fbf"
106 | style: [ bold ]
107 | Decorator:
108 | id: 135
109 | foreground: "#3f5fbf"
110 | style: [ italic ]
111 | # YAML
112 | Reference:
113 | id: 145
114 | foreground: "#3f3fbf"
115 | Error:
116 | id: 148
117 | foreground: "#ff4136"
118 | # AWK/Bash/Diff/Makefile
119 | Backticks:
120 | id: 151
121 | foreground: "#646464"
122 | style: [ bold ]
123 | Scalar/Array/Diff header:
124 | id: 152
125 | foreground: "#0000c0"
126 | style: [ italic ]
127 | Recipe env variables:
128 | id: 180
129 | foreground: "#006600"
130 | Recipe shell functions:
131 | id: 181
132 | foreground: "#552200"
133 | style: [ bold ]
134 | Recipe Scalar:
135 | id: 182
136 | foreground: "#408080"
137 | style: [ italic ]
138 | Deleted:
139 | id: 165
140 | foreground: "#ff4136"
141 | Added:
142 | id: 166
143 | foreground: "#2ecc40"
144 | # CMake
145 | String L:
146 | id: 153
147 | foreground: "#2a00ff"
148 | style: [ italic ]
149 | String R:
150 | id: 154
151 | foreground: "#2a00ff"
152 | style: [ underline ]
153 | # HTML/XML/CSS
154 | Tag Start/End:
155 | id: 155
156 | foreground: "#3f7f7f"
157 | Attribute:
158 | id: 156
159 | foreground: "#7f007f"
160 | SGML default:
161 | id: 161
162 | foreground: "#000000"
163 | background: "#a6caf0"
164 | # Markdown
165 | Strong:
166 | id: 200
167 | style: [ bold ]
168 | Emphasis:
169 | id: 201
170 | style: [ italic ]
--------------------------------------------------------------------------------
/data/styles/dimmed.yaml:
--------------------------------------------------------------------------------
1 | # based on Eclipse theme for Notepad++
2 | # a dimmed version of Koder's default style
3 | # Copyright (c) 2009 Fesenko Alexander
4 | # MIT licensed
5 | Global:
6 | Default:
7 | id: 32
8 | foreground: "#000000"
9 | background: "#EEEEEE"
10 | Current line:
11 | background: "#FFFFFF"
12 | Whitespace:
13 | foreground: "#7f9fbf"
14 | Selected text:
15 | background: "#5EBCFF"
16 | Caret:
17 | foreground: "#000000"
18 | Edge:
19 | foreground: "#7f9fbf"
20 | Fold:
21 | foreground: "#e4e4e4"
22 | background: "#D8D8D8"
23 | Fold marker:
24 | foreground: "#FFFFFF"
25 | background: "#808080"
26 | Indent guideline:
27 | id: 37
28 | foreground: "#c0c0c0"
29 | background: "#ffffff"
30 | Brace highlight:
31 | id: 34
32 | foreground: "#0000ff"
33 | background: "#D8D8D8"
34 | style: [ bold ]
35 | Bad brace:
36 | id: 35
37 | foreground: "#FFFFFF"
38 | background: "#FF0000"
39 | style: [ bold ]
40 | Line number:
41 | id: 33
42 | foreground: "#808080"
43 | background: "#D8D8D8"
44 | Smart highlight:
45 | background: "#a3a3a3"
46 | Find mark:
47 | background: "#0000ff"
48 | Incremental highlight:
49 | background: "#00ffff"
50 | Tags match highlight:
51 | background: "#00ffff"
52 | Tags attributes:
53 | background: "#ffffff"
54 | Bookmark marker:
55 | foreground: "#CCDB52"
56 | background: "#EF2E2E"
57 | # C++
58 | Preprocessor:
59 | id: 109
60 | foreground: "#7f7f9f"
61 | style: [ bold ]
62 | Keyword:
63 | id: 105
64 | foreground: "#EB009D"
65 | style: [ bold ]
66 | Number:
67 | id: 104
68 | foreground: "#D012AC"
69 | String:
70 | id: 106
71 | foreground: "#2a00ff"
72 | Operator:
73 | id: 110
74 | foreground: "#FF1414"
75 | Verbatim:
76 | id: 113
77 | foreground: "#646464"
78 | Regexp:
79 | id: 114
80 | foreground: "#646464"
81 | Global class:
82 | id: 119
83 | foreground: "#00A700"
84 | Constant:
85 | id: 120
86 | foreground: "#DA5700"
87 | Namespace:
88 | id: 121
89 | foreground: "#408080"
90 | Comment:
91 | id: 101
92 | foreground: "#557f5f"
93 | Comment doc:
94 | id: 103
95 | foreground: "#3f55bf"
96 | Comment doc keyword:
97 | id: 117
98 | foreground: "#7f9fbf"
99 | style: [ bold ]
100 | # Python/Ruby
101 | Triple:
102 | id: 126
103 | foreground: "#646464"
104 | Defname:
105 | id: 129
106 | foreground: "#3f5fbf"
107 | style: [ bold ]
108 | Decorator:
109 | id: 135
110 | foreground: "#3f5fbf"
111 | style: [ italic ]
112 | # YAML
113 | Reference:
114 | id: 145
115 | foreground: "#3f3fbf"
116 | Error:
117 | id: 148
118 | foreground: "#ff4136"
119 | # AWK/Bash/Diff/Makefile
120 | Backticks:
121 | id: 151
122 | foreground: "#646464"
123 | style: [ bold ]
124 | Scalar/Array/Diff header:
125 | id: 152
126 | foreground: "#0000c0"
127 | style: [ italic ]
128 | Recipe env variables:
129 | id: 180
130 | foreground: "#006600"
131 | Recipe shell functions:
132 | id: 181
133 | foreground: "#552200"
134 | style: [ bold ]
135 | Recipe Scalar:
136 | id: 182
137 | foreground: "#408080"
138 | style: [ italic ]
139 | Deleted:
140 | id: 165
141 | foreground: "#ff4136"
142 | Added:
143 | id: 166
144 | foreground: "#2ecc40"
145 | # CMake
146 | String L:
147 | id: 153
148 | foreground: "#2a00ff"
149 | style: [ italic ]
150 | String R:
151 | id: 154
152 | foreground: "#2a00ff"
153 | style: [ underline ]
154 | # HTML/XML/CSS
155 | Tag Start/End:
156 | id: 155
157 | foreground: "#3f7f7f"
158 | Attribute:
159 | id: 156
160 | foreground: "#7f007f"
161 | SGML default:
162 | id: 161
163 | foreground: "#000000"
164 | background: "#a6caf0"
165 | # Markdown
166 | Strong:
167 | id: 200
168 | style: [ bold ]
169 | Emphasis:
170 | id: 201
171 | style: [ italic ]
172 |
--------------------------------------------------------------------------------
/data/styles/mono.yaml:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018 Mikael Konradsson
2 | # MIT licensed
3 | Global:
4 | Default:
5 | id: 32
6 | foreground: "#474247"
7 | background: "#E0DCE0"
8 | Current line:
9 | background: "#C1BCC2"
10 | Whitespace:
11 | foreground: "#66BFFF"
12 | Selected text:
13 | background: "#FFD24A"
14 | Caret:
15 | foreground: "#FF4050"
16 | Edge:
17 | foreground: "#C1BCC2"
18 | Fold:
19 | foreground: "#C1BCC2"
20 | background: "#C1BCC2"
21 | Indent guideline:
22 | id: 37
23 | foreground: "#C1BCC2"
24 | background: "#C1BCC2"
25 | Brace highlight:
26 | id: 34
27 | foreground: "#26C99E"
28 | background: "#E0DCE0"
29 | style: [ bold ]
30 | Bad brace:
31 | id: 35
32 | foreground: "#FF4050"
33 | background: "#E0DCE0"
34 | style: [ bold ]
35 | Line number:
36 | id: 33
37 | foreground: "#656066"
38 | background: "#E0DCE0"
39 | Smart highlight:
40 | background: "#66BFFF"
41 | Find mark:
42 | background: "#0000ff"
43 | Incremental highlight:
44 | background: "#00ffff"
45 | Tags match highlight:
46 | background: "#CC78FA"
47 | Tags attributes:
48 | background: "#F553BF"
49 | # C++
50 | Preprocessor:
51 | id: 109
52 | foreground: "#656066"
53 | style: [ bold ]
54 | Keyword:
55 | id: 105
56 | foreground: "#282629"
57 | style: [ bold ]
58 | Number:
59 | id: 104
60 | foreground: "#474247"
61 | String:
62 | id: 106
63 | foreground: "#474247"
64 | Operator:
65 | id: 110
66 | foreground: "#474247"
67 | style: [ bold ]
68 | Verbatim:
69 | id: 113
70 | foreground: "#F28144"
71 | Regexp:
72 | id: 114
73 | foreground: "#F28144"
74 | Global class:
75 | id: 119
76 | foreground: "#474247"
77 | Comment:
78 | id: 101
79 | foreground: "#A29DA3"
80 | Comment doc:
81 | id: 103
82 | foreground: "#A29DA3"
83 | Comment doc keyword:
84 | id: 117
85 | foreground: "#A29DA3"
86 | style: [ bold ]
87 | # Python/Ruby
88 | Triple:
89 | id: 126
90 | foreground: "#646464"
91 | Defname:
92 | id: 129
93 | foreground: "#66BFFF"
94 | style: [ bold ]
95 | Decorator:
96 | id: 135
97 | foreground: "#F28144"
98 | style: [ italic ]
99 | # YAML
100 | Reference:
101 | id: 145
102 | foreground: "#F28144"
103 | Error:
104 | id: 148
105 | foreground: "#F03E4D"
106 | # AWK/Bash/Diff/Makefile
107 | Backticks:
108 | id: 151
109 | foreground: "#CC78FA"
110 | style: [ bold ]
111 | Scalar/Array/Diff header:
112 | id: 152
113 | foreground: "#F28144"
114 | style: [ italic ]
115 | Deleted:
116 | id: 165
117 | foreground: "#F03E4D"
118 | Added:
119 | id: 166
120 | foreground: "#1FC598"
121 | # CMake
122 | String L:
123 | id: 153
124 | foreground: "#A4CC35"
125 | style: [ italic ]
126 | String R:
127 | id: 154
128 | foreground: "#A4CC35"
129 | style: [ underline ]
130 | # HTML/XML/CSS
131 | Tag Start/End:
132 | id: 155
133 | foreground: "#F28144"
134 | Attribute:
135 | id: 156
136 | foreground: "#26C99E"
137 | SGML default:
138 | id: 161
139 | foreground: "#282629"
140 |
--------------------------------------------------------------------------------
/data/styles/purpleriot.yaml:
--------------------------------------------------------------------------------
1 | # based on Themer default color scheme
2 | # Copyright (c) 2018 Mikael Konradsson
3 | # with tweaks for languages other than C++ by Kacper Kasper
4 | # MIT licensed
5 | Global:
6 | Default:
7 | id: 32
8 | foreground: "#E0DCE0"
9 | background: "#24003E"
10 | Current line:
11 | background: "#322543"
12 | Whitespace:
13 | foreground: "#66BFFF"
14 | Selected text:
15 | background: "#05000C"
16 | Caret:
17 | foreground: "#FF4050"
18 | Edge:
19 | foreground: "#322543"
20 | Fold:
21 | foreground: "#24003E"
22 | background: "#322543"
23 | Indent guideline:
24 | id: 37
25 | foreground: "#5F2B48"
26 | background: "#24003E"
27 | Brace highlight:
28 | id: 34
29 | foreground: "#26C99E"
30 | background: "#24003E"
31 | style: [ bold ]
32 | Bad brace:
33 | id: 35
34 | foreground: "#FF4050"
35 | background: "#24003E"
36 | style: [ bold ]
37 | Line number:
38 | id: 33
39 | foreground: "#C498EB"
40 | background: "#24003E"
41 | Smart highlight:
42 | background: "#66BFFF"
43 | Find mark:
44 | background: "#F553BF"
45 | Incremental highlight:
46 | background: "#00ffff"
47 | Tags match highlight:
48 | background: "#CC78FA"
49 | Tags attributes:
50 | background: "#F553BF"
51 | # C++
52 | Preprocessor:
53 | id: 109
54 | foreground: "#5F2B48"
55 | style: [ bold ]
56 | Keyword:
57 | id: 105
58 | foreground: "#FFA40B"
59 | style: [ bold ]
60 | Number:
61 | id: 104
62 | foreground: "#FD0B10"
63 | String:
64 | id: 106
65 | foreground: "#C498EB"
66 | Operator:
67 | id: 110
68 | foreground: "#FD3174"
69 | style: [ bold ]
70 | Verbatim:
71 | id: 113
72 | foreground: "#5F2B48"
73 | Regexp:
74 | id: 114
75 | foreground: "#F28144"
76 | Global class:
77 | id: 119
78 | foreground: "#FFA40B"
79 | Comment:
80 | id: 101
81 | foreground: "#A29DA3"
82 | Comment doc:
83 | id: 103
84 | foreground: "#A29DA3"
85 | Comment doc keyword:
86 | id: 117
87 | foreground: "#A29DA3"
88 | style: [ bold ]
89 | # Python/Ruby
90 | Triple:
91 | id: 126
92 | foreground: "#646464"
93 | Defname:
94 | id: 129
95 | foreground: "#66BFFF"
96 | style: [ bold ]
97 | Decorator:
98 | id: 135
99 | foreground: "#F28144"
100 | style: [ italic ]
101 | # YAML
102 | Reference:
103 | id: 145
104 | foreground: "#F28144"
105 | Error:
106 | id: 148
107 | foreground: "#F03E4D"
108 | # AWK/Bash/Diff/Makefile
109 | Backticks:
110 | id: 151
111 | foreground: "#CC78FA"
112 | style: [ bold ]
113 | Scalar/Array/Diff header:
114 | id: 152
115 | foreground: "#F28144"
116 | style: [ italic ]
117 | Deleted:
118 | id: 165
119 | foreground: "#F03E4D"
120 | Added:
121 | id: 166
122 | foreground: "#1FC598"
123 | # CMake
124 | String L:
125 | id: 153
126 | foreground: "#A4CC35"
127 | style: [ italic ]
128 | String R:
129 | id: 154
130 | foreground: "#A4CC35"
131 | style: [ underline ]
132 | # HTML/XML/CSS
133 | Tag Start/End:
134 | id: 155
135 | foreground: "#F28144"
136 | Attribute:
137 | id: 156
138 | foreground: "#26C99E"
139 | SGML default:
140 | id: 161
141 | foreground: "#282629"
142 |
--------------------------------------------------------------------------------
/locales/id.catkeys:
--------------------------------------------------------------------------------
1 | 1 Indonesian x-vnd.KapiX-Koder 822155924
2 | Code editor for Haiku based on Scintilla editing component. App Kode editor untuk Haiku berbasis komponen pengeditan Scintilla.
3 | Distributed on MIT license terms. App Didistribusikan dengan persyaratan lisensi MIT.
4 | Neil Hodgson, for Scintilla editing component and SciTE editor. App Neil Hodgson, untuk komponen pengeditan Scintilla dan editor SciTE.
5 | zuMi, for toolbar icons. App zuMi, untuk ikon bilah-alat.
6 | Konrad77, for dark theme. App Konrad77, untuk tema gelap.
7 | translators to: App to _ (language), e.g. German penerjemah ke:
8 | humdinger, for GUI design tips and artwork. App humdinger, untuk kiat desain GUI dan karya seni.
9 | Background AppPreferencesWindow Latar Belakang
10 | Compact language menu AppPreferencesWindow Menu bahasa yang ringkas
11 | Convert tabs to spaces AppPreferencesWindow Konversikan tab menjadi spasi
12 | Highlight braces AppPreferencesWindow Sorot tanda kurung
13 | Highlight current line AppPreferencesWindow Sorot baris saat ini
14 | Highlight trailing whitespace AppPreferencesWindow Sorot spasi spasi tambahan
15 | Koder preferences AppPreferencesWindow Preferensi Koder
16 | Line AppPreferencesWindow Baris
17 | Mark overly long lines AppPreferencesWindow Mark overly long lines
18 | Max. characters per line: AppPreferencesWindow Max. characters per line:
19 | Only in actually indented lines AppPreferencesWindow Only in actually indented lines
20 | Revert AppPreferencesWindow Revert
21 | Show full path in title AppPreferencesWindow Show full path in title
22 | Show indentation guides AppPreferencesWindow Show indentation guides
23 | Show toolbar AppPreferencesWindow Show toolbar
24 | Spaces per tab: AppPreferencesWindow Spaces per tab:
25 | Stack new windows AppPreferencesWindow Stack new windows
26 | Style AppPreferencesWindow Style
27 | Trim trailing whitespace on save AppPreferencesWindow Trim trailing whitespace on save
28 | Up to the next non-empty line AppPreferencesWindow Up to the next non-empty line
29 | Up to the next/previous non-empty line AppPreferencesWindow Up to the next/previous non-empty line
30 | Behavior AppPreferencesWindow Tingkah laku
31 | Background AppPreferencesWindow Current line highlight Latar Belakang
32 | Frame AppPreferencesWindow Current line highlight Bingkai
33 | Trailing whitespace AppPreferencesWindow Trailing whitespace
34 | Visual AppPreferencesWindow Visual
35 | Indentation AppPreferencesWindow Lekukan
36 | Use .editorconfig if possible AppPreferencesWindow Use .editorconfig if possible
37 | Always open files in new window AppPreferencesWindow Selalu buka file di jendela baru
38 | Use custom font AppPreferencesWindow Use custom font
39 | Folds AppPreferencesWindow Lipat
40 | Gigantic AppPreferencesWindow Toolbar icon size Raksasa
41 | Large AppPreferencesWindow Toolbar icon size Besar
42 | Bookmarks AppPreferencesWindow Tandabuku
43 | Extra large AppPreferencesWindow Toolbar icon size Ekstra besar
44 | Medium AppPreferencesWindow Toolbar icon size Medium
45 | Small AppPreferencesWindow Toolbar icon size Small
46 | Huge AppPreferencesWindow Toolbar icon size Sangat besar
47 | Icon size AppPreferencesWindow Ukuran ikon
48 | Line numbers AppPreferencesWindow Line numbers
49 | Enormous AppPreferencesWindow Toolbar icon size Besar sekali
50 | Left margin AppPreferencesWindow Margin kiri
51 | Ensure empty last line on save AppPreferencesWindow Pastikan baris terakhir kosong saat disimpan
52 | [read-only] EditorWindow [read-only]
53 | About… EditorWindow About…
54 | Access denied EditorWindow Access denied
55 | Cancel EditorWindow Cancel
56 | Close EditorWindow Close
57 | Comment block EditorWindow Comment block
58 | Comment line EditorWindow Comment line
59 | Copy EditorWindow Copy
60 | Cut EditorWindow Cut
61 | Discard EditorWindow Discard
62 | Do nothing EditorWindow Do nothing
63 | Edit EditorWindow Edit
64 | File EditorWindow File
65 | File modified EditorWindow File modified
66 | Find/Replace… EditorWindow Find/Replace…
67 | Go to line… EditorWindow Go to line…
68 | Help EditorWindow Help
69 | Koder preferences… EditorWindow Koder preferences…
70 | Language EditorWindow Language
71 | Line endings EditorWindow Line endings
72 | New EditorWindow New
73 | Old Mac format EditorWindow Old Mac format
74 | Open… EditorWindow Open…
75 | Paste EditorWindow Paste
76 | Quit EditorWindow Quit
77 | Reached the end of the target. No results found. EditorWindow Reached the end of the target. No results found.
78 | Redo EditorWindow Redo
79 | Reload EditorWindow Reload
80 | Replaced {0, plural, one{# occurence} other{# occurences}}. EditorWindow Replaced {0, plural, one{# occurence} other{# occurences}}.
81 | Replacement finished EditorWindow Replacement finished
82 | Save EditorWindow Save
83 | Save as… EditorWindow Save as…
84 | Search EditorWindow Search
85 | Searching finished EditorWindow Searching finished
86 | Select all EditorWindow Select all
87 | Show line endings EditorWindow Show line endings
88 | Show toolbar EditorWindow Show toolbar
89 | Show white space EditorWindow Show white space
90 | Special symbols EditorWindow Special symbols
91 | The file contains unsaved changes, but is read-only. What to do? EditorWindow The file contains unsaved changes, but is read-only. What to do?
92 | The file contains unsaved changes. What to do? EditorWindow The file contains unsaved changes. What to do?
93 | The file has been modified by another application. What to do? EditorWindow The file has been modified by another application. What to do?
94 | Trim trailing whitespace EditorWindow Trim trailing whitespace
95 | Undo EditorWindow Undo
96 | Unix format EditorWindow Unix format
97 | Unsaved changes EditorWindow Unsaved changes
98 | Untitled EditorWindow Untitled
99 | View EditorWindow View
100 | Windows format EditorWindow Windows format
101 | Wrap lines EditorWindow Wrap lines
102 | You don't have sufficient permissions to edit this file. EditorWindow You don't have sufficient permissions to edit this file.
103 | Your changes will be lost. EditorWindow Your changes will be lost.
104 | Find selection EditorWindow Find selection
105 | Find next EditorWindow Find next
106 | Replace and find EditorWindow Replace and find
107 | Incremental search EditorWindow Incremental search
108 | Could not find Open Terminal Tracker add-on. EditorWindow Could not find Open Terminal Tracker add-on.
109 | Toggle bookmark EditorWindow Toggle bookmark
110 | Open Terminal EditorWindow Open Terminal
111 | Next bookmark EditorWindow Next bookmark
112 | Could not launch Open Terminal Tracker add-on. EditorWindow Could not launch Open Terminal Tracker add-on.
113 | File removed EditorWindow File removed
114 | Bookmarks EditorWindow Bookmarks
115 | The file has been removed. What to do? EditorWindow The file has been removed. What to do?
116 | Open partner file EditorWindow Open partner file
117 | Previous bookmark EditorWindow Previous bookmark
118 | Partner file not found. EditorWindow Partner file not found.
119 | Backwards FindWindow Backwards
120 | Find FindWindow Find
121 | Find: FindWindow Find:
122 | Find/Replace FindWindow Find/Replace
123 | In selection FindWindow In selection
124 | Match case FindWindow Match case
125 | Match entire words FindWindow Match entire words
126 | Regex FindWindow Regex
127 | Replace FindWindow Replace
128 | Replace all FindWindow Replace all
129 | Replace and find FindWindow Replace and find
130 | Replace: FindWindow Replace:
131 | Wrap around FindWindow Wrap around
132 | Cancel GoToLineWindow Cancel
133 | Go to line GoToLineWindow Go to line
134 | Go to line: GoToLineWindow Go to line:
135 | OK GoToLineWindow OK
136 | Cancel QuitAlert Cancel
137 | Don't save QuitAlert Don't save
138 | Save all QuitAlert Save all
139 | Save selected QuitAlert Save selected
140 | There are unsaved changes.\nSelect the files to save. QuitAlert There are unsaved changes.\nSelect the files to save.
141 | Unsaved files QuitAlert Unsaved files
142 | 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.
143 | Style files Styler Style files
144 | Koder System name Koder
145 | Access was denied while opening the configuration file. Make sure you have %s% permission for your settings directory. Preferences Access was denied while opening the configuration file. Make sure you have %s% permission for your settings directory.
146 | Editor settings Preferences Editor settings
147 | read Preferences Make sure you have _ permission for read
148 | 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%.
149 | load Preferences to _ the configuration load
150 | Unknown error. Preferences Unknown error.
151 | There is not enough memory available to %s% the configuration file. Try closing a few applications and restart the editor. Preferences There is not enough memory available to %s% the configuration file. Try closing a few applications and restart the editor.
152 | loaded Preferences settings will not be _ loaded
153 | write Preferences Make sure you have _ permission for write
154 | save Preferences to _ the configuration save
155 | saved Preferences settings will not be _ saved
156 | Read-only StatusView Read-only
157 | Open Terminal StatusView Open Terminal
158 | Go to BookmarksListView Go to
159 | Delete BookmarksListView Delete
160 | OK Utilities OK
161 | Bookmarks BookmarksWindow Bookmarks
162 |
--------------------------------------------------------------------------------
/locales/ja.catkeys:
--------------------------------------------------------------------------------
1 | 1 Japanese x-vnd.KapiX-Koder 3251374093
2 | [read-only] EditorWindow [読み取り専用]
3 | EditorWindow <なし>
4 | About… EditorWindow このソフトウェアについて…
5 | Access denied EditorWindow アクセス拒否
6 | Bookmarks EditorWindow ブックマーク
7 | Cancel EditorWindow キャンセル
8 | Close EditorWindow 閉じる
9 | Comment block EditorWindow 現在のブロック
10 | Comment line EditorWindow 現在の行
11 | Copy EditorWindow コピー
12 | Could not find Open Terminal Tracker add-on. EditorWindow Open Terminal Tracker アドオンを見つけられませんでした。
13 | Could not launch Open Terminal Tracker add-on. EditorWindow Open Terminal Tracker アドオンを起動できませんでした。
14 | Cut EditorWindow 切り取り
15 | Discard EditorWindow 破棄
16 | Do nothing EditorWindow 何もしない
17 | Edit EditorWindow 編集
18 | File EditorWindow ファイル
19 | File modified EditorWindow ファイルが編集されました
20 | File removed EditorWindow ファイルが削除されました
21 | Find next EditorWindow 次を検索
22 | Find selection EditorWindow 選択部を検索
23 | Find/Replace… EditorWindow 検索/置換…
24 | Go to line… EditorWindow 行へ移動…
25 | Help EditorWindow ヘルプ
26 | Incremental search EditorWindow インクリメンタルサーチ
27 | Koder preferences… EditorWindow Koder 設定…
28 | Language EditorWindow 言語
29 | Line endings EditorWindow 改行
30 | New EditorWindow 新規
31 | Next bookmark EditorWindow 次のブックマーク
32 | Old Mac format EditorWindow 古い Mac 形式
33 | Open partner file EditorWindow 対応するファイルを開く
34 | Open recent EditorWindow 最近開いたファイル
35 | Open Terminal EditorWindow Open Terminal
36 | Open… EditorWindow 開く…
37 | Partner file not found. EditorWindow 対応するファイルが見つかりませんでした。
38 | Paste EditorWindow 貼り付け
39 | Previous bookmark EditorWindow 前のブックマーク
40 | Quit EditorWindow 終了
41 | Reached the end of the target. No results found. EditorWindow 検索の最後まで達しましたが、見つかりませんでした。
42 | Redo EditorWindow やり直す
43 | Reload EditorWindow 再読み込み
44 | Replace and find EditorWindow 置換と検索
45 | Replaced {0, plural, one{# occurence} other{# occurences}}. EditorWindow {0, plural, one{# 個置換しました} other{# 個置換しました}}.
46 | Replacement finished EditorWindow 置換が終了しました
47 | Save EditorWindow 保存
48 | Save as… EditorWindow 名前を付けて保存…
49 | Search EditorWindow 検索
50 | Searching finished EditorWindow 検索が終了しました
51 | Select all EditorWindow すべてを選択
52 | Show line endings EditorWindow 改行を表示
53 | Show toolbar EditorWindow ツールバーを表示
54 | Show white space EditorWindow 空白文字を表示
55 | Special symbols EditorWindow 特殊記号
56 | The file contains unsaved changes, but is read-only. What to do? EditorWindow ファイルは保存されていない変更を含んでいますが、読み取り専用です。どうしますか?
57 | The file contains unsaved changes. What to do? EditorWindow ファイルは保存されていない変更を含んでいます。どうしますか?
58 | The file has been modified by another application. What to do? EditorWindow ファイルはほかのアプリケーションで変更されています。どうしますか?
59 | The file has been removed. What to do? EditorWindow ファイルは削除されています。どうしますか?
60 | Toggle bookmark EditorWindow ブックマークを切り替え
61 | Trim trailing whitespace EditorWindow 行末の空白文字を削除
62 | Undo EditorWindow 元に戻す
63 | Unix format EditorWindow Unix 形式
64 | Unsaved changes EditorWindow 保存されていない変更
65 | Untitled EditorWindow 無題
66 | View EditorWindow 表示
67 | Windows format EditorWindow Windows 形式
68 | Wrap lines EditorWindow 行を折り返す
69 | You don't have sufficient permissions to edit this file. EditorWindow このファイルを編集する充分な許可がありません。
70 | Your changes will be lost. EditorWindow 変更は失われるでしょう。
71 | FindStatusView <なし>
72 | Clear FindStatusView 消去
73 | History FindStatusView 履歴
74 | Access was denied while opening the configuration file. Make sure you have %s% permission for your settings directory. Preferences 設定ファイルを開く際にアクセスが拒否されました。settings ディレクトリに %s% の許可があるとこを確認してください。
75 | Editor settings Preferences エディター設定
76 | load Preferences to _ the configuration 読み込み
77 | loaded Preferences settings will not be _ 読み込み
78 | read Preferences Make sure you have _ permission for 読み取り
79 | save Preferences to _ the configuration 保存
80 | saved Preferences settings will not be _ 保存
81 | Something wrong has happened while opening the configuration file. Your personal settings will not be %s%. Preferences 設定ファイルを開く際になにか問題が発生しました。ユーザーの個人設定は%s%されません。
82 | There is not enough memory available to %s% the configuration file. Try closing a few applications and restart the editor. Preferences 設定ファイルを%s%するための充分なメモリーがありません。いくつかのアプリケーションを閉じて、エディターを再起動してみてください。
83 | Unknown error. Preferences 不明なエラー。
84 | write Preferences Make sure you have _ permission for 書き込み
85 | Always open files in new window AppPreferencesWindow 常に新しいウィンドウで開く
86 | Background AppPreferencesWindow 背景
87 | Background AppPreferencesWindow Current line highlight 背景
88 | Behavior AppPreferencesWindow 動作
89 | Bookmarks AppPreferencesWindow ブックマーク
90 | Compact language menu AppPreferencesWindow 言語メニューを縮小
91 | Convert tabs to spaces AppPreferencesWindow タブをスペースに変換
92 | Enormous AppPreferencesWindow Toolbar icon size 超巨大
93 | Ensure empty last line on save AppPreferencesWindow 保存時に文末に空行を追加
94 | Extra large AppPreferencesWindow Toolbar icon size 特大
95 | Folds AppPreferencesWindow 折り返し
96 | Frame AppPreferencesWindow Current line highlight フレーム
97 | Gigantic AppPreferencesWindow Toolbar icon size 超々巨大
98 | Highlight braces AppPreferencesWindow 括弧の組を強調
99 | Highlight current line AppPreferencesWindow 現在の行を強調
100 | Highlight trailing whitespace AppPreferencesWindow 行末の空白文字を強調
101 | Huge AppPreferencesWindow Toolbar icon size 巨大
102 | Icon size AppPreferencesWindow アイコンサイズ
103 | Indentation AppPreferencesWindow インデント
104 | Koder preferences AppPreferencesWindow Koder 設定
105 | Large AppPreferencesWindow Toolbar icon size 大
106 | Left margin AppPreferencesWindow 左余白
107 | Line AppPreferencesWindow 線
108 | Line numbers AppPreferencesWindow 行番号
109 | Mark overly long lines AppPreferencesWindow 長い行をマーク
110 | Max. characters per line: AppPreferencesWindow 1 行あたりの最大文字数:
111 | Medium AppPreferencesWindow Toolbar icon size 中
112 | Only in actually indented lines AppPreferencesWindow 実際にインデントしている行のみ
113 | Revert AppPreferencesWindow 取り消す
114 | Show full path in title AppPreferencesWindow タイトルにフルパスを表示
115 | Show indentation guides AppPreferencesWindow インデントガイドを表示
116 | Show toolbar AppPreferencesWindow ツールバーを表示
117 | Small AppPreferencesWindow Toolbar icon size 小
118 | Spaces per tab: AppPreferencesWindow タブあたりのスペース:
119 | Stack new windows AppPreferencesWindow 新規ウィンドウをスタック
120 | Style AppPreferencesWindow スタイル
121 | Trailing whitespace AppPreferencesWindow 行末の空白文字
122 | Trim trailing whitespace on save AppPreferencesWindow 保存時に行末の空白文字を削除
123 | Up to the next non-empty line AppPreferencesWindow 次の空行でない行まで
124 | Up to the next/previous non-empty line AppPreferencesWindow 次/前の空行でない行まで
125 | Use .editorconfig if possible AppPreferencesWindow 可能であれば .editorconfig を使用
126 | Use custom font AppPreferencesWindow カスタムフォントを使う
127 | Visual AppPreferencesWindow ビジュアル
128 | Backwards FindWindow 前方向へ検索
129 | Find FindWindow 検索
130 | Find: FindWindow 検索:
131 | Find/Replace FindWindow 検索/置換
132 | In selection FindWindow 選択範囲を検索
133 | Match case FindWindow 大文字小文字を区別する
134 | Match entire words FindWindow 単語全体に一致
135 | Regex FindWindow 正規表現
136 | Replace FindWindow 置換
137 | Replace all FindWindow すべて置換
138 | Replace and find FindWindow 置換と検索
139 | Replace: FindWindow 置換:
140 | Wrap around FindWindow 折り返し検索
141 | Bookmarks BookmarksWindow ブックマーク
142 | Cancel GoToLineWindow キャンセル
143 | Go to line GoToLineWindow 行へ移動
144 | Go to line: GoToLineWindow 行へ移動:
145 | OK GoToLineWindow OK
146 | Cancel QuitAlert キャンセル
147 | Don't save QuitAlert 保存せずに終了
148 | Save all QuitAlert すべて保存
149 | Save selected QuitAlert 選択したファイルを保存
150 | There are unsaved changes.\nSelect the files to save. QuitAlert 保存されていない変更があります。\n保存するファイルを選んでください。
151 | Unsaved files QuitAlert 保存されていないファイル
152 | Code editor for Haiku based on Scintilla editing component. App Scintilla editing component に基づく Haiku 用コードエディター
153 | Distributed on MIT license terms. App MIT license 条項で配布されます。
154 | humdinger, for GUI design tips and artwork. App humdinger: GUI デザインのヒントとアートワーク
155 | Konrad77, for dark theme. App Konrad77: ダークテーマ
156 | Neil Hodgson, for Scintilla editing component and SciTE editor. App Neil Hodgson: Scintilla editing component と SciTE エディター
157 | translators to: App to _ (language), e.g. German 翻訳:
158 | zuMi, for toolbar icons. App zuMi: ツールバーアイコン
159 | Couldn't find style files. Make sure you have them installed in one of your data directories. Styler スタイルファイルが見つかりません。データディレクトリにそれらがあるか確認してください。
160 | Style files Styler スタイルファイル
161 | Delete BookmarksListView 削除
162 | Go to BookmarksListView 移動
163 | Koder System name Koder
164 | OK Utilities OK
165 | Open Terminal EditorStatusView 端末を開く
166 | Read-only EditorStatusView 読み取り専用
167 |
--------------------------------------------------------------------------------
/locales/zh_Hans.catkeys:
--------------------------------------------------------------------------------
1 | 1 Chinese (simplified) x-vnd.KapiX-Koder 3251374093
2 | [read-only] EditorWindow [只读]
3 | EditorWindow
4 | About… EditorWindow 关于…
5 | Access denied EditorWindow 访问被拒绝
6 | Bookmarks EditorWindow 书签
7 | Cancel EditorWindow 取消
8 | Close EditorWindow 关闭
9 | Comment block EditorWindow 注释块
10 | Comment line EditorWindow 注释行
11 | Copy EditorWindow 复制
12 | Could not find Open Terminal Tracker add-on. EditorWindow 找不到 Open Terminal Tracker 插件。
13 | Could not launch Open Terminal Tracker add-on. EditorWindow 无法启动 Open Terminal Tracker 加载项。
14 | Cut EditorWindow 剪切
15 | Discard EditorWindow 丢弃
16 | Do nothing EditorWindow 不执行任何操作
17 | Edit EditorWindow 编辑
18 | File EditorWindow 文件
19 | File modified EditorWindow 文件已修改
20 | File removed EditorWindow 文件已删除
21 | Find next EditorWindow 查找下一个
22 | Find selection EditorWindow 查找所选内容
23 | Find/Replace… EditorWindow 查找/替换…
24 | Go to line… EditorWindow 转到行…
25 | Help EditorWindow 帮助
26 | Incremental search EditorWindow 增量搜索
27 | Koder preferences… EditorWindow Koder 首选项…
28 | Language EditorWindow 语言
29 | Line endings EditorWindow 行尾
30 | New EditorWindow 新建
31 | Next bookmark EditorWindow 下一个书签
32 | Old Mac format EditorWindow 旧 Mac 格式
33 | Open partner file EditorWindow 打开合作伙伴文件
34 | Open recent EditorWindow 打开最近文件
35 | Open Terminal EditorWindow 打开终端
36 | Open… EditorWindow 打开…
37 | Partner file not found. EditorWindow 没有合作伙伴文件被发现。
38 | Paste EditorWindow 粘贴
39 | Previous bookmark EditorWindow 上一个书签
40 | Quit EditorWindow 退出
41 | Reached the end of the target. No results found. EditorWindow 已抵达目标结尾。没有发现。
42 | Redo EditorWindow 重做
43 | Reload EditorWindow 重新加载
44 | Replace and find EditorWindow 替换并查找
45 | Replaced {0, plural, one{# occurence} other{# occurences}}. EditorWindow 替换了 {0, plural, one{# occurence} other{# occurences}}。
46 | Replacement finished EditorWindow 替换完成
47 | Save EditorWindow 保存
48 | Save as… EditorWindow 另存为…
49 | Search EditorWindow 搜索
50 | Searching finished EditorWindow 搜索完成
51 | Select all EditorWindow 全选
52 | Show line endings EditorWindow 显示行尾
53 | Show toolbar EditorWindow 显示工具栏
54 | Show white space EditorWindow 显示空白
55 | Special symbols EditorWindow 特殊符号
56 | The file contains unsaved changes, but is read-only. What to do? EditorWindow 该文件包含未保存的更改,但为只读。怎么办?
57 | The file contains unsaved changes. What to do? EditorWindow 该文件包含未保存的更改。怎么办?
58 | The file has been modified by another application. What to do? EditorWindow 该文件已被其他应用程序修改。怎么办?
59 | The file has been removed. What to do? EditorWindow 该文件已删除。怎么办?
60 | Toggle bookmark EditorWindow 切换书签
61 | Trim trailing whitespace EditorWindow 修整尾部空白
62 | Undo EditorWindow 撤消
63 | Unix format EditorWindow Unix 格式
64 | Unsaved changes EditorWindow 未保存的更改
65 | Untitled EditorWindow 未命名
66 | View EditorWindow 视图
67 | Windows format EditorWindow Windows 格式
68 | Wrap lines EditorWindow 换行符
69 | You don't have sufficient permissions to edit this file. EditorWindow 您没有足够的权限编辑此文件。
70 | Your changes will be lost. EditorWindow 您的更改将会丢失。
71 | FindStatusView
72 | Clear FindStatusView 清除
73 | History FindStatusView 历史
74 | Access was denied while opening the configuration file. Make sure you have %s% permission for your settings directory. Preferences 打开配置文件时拒绝访问。确保您对设置目录具有 %s% 权限。
75 | Editor settings Preferences 编辑器设置
76 | load Preferences to _ the configuration 加载
77 | loaded Preferences settings will not be _ 已加载
78 | read Preferences Make sure you have _ permission for 读
79 | save Preferences to _ the configuration 保存
80 | saved Preferences settings will not be _ 已保存
81 | Something wrong has happened while opening the configuration file. Your personal settings will not be %s%. Preferences 打开配置文件时出错。您的个人设置将不是 %s% 。
82 | There is not enough memory available to %s% the configuration file. Try closing a few applications and restart the editor. Preferences 内存不足,无法使用 %s% 配置文件。请尝试关闭一些应用程序并重新启动编辑器。
83 | Unknown error. Preferences 未知错误。
84 | write Preferences Make sure you have _ permission for 写
85 | Always open files in new window AppPreferencesWindow 总是在新窗口打开文件
86 | Background AppPreferencesWindow 背景
87 | Background AppPreferencesWindow Current line highlight 背景
88 | Behavior AppPreferencesWindow 行为
89 | Bookmarks AppPreferencesWindow 书签
90 | Compact language menu AppPreferencesWindow 精简语言菜单
91 | Convert tabs to spaces AppPreferencesWindow 将制表符转换为空格
92 | Enormous AppPreferencesWindow Toolbar icon size 极大
93 | Ensure empty last line on save AppPreferencesWindow 保存时确保最后一行为空
94 | Extra large AppPreferencesWindow Toolbar icon size 较大
95 | Folds AppPreferencesWindow 折叠
96 | Frame AppPreferencesWindow Current line highlight 边框
97 | Gigantic AppPreferencesWindow Toolbar icon size 庞大
98 | Highlight braces AppPreferencesWindow 高亮显示大括号
99 | Highlight current line AppPreferencesWindow 高亮显示当前行
100 | Highlight trailing whitespace AppPreferencesWindow 高亮显示尾随空格
101 | Huge AppPreferencesWindow Toolbar icon size 巨大
102 | Icon size AppPreferencesWindow 图标大小
103 | Indentation AppPreferencesWindow 缩进
104 | Koder preferences AppPreferencesWindow Koder 首选项
105 | Large AppPreferencesWindow Toolbar icon size 大
106 | Left margin AppPreferencesWindow 左页边
107 | Line AppPreferencesWindow 线条
108 | Line numbers AppPreferencesWindow 行号
109 | Mark overly long lines AppPreferencesWindow 标记过长的线条
110 | Max. characters per line: AppPreferencesWindow 每行最大字符数:
111 | Medium AppPreferencesWindow Toolbar icon size 中
112 | Only in actually indented lines AppPreferencesWindow 仅在实际缩进的行中
113 | Revert AppPreferencesWindow 还原
114 | Show full path in title AppPreferencesWindow 在标题中显示完整路径
115 | Show indentation guides AppPreferencesWindow 显示缩进参考线
116 | Show toolbar AppPreferencesWindow 显示工具栏
117 | Small AppPreferencesWindow Toolbar icon size 小
118 | Spaces per tab: AppPreferencesWindow 每个制表符占用空格:
119 | Stack new windows AppPreferencesWindow 堆叠新窗口
120 | Style AppPreferencesWindow 样式
121 | Trailing whitespace AppPreferencesWindow 尾部空格
122 | Trim trailing whitespace on save AppPreferencesWindow 保存时删除尾部空格
123 | Up to the next non-empty line AppPreferencesWindow 直到下一个非空行
124 | Up to the next/previous non-empty line AppPreferencesWindow 直到下一个或上一个非空行
125 | Use .editorconfig if possible AppPreferencesWindow 如果可能,请使用 .editorconfig
126 | Use custom font AppPreferencesWindow 使用自定义字体
127 | Visual AppPreferencesWindow 视觉
128 | Backwards FindWindow 反向
129 | Find FindWindow 查找
130 | Find: FindWindow 查找:
131 | Find/Replace FindWindow 查找/替换
132 | In selection FindWindow 在所选中
133 | Match case FindWindow 区分大小写
134 | Match entire words FindWindow 匹配整个单词
135 | Regex FindWindow 正规表示式
136 | Replace FindWindow 替换
137 | Replace all FindWindow 全部替换
138 | Replace and find FindWindow 替换并查找
139 | Replace: FindWindow 替换:
140 | Wrap around FindWindow 回绕
141 | Bookmarks BookmarksWindow 书签
142 | Cancel GoToLineWindow 取消
143 | Go to line GoToLineWindow 转至行
144 | Go to line: GoToLineWindow 转至行:
145 | OK GoToLineWindow 确定
146 | Cancel QuitAlert 取消
147 | Don't save QuitAlert 不保存
148 | Save all QuitAlert 全部保存
149 | Save selected QuitAlert 保存所选
150 | There are unsaved changes.\nSelect the files to save. QuitAlert 有未保存的更改。\n选择要保存的文件。
151 | Unsaved files QuitAlert 未保存文件
152 | Code editor for Haiku based on Scintilla editing component. App 基于 Scintilla 编辑组件的 Haiku 代码编辑器。
153 | Distributed on MIT license terms. App 根据 MIT 许可条款分发。
154 | humdinger, for GUI design tips and artwork. App humdinger, 贡献 GUI 艺术设计和插画。
155 | Konrad77, for dark theme. App Konrad77, 贡献暗黑主题。
156 | Neil Hodgson, for Scintilla editing component and SciTE editor. App Neil Hodgson, 贡献 Scintilla 编辑组件和 SciTE 编辑器。
157 | translators to: App to _ (language), e.g. German 翻译人员:
158 | zuMi, for toolbar icons. App zuMi, 贡献工具栏图标。
159 | Couldn't find style files. Make sure you have them installed in one of your data directories. Styler 找不到样式文件。请确保已将它们安装在其中一个数据目录中。
160 | Style files Styler 样式文件
161 | Delete BookmarksListView 删除
162 | Go to BookmarksListView 跳转至
163 | Koder System name Koder
164 | OK Utilities 确定
165 | Open Terminal EditorStatusView 打开终端
166 | Read-only EditorStatusView 只读
167 |
--------------------------------------------------------------------------------
/src/App.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #ifndef APP_H
7 | #define APP_H
8 |
9 |
10 | #include
11 |
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 |
19 | class AppPreferencesWindow;
20 | class EditorWindow;
21 | class FindWindow;
22 | class Preferences;
23 | class Styler;
24 |
25 |
26 | enum {
27 | SUPPRESS_INITIAL_WINDOW = 'Siwn',
28 | WINDOW_NEW_WITH_QUIT_REPLY = 'NWwn'
29 | };
30 |
31 |
32 | const BString gAppMime = "application/x-vnd.KapiX-Koder";
33 |
34 |
35 | class App : public BApplication {
36 | public:
37 | App();
38 | ~App();
39 |
40 | void Init();
41 |
42 | void AboutRequested();
43 | bool QuitRequested();
44 | void ReadyToRun();
45 | void ArgvReceived(int32 argc, char** argv);
46 | void RefsReceived(BMessage* message);
47 | void MessageReceived(BMessage* message);
48 |
49 | private:
50 | void _ActivateOrCreateWindow(const BMessage* message,
51 | const entry_ref& ref, const int32 line,
52 | const int32 column,
53 | std::unique_ptr& windowStack);
54 | EditorWindow* _CreateWindow(const BMessage* message,
55 | std::unique_ptr& windowStack);
56 | void _CreateWindowWithQuitReply(BMessage* message,
57 | const entry_ref* ref = nullptr,
58 | const int32 line = -1,
59 | const int32 column = -1);
60 |
61 | BObjectList fWindows;
62 | EditorWindow* fLastActiveWindow;
63 | AppPreferencesWindow* fAppPreferencesWindow;
64 | FindWindow* fFindWindow;
65 | Preferences* fPreferences;
66 | Styler* fStyler;
67 |
68 | BPath fPreferencesFile;
69 | bool fSuppressInitialWindow;
70 | };
71 |
72 |
73 | #endif // APP_H
74 |
--------------------------------------------------------------------------------
/src/bookmarks/BookmarksListView.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 |
7 | #include "BookmarksListView.h"
8 |
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | #include
18 |
19 | #include "BookmarksWindow.h"
20 | #include "GoToLineWindow.h"
21 |
22 |
23 | #undef B_TRANSLATION_CONTEXT
24 | #define B_TRANSLATION_CONTEXT "BookmarksListView"
25 |
26 |
27 | BookmarksListView::BookmarksListView(const char* name)
28 | :
29 | BListView(name)
30 | {
31 | }
32 |
33 |
34 | BookmarksListView::~BookmarksListView()
35 | {
36 | }
37 |
38 |
39 | void
40 | BookmarksListView::AttachedToWindow()
41 | {
42 | SetFlags(Flags() | B_FULL_UPDATE_ON_RESIZE);
43 | }
44 |
45 |
46 | status_t
47 | BookmarksListView::Invoke(BMessage* message)
48 | {
49 | bool notify = false;
50 | uint32 kind = InvokeKind(¬ify);
51 | if(notify)
52 | return BListView::Invoke(message);
53 |
54 | BMessage clone(kind);
55 | if(InvocationMessage() != nullptr)
56 | clone = *InvocationMessage();
57 | int32 index = CurrentSelection();
58 | BookmarkItem* item = static_cast(ItemAt(index));
59 | if(item != nullptr) {
60 | clone.AddInt32("line", item->Line() + 1);
61 | return BListView::Invoke(&clone);
62 | }
63 | return B_BAD_VALUE;
64 | }
65 |
66 |
67 | void
68 | BookmarksListView::MouseDown(BPoint where)
69 | {
70 | BMessage* message = Looper()->CurrentMessage();
71 | int32 buttons = message->GetInt32("buttons", 0);
72 | if((buttons & B_PRIMARY_MOUSE_BUTTON) != 0) {
73 | BListView::MouseDown(where);
74 | } else if((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
75 | Select(IndexOf(where));
76 | _ShowContextMenu(where);
77 | }
78 | }
79 |
80 |
81 | void
82 | BookmarksListView::UpdateBookmarks(const BMessage bookmarks)
83 | {
84 | MakeEmpty();
85 | type_code type;
86 | int32 count;
87 | if(bookmarks.GetInfo("line", &type, &count) == B_OK) {
88 | for(int32 i = 0; i < count; i++) {
89 | int64 line = bookmarks.GetInt64("line", i, -1);
90 | const char* text = bookmarks.GetString("text", i, "");
91 | if(line != -1) {
92 | BListView::AddItem(new BookmarkItem(line, text));
93 | }
94 | }
95 | }
96 | }
97 |
98 |
99 | void
100 | BookmarksListView::_ShowContextMenu(BPoint where)
101 | {
102 | BMessage* gotoMessage = new BMessage(GTLW_GO);
103 | BMessage* deleteMessage = new BMessage(BOOKMARK_REMOVED);
104 | int32 index = CurrentSelection();
105 | BookmarkItem* item = static_cast(ItemAt(index));
106 | if(item != nullptr) {
107 | gotoMessage->AddInt32("line", item->Line() + 1);
108 | deleteMessage->AddInt32("line", item->Line());
109 | }
110 | BPopUpMenu* contextMenu = new BPopUpMenu("ContextMenu", false, false);
111 | BLayoutBuilder::Menu<>(contextMenu)
112 | .AddItem(B_TRANSLATE("Go to"), gotoMessage)
113 | .AddItem(B_TRANSLATE("Delete"), deleteMessage);
114 | contextMenu->SetTargetForItems(Target());
115 | contextMenu->Go(ConvertToScreen(where), true, true);
116 | }
117 |
118 |
119 | BookmarksListView::BookmarkItem::BookmarkItem(int64 line, BString text)
120 | :
121 | BStringItem(text.String()),
122 | fLine(line),
123 | fText(text)
124 | {
125 | }
126 |
127 |
128 | void
129 | BookmarksListView::BookmarkItem::DrawItem(BView* owner, BRect frame, bool complete)
130 | {
131 | rgb_color lowColor = owner->LowColor();
132 |
133 | if (IsSelected() || complete) {
134 | rgb_color color;
135 | if (IsSelected())
136 | color = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR);
137 | else
138 | color = owner->ViewColor();
139 |
140 | owner->SetLowColor(color);
141 | owner->FillRect(frame, B_SOLID_LOW);
142 | } else
143 | owner->SetLowColor(owner->ViewColor());
144 |
145 | owner->MovePenTo(frame.left + be_control_look->DefaultLabelSpacing(),
146 | frame.top + BaselineOffset());
147 |
148 | BString lineStr;
149 | lineStr << fLine + 1;
150 | float lineStrWidth = owner->StringWidth(lineStr.String());
151 | owner->DrawString(lineStr.String());
152 | owner->MovePenBy(lineStrWidth, 0.0f);
153 |
154 | BString textToDraw = fText;
155 | float width = frame.right - owner->PenLocation().x;
156 | owner->TruncateString(&textToDraw, B_TRUNCATE_END, width);
157 | owner->DrawString(textToDraw);
158 |
159 | owner->SetLowColor(lowColor);
160 | }
161 |
162 |
163 | int64
164 | BookmarksListView::BookmarkItem::Line() const
165 | {
166 | return fLine;
167 | }
168 |
--------------------------------------------------------------------------------
/src/bookmarks/BookmarksListView.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 | #ifndef BOOKMARKSLISTVIEW_H
6 | #define BOOKMARKSLISTVIEW_H
7 |
8 |
9 | #include
10 | #include
11 | #include
12 |
13 |
14 | class BookmarksListView : public BListView {
15 | public:
16 | BookmarksListView(const char* name);
17 | ~BookmarksListView();
18 |
19 | void AttachedToWindow();
20 | status_t Invoke(BMessage* message = nullptr);
21 | void MouseDown(BPoint where);
22 |
23 | void UpdateBookmarks(const BMessage bookmarks);
24 | private:
25 | class BookmarkItem : public BStringItem {
26 | public:
27 | BookmarkItem(int64 line, BString text);
28 |
29 | virtual void DrawItem(BView* owner, BRect frame, bool complete = false);
30 |
31 | int64 Line() const;
32 | private:
33 | int64 fLine;
34 | BString fText;
35 | };
36 | void _ShowContextMenu(BPoint where);
37 | };
38 |
39 |
40 | #endif // BOOKMARKSLISTVIEW_H
41 |
--------------------------------------------------------------------------------
/src/bookmarks/BookmarksWindow.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 |
7 | #include "BookmarksWindow.h"
8 |
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | #include
16 |
17 | #include "BookmarksListView.h"
18 | #include "GoToLineWindow.h"
19 |
20 |
21 | #undef B_TRANSLATION_CONTEXT
22 | #define B_TRANSLATION_CONTEXT "BookmarksWindow"
23 |
24 |
25 | class CustomScrollView : public BScrollView {
26 | public:
27 | CustomScrollView(const char* name, BView* target);
28 |
29 | virtual void DoLayout();
30 | };
31 |
32 |
33 | CustomScrollView::CustomScrollView(const char* name, BView* target)
34 | :
35 | BScrollView(name, target, 0, false, true)
36 | {
37 | }
38 |
39 |
40 | void
41 | CustomScrollView::DoLayout()
42 | {
43 | BScrollView::DoLayout();
44 |
45 | BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
46 | scrollBar->ResizeBy(0, 2);
47 | scrollBar->MoveBy(0, -1);
48 | }
49 |
50 |
51 | #pragma mark -
52 |
53 |
54 | BookmarksWindow::BookmarksWindow(BWindow* owner, const BMessage bookmarks)
55 | :
56 | BWindow(BRect(0, 0, 0, 0), B_TRANSLATE("Bookmarks"),
57 | B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, 0),
58 | fOwner(owner)
59 | {
60 | AddToSubset(fOwner);
61 |
62 | fOwner->StartWatching(this, BOOKMARK_ADDED);
63 | fOwner->StartWatching(this, BOOKMARK_REMOVED);
64 | fOwner->StartWatching(this, BOOKMARKS_INVALIDATED);
65 |
66 | BMessage* goToLineMessage = new BMessage(GTLW_GO);
67 | fList = new BookmarksListView("bookmarks list");
68 | fList->SetInvocationMessage(goToLineMessage);
69 | fList->SetTarget(fOwner);
70 | fScroller = new CustomScrollView("bookmarks", fList);
71 | fScroller->SetBorder(B_NO_BORDER);
72 |
73 | BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0);
74 | SetLayout(layout);
75 | layout->AddView(fScroller);
76 | layout->SetInsets(0.f, 0.f, -1.0f, 0.f);
77 |
78 | fList->UpdateBookmarks(bookmarks);
79 |
80 | BRect frame = fOwner->Frame();
81 | BRect decorFrame = fOwner->DecoratorFrame();
82 | float frameThickness = frame.left - decorFrame.left;
83 | MoveTo(frame.left + frame.Width() + frameThickness * 2, frame.top);
84 | ResizeTo(200.0f, fOwner->Bounds().Height());
85 | }
86 |
87 |
88 | BookmarksWindow::~BookmarksWindow()
89 | {
90 | }
91 |
92 |
93 | void
94 | BookmarksWindow::MessageReceived(BMessage* message)
95 | {
96 | switch(message->what) {
97 | case B_OBSERVER_NOTICE_CHANGE: {
98 | int32 what = message->GetInt32("be:observe_change_what", 0);
99 | switch(what) {
100 | case BOOKMARK_ADDED:
101 | case BOOKMARK_REMOVED:
102 | case BOOKMARKS_INVALIDATED: {
103 | fList->UpdateBookmarks(*message);
104 | } break;
105 | }
106 | } break;
107 | default:
108 | BWindow::MessageReceived(message);
109 | break;
110 | }
111 | }
112 |
113 |
114 | void
115 | BookmarksWindow::Quit()
116 | {
117 | fOwner->PostMessage(BOOKMARKS_WINDOW_QUITTING);
118 |
119 | BWindow::Quit();
120 | }
121 |
--------------------------------------------------------------------------------
/src/bookmarks/BookmarksWindow.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 | #ifndef BOOKMARKWINDOW_H
6 | #define BOOKMARKWINDOW_H
7 |
8 |
9 | #include
10 |
11 |
12 | class BScrollView;
13 | class BookmarksListView;
14 |
15 |
16 | enum {
17 | BOOKMARK_ADDED = 'bkma',
18 | BOOKMARK_REMOVED = 'bkmr',
19 | BOOKMARKS_INVALIDATED = 'bkmi',
20 | BOOKMARKS_WINDOW_QUITTING = 'bkqt',
21 | };
22 |
23 |
24 | class BookmarksWindow : public BWindow {
25 | public:
26 | BookmarksWindow(BWindow* owner, const BMessage bookmarks);
27 | ~BookmarksWindow();
28 |
29 | void MessageReceived(BMessage* message);
30 | void Quit();
31 | private:
32 | BScrollView* fScroller;
33 | BookmarksListView* fList;
34 | BWindow* fOwner;
35 | };
36 |
37 |
38 | #endif // BOOKMARKWINDOW_H
39 |
--------------------------------------------------------------------------------
/src/controls/StatusView.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2012, Haiku, Inc. All Rights Reserved.
3 | * Distributed under the terms of the MIT License.
4 | *
5 | * Authors:
6 | * Vlad Slepukhin
7 | * Siarzhuk Zharski
8 | *
9 | * Copied from Haiku commit a609673ce8c942d91e14f24d1d8832951ab27964.
10 | * Modifications:
11 | * Copyright 2018-2019 Kacper Kasper
12 | * Distributed under the terms of the MIT License.
13 | */
14 |
15 |
16 | #include "StatusView.h"
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 |
34 | const float kHorzSpacing = 5.f;
35 |
36 | using namespace BPrivate;
37 |
38 |
39 | namespace controls {
40 |
41 | StatusView::StatusView(BScrollView* scrollView)
42 | :
43 | BView(BRect(), "statusview",
44 | B_FOLLOW_BOTTOM | B_FOLLOW_LEFT, B_WILL_DRAW),
45 | fScrollView(scrollView),
46 | fPreferredSize(0., 0.)
47 | {
48 | scrollView->AddChild(this);
49 | }
50 |
51 |
52 | StatusView::~StatusView()
53 | {
54 | }
55 |
56 |
57 | void
58 | StatusView::AttachedToWindow()
59 | {
60 | BScrollBar* scrollBar = fScrollView->ScrollBar(B_HORIZONTAL);
61 | MoveTo(0., scrollBar->Frame().top);
62 |
63 | SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
64 |
65 | ResizeToPreferred();
66 | }
67 |
68 |
69 | void
70 | StatusView::GetPreferredSize(float* _width, float* _height)
71 | {
72 | _ValidatePreferredSize();
73 |
74 | if (_width)
75 | *_width = fPreferredSize.width;
76 |
77 | if (_height)
78 | *_height = fPreferredSize.height;
79 | }
80 |
81 |
82 | void
83 | StatusView::ResizeToPreferred()
84 | {
85 | float width, height;
86 | GetPreferredSize(&width, &height);
87 |
88 | if (Bounds().Width() > width)
89 | width = Bounds().Width();
90 |
91 | BView::ResizeTo(width, height);
92 | }
93 |
94 |
95 | void
96 | StatusView::WindowActivated(bool active)
97 | {
98 | // Workaround: doesn't redraw automatically
99 | Invalidate();
100 | }
101 |
102 |
103 | BScrollView*
104 | StatusView::ScrollView()
105 | {
106 | return fScrollView;
107 | }
108 |
109 |
110 | void
111 | StatusView::_ValidatePreferredSize()
112 | {
113 | // width
114 | fPreferredSize.width = Width();
115 |
116 | // height
117 | font_height fontHeight;
118 | GetFontHeight(&fontHeight);
119 |
120 | fPreferredSize.height = ceilf(fontHeight.ascent + fontHeight.descent
121 | + fontHeight.leading);
122 |
123 | BScrollBar* scrollBar = fScrollView->ScrollBar(B_HORIZONTAL);
124 | BRect frame = scrollBar->Frame();
125 |
126 | if (fPreferredSize.height < frame.Height() + 1)
127 | fPreferredSize.height = frame.Height() + 1;
128 |
129 | ResizeBy(fPreferredSize.width, 0);
130 | float diff = frame.left - fPreferredSize.width;
131 | if(fabs(diff) > 0.5) {
132 | scrollBar->ResizeBy(diff, 0);
133 | scrollBar->MoveBy(-diff, 0);
134 | }
135 | }
136 |
137 | } // namespace controls
138 |
--------------------------------------------------------------------------------
/src/controls/StatusView.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2012, Haiku, Inc. All Rights Reserved.
3 | * Distributed under the terms of the MIT License.
4 | *
5 | * Authors:
6 | * Vlad Slepukhin
7 | * Siarzhuk Zharski
8 | *
9 | * Copied from Haiku commit a609673ce8c942d91e14f24d1d8832951ab27964.
10 | * Modifications:
11 | * Copyright 2018-2019 Kacper Kasper
12 | * Distributed under the terms of the MIT License.
13 | */
14 | #ifndef STATUS_VIEW_H
15 | #define STATUS_VIEW_H
16 |
17 |
18 | #include
19 | #include
20 | #include
21 |
22 |
23 | class BScrollView;
24 |
25 |
26 | namespace controls {
27 |
28 | class StatusView : public BView {
29 | public:
30 | StatusView(BScrollView* scrollView);
31 | ~StatusView();
32 |
33 | virtual void AttachedToWindow();
34 | virtual void GetPreferredSize(float* _width, float* _height);
35 | virtual void ResizeToPreferred();
36 | virtual void WindowActivated(bool active);
37 |
38 | protected:
39 | virtual float Width() = 0;
40 | BScrollView* ScrollView();
41 |
42 | private:
43 | void _ValidatePreferredSize();
44 |
45 | BScrollView* fScrollView;
46 | BSize fPreferredSize;
47 | };
48 |
49 | } // namespace controls
50 |
51 | #endif // STATUS_VIEW_H
52 |
--------------------------------------------------------------------------------
/src/controls/ToolBar.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | *
5 | * Border drawing code lifted from kits/tracker/Navigator.cpp
6 | * Copyright 2015 John Scipione
7 | */
8 |
9 |
10 | #include "ToolBar.h"
11 |
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | #include "Utils.h"
18 |
19 |
20 | ToolBar::ToolBar(BHandler* defaultTarget)
21 | :
22 | BToolBar(B_HORIZONTAL),
23 | fDefaultTarget(defaultTarget),
24 | fIconSize(24.0f)
25 | {
26 | GroupLayout()->SetInsets(0.0f, 0.0f, B_USE_HALF_ITEM_INSETS, 1.0f);
27 | // 1px bottom inset used for border
28 |
29 | // Needed to draw the bottom border
30 | SetFlags(Flags() | B_WILL_DRAW);
31 | SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
32 | }
33 |
34 |
35 | void
36 | ToolBar::Draw(BRect updateRect)
37 | {
38 | // Draw a 1px bottom border, like BMenuBar
39 | BRect rect(Bounds());
40 | rgb_color base = LowColor();
41 | uint32 flags = 0;
42 |
43 | be_control_look->DrawBorder(this, rect, updateRect, base,
44 | B_PLAIN_BORDER, flags, BControlLook::B_BOTTOM_BORDER);
45 |
46 | BToolBar::Draw(rect & updateRect);
47 | }
48 |
49 |
50 | void
51 | ToolBar::AddAction(uint32 command, const char* toolTipText,
52 | const char* iconName, bool lockable)
53 | {
54 | BBitmap *icon = nullptr;
55 | if(iconName != nullptr) {
56 | icon = new BBitmap(BRect(fIconSize - 1.0f), 0, B_RGBA32);
57 | GetVectorIcon(iconName, icon);
58 | fActionIcons.emplace(std::make_pair(command, iconName));
59 | }
60 | BToolBar::AddAction(command, fDefaultTarget, icon, toolTipText,
61 | nullptr, lockable);
62 | }
63 |
64 |
65 | void
66 | ToolBar::ChangeIconSize(float newSize)
67 | {
68 | fIconSize = newSize;
69 | BBitmap icon(BRect(fIconSize - 1.0f), 0, B_RGBA32);
70 | for(const auto& action : fActionIcons) {
71 | GetVectorIcon(action.second.c_str(), &icon);
72 | BToolBar::FindButton(action.first)->SetIcon(&icon);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/controls/ToolBar.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 | #ifndef TOOLBAR_H
6 | #define TOOLBAR_H
7 |
8 |
9 | #include
10 |
11 | #include
12 | #include
13 |
14 |
15 | class BHandler;
16 |
17 |
18 | class ToolBar : public BPrivate::BToolBar {
19 | public:
20 | ToolBar(BHandler* defaultTarget);
21 |
22 | virtual void Draw(BRect updateRect);
23 |
24 | void AddAction(uint32 command, const char* toolTipText,
25 | const char* iconName = nullptr, bool lockable = false);
26 | void ChangeIconSize(float newSize);
27 |
28 | private:
29 | BHandler* fDefaultTarget;
30 | float fIconSize;
31 | // command, iconName
32 | std::unordered_map fActionIcons;
33 | };
34 |
35 |
36 | #endif // TOOLBAR_H
37 |
--------------------------------------------------------------------------------
/src/editor/Editor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #ifndef EDITOR_H
7 | #define EDITOR_H
8 |
9 |
10 | #include
11 |
12 | #include
13 | #include
14 |
15 | #include
16 | #include
17 | #include
18 |
19 | #include "ScintillaUtils.h"
20 |
21 |
22 | namespace editor {
23 | class StatusView;
24 | }
25 |
26 |
27 | enum {
28 | EDITOR_SAVEPOINT_LEFT = 'svpl',
29 | EDITOR_SAVEPOINT_REACHED = 'svpr',
30 | EDITOR_MODIFIED = 'modi',
31 | EDITOR_CONTEXT_MENU = 'conm',
32 | EDITOR_UPDATEUI = 'updu'
33 | };
34 |
35 |
36 | class Editor : public BScintillaView {
37 | public:
38 | enum Margin {
39 | NUMBER = 0,
40 | FOLD,
41 | BOOKMARKS
42 | };
43 | enum Marker {
44 | BOOKMARK = 0
45 | };
46 | enum Indicator {
47 | WHITESPACE = 0
48 | };
49 |
50 | Editor();
51 |
52 | virtual void DoLayout();
53 | virtual void FrameResized(float width, float height);
54 |
55 | void NotificationReceived(SCNotification* notification);
56 | void ContextMenu(BPoint point);
57 |
58 | void SetType(std::string type);
59 | void SetRef(const entry_ref& ref);
60 | void SetReadOnly(bool readOnly);
61 |
62 | void CommentLine(Scintilla::Range range);
63 | void CommentBlock(Scintilla::Range range);
64 |
65 | void SetCommentLineToken(std::string token);
66 | void SetCommentBlockTokens(std::string start, std::string end);
67 |
68 | bool CanCommentLine();
69 | bool CanCommentBlock();
70 |
71 | void HighlightTrailingWhitespace();
72 | void ClearHighlightedWhitespace();
73 | void TrimTrailingWhitespace();
74 |
75 | void AppendNLAtTheEndIfNotPresent();
76 |
77 | void UpdateLineNumberWidth();
78 |
79 | void GoToLine(int64 line);
80 |
81 | void SetBookmarks(const BMessage &lines);
82 | BMessage Bookmarks();
83 | BMessage BookmarksWithText();
84 |
85 | bool ToggleBookmark(int64 line = -1);
86 | void GoToNextBookmark();
87 | void GoToPreviousBookmark();
88 |
89 | void SetNumberMarginEnabled(bool enabled);
90 | void SetFoldMarginEnabled(bool enabled);
91 | void SetBookmarkMarginEnabled(bool enabled);
92 | void SetBracesHighlightingEnabled(bool enabled);
93 | void SetTrailingWSHighlightingEnabled(bool enabled);
94 |
95 | std::string SelectionText();
96 |
97 | template
98 | typename T::type Get() { return T::Get(this); }
99 | template
100 | void Set(typename T::type value) { T::Set(this, value); }
101 |
102 | private:
103 | void _MaintainIndentation(char ch);
104 | void _UpdateStatusView();
105 | void _BraceHighlight();
106 | bool _BraceMatch(int pos);
107 | void _MarginClick(int margin, int pos);
108 | void _HighlightTrailingWhitespace(Sci_Position start, Sci_Position end);
109 | std::string _LineFeedString(int eolMode);
110 |
111 | void _SetLineIndentation(int line, int indent);
112 |
113 | editor::StatusView* fStatusView;
114 |
115 | std::string fCommentLineToken;
116 | std::string fCommentBlockStartToken;
117 | std::string fCommentBlockEndToken;
118 |
119 | Sci_Position fHighlightedWhitespaceStart;
120 | Sci_Position fHighlightedWhitespaceEnd;
121 | Sci_Position fHighlightedWhitespaceCurrentPos;
122 |
123 | bool fNumberMarginEnabled;
124 | bool fFoldMarginEnabled;
125 | bool fBookmarkMarginEnabled;
126 | bool fBracesHighlightingEnabled;
127 | bool fTrailingWSHighlightingEnabled;
128 |
129 | // needed for StatusView
130 | std::string fType;
131 | bool fReadOnly;
132 | };
133 |
134 |
135 | #endif // EDITOR_H
136 |
--------------------------------------------------------------------------------
/src/editor/EditorStatusView.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2012, Haiku, Inc. All Rights Reserved.
3 | * Distributed under the terms of the MIT License.
4 | *
5 | * Authors:
6 | * Vlad Slepukhin
7 | * Siarzhuk Zharski
8 | *
9 | * Copied from Haiku commit a609673ce8c942d91e14f24d1d8832951ab27964.
10 | * Modifications:
11 | * Copyright 2018-2019 Kacper Kasper
12 | * Distributed under the terms of the MIT License.
13 | */
14 |
15 |
16 | #include "EditorStatusView.h"
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | #include "EditorWindow.h"
34 |
35 |
36 | const float kHorzSpacing = 5.f;
37 |
38 | using namespace BPrivate;
39 |
40 |
41 | #undef B_TRANSLATION_CONTEXT
42 | #define B_TRANSLATION_CONTEXT "EditorStatusView"
43 |
44 | namespace editor {
45 |
46 | StatusView::StatusView(BScrollView* scrollView)
47 | :
48 | controls::StatusView(scrollView),
49 | fReadOnly(false),
50 | fNavigationPressed(false),
51 | fNavigationButtonWidth(scrollView->ScrollBar(B_HORIZONTAL)->Frame().Height())
52 | {
53 | memset(fCellWidth, 0, sizeof(fCellWidth));
54 |
55 | SetFont(be_plain_font);
56 | float fontSize = 10.f * (be_plain_font->Size() / 12.f);
57 | SetFontSize(fontSize);
58 | }
59 |
60 |
61 | StatusView::~StatusView()
62 | {
63 | }
64 |
65 |
66 | void
67 | StatusView::AttachedToWindow()
68 | {
69 | BMessage message(UPDATE_STATUS);
70 | message.AddInt32("line", 1);
71 | message.AddInt32("column", 1);
72 | message.AddString("type", "");
73 | SetStatus(&message);
74 |
75 | controls::StatusView::AttachedToWindow();
76 | }
77 |
78 |
79 | void
80 | StatusView::Draw(BRect updateRect)
81 | {
82 | float width, height;
83 | GetPreferredSize(&width, &height);
84 | if (width <= 0)
85 | return;
86 |
87 | rgb_color highColor = HighColor();
88 | BRect bounds(Bounds());
89 | bounds.bottom = height;
90 | bounds.right = width;
91 | uint32 flags = 0;
92 | if(!Window()->IsActive())
93 | flags |= BControlLook::B_DISABLED;
94 | be_control_look->DrawScrollBarBackground(this, bounds, bounds, ViewColor(),
95 | flags, B_HORIZONTAL);
96 | // DrawScrollBarBackground mutates the rect
97 | bounds.left = 0.0f;
98 |
99 | SetHighColor(tint_color(ViewColor(), B_DARKEN_2_TINT));
100 | StrokeLine(bounds.LeftTop(), bounds.RightTop());
101 |
102 | // Navigation button
103 | BRect navRect(bounds);
104 | navRect.left--;
105 | navRect.right = fNavigationButtonWidth + 1;
106 | StrokeLine(navRect.RightTop(), navRect.RightBottom());
107 | _DrawNavigationButton(navRect);
108 | bounds.left = navRect.right + 1;
109 |
110 | // BControlLook mutates color
111 | SetHighColor(tint_color(ViewColor(), B_DARKEN_2_TINT));
112 |
113 | float x = bounds.left;
114 | for (size_t i = 0; i < kStatusCellCount - 1; i++) {
115 | if (fCellText[i].IsEmpty())
116 | continue;
117 | x += fCellWidth[i];
118 | if (fCellText[i + 1].IsEmpty() == false)
119 | StrokeLine(BPoint(x, bounds.top + 3), BPoint(x, bounds.bottom - 3));
120 | }
121 |
122 | SetLowColor(ViewColor());
123 | SetHighColor(highColor);
124 |
125 | font_height fontHeight;
126 | GetFontHeight(&fontHeight);
127 |
128 | x = bounds.left;
129 | float y = (bounds.bottom + bounds.top
130 | + ceilf(fontHeight.ascent) - ceilf(fontHeight.descent)) / 2;
131 |
132 | for (size_t i = 0; i < kStatusCellCount; i++) {
133 | if (fCellText[i].Length() == 0)
134 | continue;
135 | DrawString(fCellText[i], BPoint(x + kHorzSpacing, y));
136 | x += fCellWidth[i];
137 | }
138 | }
139 |
140 |
141 | void
142 | StatusView::MouseDown(BPoint where)
143 | {
144 | if (where.x < fNavigationButtonWidth && _HasRef()) {
145 | fNavigationPressed = true;
146 | Invalidate();
147 | _ShowDirMenu();
148 | return;
149 | }
150 |
151 | if(where.x < fNavigationButtonWidth + fCellWidth[kPositionCell] && where.x > fNavigationButtonWidth) {
152 | BMessenger msgr(Window());
153 | msgr.SendMessage(MAINMENU_SEARCH_GOTOLINE);
154 | }
155 |
156 | if (!fReadOnly)
157 | return;
158 |
159 | float left = fNavigationButtonWidth + fCellWidth[kPositionCell] + fCellWidth[kTypeCell];
160 | if (where.x < left)
161 | return;
162 |
163 | int32 clicks = 0;
164 | BMessage* message = Window()->CurrentMessage();
165 | if (message != NULL
166 | && message->FindInt32("clicks", &clicks) == B_OK && clicks > 1)
167 | return;
168 | }
169 |
170 |
171 | float
172 | StatusView::Width()
173 | {
174 | float width = fNavigationButtonWidth;
175 | for (size_t i = 0; i < kStatusCellCount; i++) {
176 | if (fCellText[i].Length() == 0) {
177 | fCellWidth[i] = 0;
178 | continue;
179 | }
180 | float cellWidth = ceilf(StringWidth(fCellText[i]));
181 | if (cellWidth > 0)
182 | cellWidth += kHorzSpacing * 2;
183 | if (cellWidth > fCellWidth[i] || i != kPositionCell)
184 | fCellWidth[i] = cellWidth;
185 | width += fCellWidth[i];
186 | }
187 | return width;
188 | }
189 |
190 |
191 | void
192 | StatusView::SetStatus(BMessage* message)
193 | {
194 | int32 line = 0, column = 0;
195 | if (message->FindInt32("line", &line) == B_OK
196 | && message->FindInt32("column", &column) == B_OK)
197 | {
198 | fCellText[kPositionCell].SetToFormat("%d, %d", line, column);
199 | }
200 |
201 | if (message->FindString("type", &fType) == B_OK) {
202 | fCellText[kTypeCell] = fType;
203 | }
204 |
205 | fReadOnly = false;
206 | if (message->FindBool("readOnly", &fReadOnly) == B_OK && fReadOnly) {
207 | fCellText[kFileStateCell] = B_TRANSLATE("Read-only");
208 | } else
209 | fCellText[kFileStateCell].Truncate(0);
210 |
211 | Invalidate();
212 | }
213 |
214 |
215 | void
216 | StatusView::SetRef(const entry_ref& ref)
217 | {
218 | fRef = ref;
219 | }
220 |
221 |
222 | bool
223 | StatusView::_HasRef()
224 | {
225 | return fRef != entry_ref();
226 | }
227 |
228 |
229 | void
230 | StatusView::_DrawNavigationButton(BRect rect)
231 | {
232 | rect.InsetBy(1.0f, 1.0f);
233 | rgb_color baseColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
234 | B_LIGHTEN_1_TINT);
235 | uint32 flags = 0;
236 | if(fNavigationPressed)
237 | flags |= BControlLook::B_ACTIVATED;
238 | if(Window()->IsActive() == false || _HasRef() == false)
239 | flags |= BControlLook::B_DISABLED;
240 | be_control_look->DrawButtonBackground(this, rect, rect, baseColor, flags,
241 | BControlLook::B_ALL_BORDERS, B_HORIZONTAL);
242 | rect.InsetBy(0.0f, -1.0f);
243 | be_control_look->DrawArrowShape(this, rect, rect, baseColor,
244 | BControlLook::B_DOWN_ARROW, flags, B_DARKEN_MAX_TINT);
245 | }
246 |
247 |
248 | void
249 | StatusView::_ShowDirMenu()
250 | {
251 | BEntry entry;
252 | status_t status = entry.SetTo(&fRef);
253 |
254 | if (status != B_OK || !entry.Exists())
255 | return;
256 |
257 | BPrivate::BDirMenu* menu = new BDirMenu(NULL,
258 | BMessenger(Window()), B_REFS_RECEIVED);
259 |
260 | BMenuItem* openTerminal = new BMenuItem(B_TRANSLATE("Open Terminal"),
261 | new BMessage((uint32) OPEN_TERMINAL), 'T', B_OPTION_KEY);
262 | // Actual shortcut is added in EditorWindow
263 | openTerminal->SetTarget(Window());
264 | menu->AddItem(openTerminal);
265 | menu->AddSeparatorItem();
266 | menu->Populate(&entry, Window(), false, false, true, false, true);
267 |
268 | BPoint point = Parent()->Bounds().LeftBottom();
269 | point.y += 3 + B_H_SCROLL_BAR_HEIGHT;
270 | ConvertToScreen(&point);
271 | BRect clickToOpenRect(Parent()->Bounds());
272 | ConvertToScreen(&clickToOpenRect);
273 | menu->Go(point, true, true, clickToOpenRect);
274 | fNavigationPressed = false;
275 | delete menu;
276 | }
277 |
278 | } // namespace editor
279 |
--------------------------------------------------------------------------------
/src/editor/EditorStatusView.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2012, Haiku, Inc. All Rights Reserved.
3 | * Distributed under the terms of the MIT License.
4 | *
5 | * Authors:
6 | * Vlad Slepukhin
7 | * Siarzhuk Zharski
8 | *
9 | * Copied from Haiku commit a609673ce8c942d91e14f24d1d8832951ab27964.
10 | * Modifications:
11 | * Copyright 2018-2019 Kacper Kasper
12 | * Distributed under the terms of the MIT License.
13 | */
14 | #ifndef EDITOR_STATUS_VIEW_H
15 | #define EDITOR_STATUS_VIEW_H
16 |
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "StatusView.h"
23 |
24 |
25 | class BScrollView;
26 |
27 |
28 | namespace editor {
29 |
30 | class StatusView : public controls::StatusView {
31 | public:
32 | enum {
33 | UPDATE_STATUS = 'upda'
34 | };
35 |
36 | StatusView(BScrollView* fScrollView);
37 | ~StatusView();
38 |
39 | virtual void AttachedToWindow();
40 | void SetStatus(BMessage* mesage);
41 | void SetRef(const entry_ref& ref);
42 | virtual void Draw(BRect bounds);
43 | virtual void MouseDown(BPoint point);
44 |
45 | protected:
46 | virtual float Width();
47 |
48 | private:
49 | void _ShowDirMenu();
50 | void _DrawNavigationButton(BRect rect);
51 | bool _HasRef();
52 |
53 | private:
54 | enum {
55 | kPositionCell,
56 | kTypeCell,
57 | kFileStateCell,
58 | kStatusCellCount
59 | };
60 | BString fCellText[kStatusCellCount];
61 | float fCellWidth[kStatusCellCount];
62 | bool fReadOnly;
63 | bool fNavigationPressed;
64 | BString fType;
65 | entry_ref fRef;
66 | const float fNavigationButtonWidth;
67 | };
68 |
69 | } // namespace editor
70 |
71 | #endif // EDITOR_STATUS_VIEW_H
72 |
--------------------------------------------------------------------------------
/src/editor/EditorWindow.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #ifndef EDITORWINDOW_H
7 | #define EDITORWINDOW_H
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 |
20 | #include
21 |
22 | #include "Languages.h"
23 |
24 |
25 | struct entry_ref;
26 | class BFilePanel;
27 | class BMenu;
28 | class BMenuBar;
29 | class BPath;
30 | class BPopUpMenu;
31 | class BookmarksWindow;
32 | class Editor;
33 | class FindReplaceHandler;
34 | class GoToLineWindow;
35 | class Preferences;
36 | class StatusView;
37 | class ToolBar;
38 |
39 |
40 | const BString gAppName = B_TRANSLATE_SYSTEM_NAME("Koder");
41 |
42 | const uint32 ACTIVE_WINDOW_CHANGED = 'AWCH';
43 | const uint32 SAVE_FILE = 'SVFL';
44 |
45 |
46 | enum {
47 | MAINMENU_FILE_NEW = 'mnew',
48 | MAINMENU_FILE_OPEN = 'mopn',
49 | MAINMENU_FILE_RELOAD = 'mrld',
50 | MAINMENU_FILE_SAVE = 'msav',
51 | MAINMENU_FILE_SAVEAS = 'msva',
52 | MAINMENU_FILE_OPEN_CORRESPONDING = 'mcrf',
53 | MAINMENU_FILE_QUIT = 'mqut',
54 |
55 | MAINMENU_EDIT_CONVERTEOLS_UNIX = 'ceun',
56 | MAINMENU_EDIT_CONVERTEOLS_WINDOWS = 'cewi',
57 | MAINMENU_EDIT_CONVERTEOLS_MAC = 'cema',
58 |
59 | EDIT_COMMENTLINE = 'cmtl',
60 | EDIT_COMMENTBLOCK = 'cmtb',
61 |
62 | MAINMENU_EDIT_TRIMWS = 'metw',
63 |
64 | MAINMENU_EDIT_FILE_PREFERENCES = 'mefp',
65 | MAINMENU_EDIT_APP_PREFERENCES = 'meap',
66 |
67 | MAINMENU_VIEW_SPECIAL_WHITESPACE = 'vsws',
68 | MAINMENU_VIEW_SPECIAL_EOL = 'vseo',
69 | MAINMENU_VIEW_TOOLBAR = 'vstl',
70 | MAINMENU_VIEW_WRAPLINES = 'mvwl',
71 |
72 | MAINMENU_SEARCH_FINDREPLACE = 'msfr',
73 | MAINMENU_SEARCH_FINDNEXT = 'msfn',
74 | MAINMENU_SEARCH_FINDSELECTION = 'msfs',
75 | MAINMENU_SEARCH_REPLACEANDFIND = 'msrf',
76 | MAINMENU_SEARCH_INCREMENTAL = 'msin',
77 | MAINMENU_SEARCH_BOOKMARKS = 'msbk',
78 | MAINMENU_SEARCH_TOGGLEBOOKMARK = 'mtbk',
79 | MAINMENU_SEARCH_NEXTBOOKMARK = 'mnbk',
80 | MAINMENU_SEARCH_PREVBOOKMARK = 'mpbk',
81 | MAINMENU_SEARCH_GOTOLINE = 'msgl',
82 |
83 | MAINMENU_LANGUAGE = 'ml00',
84 | MAINMENU_OPEN_RECENT = 'mr00',
85 |
86 | TOOLBAR_SPECIAL_SYMBOLS = 'tlss',
87 |
88 | FILE_OPEN = 'flop',
89 | FILE_SAVE = 'flsv',
90 |
91 | WINDOW_NEW = 'ewnw',
92 | WINDOW_CLOSE = 'ewcl',
93 |
94 | OPEN_TERMINAL = 'otrm',
95 | };
96 |
97 |
98 | class EditorWindow : public BWindow {
99 | public:
100 | EditorWindow(bool stagger = false);
101 | virtual ~EditorWindow();
102 |
103 | void New();
104 | void OpenFile(const entry_ref* ref,
105 | Sci_Position line = -1,
106 | Sci_Position column = -1);
107 | void RefreshTitle();
108 | void SaveFile(entry_ref* ref);
109 |
110 | bool QuitRequested();
111 | void MessageReceived(BMessage* message);
112 | void WindowActivated(bool active);
113 | void FrameMoved(BPoint origin);
114 | void Show();
115 |
116 | bool IsModified() { return fModified; }
117 | const char* OpenedFilePath();
118 |
119 | static void SetPreferences(Preferences* preferences);
120 |
121 | void SetOnQuitReplyToMessage(BMessage* message);
122 |
123 | private:
124 | enum ModifiedAlertResult {
125 | CANCEL = 0,
126 | DISCARD = 1,
127 | SAVE = 2
128 | };
129 | struct FilePreferences {
130 | std::optional fTabWidth;
131 | std::optional fIndentWidth;
132 | std::optional fTabsToSpaces;
133 | std::optional fTrimTrailingWhitespace;
134 | std::optional fEOLMode;
135 | };
136 | BMenuBar* fMainMenu;
137 | BPopUpMenu* fContextMenu;
138 | BPath* fOpenedFilePath;
139 | BMimeType fOpenedFileMimeType;
140 | time_t fOpenedFileModificationTime;
141 | bool fModifiedOutside;
142 | bool fModified;
143 | bool fReadOnly;
144 | Editor* fEditor;
145 | BFilePanel* fOpenPanel;
146 | BFilePanel* fSavePanel;
147 | BMenu* fOpenRecentMenu;
148 | BMenu* fLanguageMenu;
149 | std::string fCurrentLanguage;
150 | ToolBar* fToolbar;
151 | StatusView* fStatusView;
152 |
153 | GoToLineWindow* fGoToLineWindow;
154 | BookmarksWindow* fBookmarksWindow;
155 |
156 | bool fActivatedGuard;
157 |
158 | BMessage* fOnQuitReplyToMessage;
159 |
160 | FindReplaceHandler* fFindReplaceHandler;
161 |
162 | static Preferences* fPreferences;
163 | FilePreferences fFilePreferences;
164 |
165 | void _PopulateOpenRecentMenu();
166 | void _PopulateLanguageMenu();
167 | void _ReloadFile(entry_ref* ref = nullptr);
168 | void _SetLanguage(std::string lang);
169 | void _SetLanguageByFilename(const char* filename);
170 | void _OpenCorrespondingFile(const BPath &file, const std::string lang);
171 | void _LoadEditorconfig();
172 | void _SyncWithPreferences();
173 | void _SyncEditMenus();
174 | int32 _ShowModifiedAlert();
175 | void _ReloadAlert(const char* title, const char* message);
176 | void _Save();
177 | void _OpenTerminal(const char* path);
178 |
179 | void OnSavePoint(bool left);
180 | };
181 |
182 |
183 | #endif // EDITORWINDOW_H
184 |
--------------------------------------------------------------------------------
/src/editor/FindReplaceHandler.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 |
7 | #include "FindReplaceHandler.h"
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 |
16 | namespace Sci = Scintilla;
17 | using namespace Sci::Properties;
18 |
19 |
20 | FindReplaceHandler::FindReplaceHandler(BScintillaView* editor,
21 | BHandler* replyHandler)
22 | :
23 | fEditor(editor),
24 | fReplyHandler(replyHandler),
25 | fSearchTarget(-1, -1),
26 | fSearchLastResult(-1, -1),
27 | fSearchLast(""),
28 | fSearchLastFlags(0)
29 | {
30 | fIncrementalSearchFilter = new IncrementalSearchMessageFilter(this);
31 | }
32 |
33 |
34 | FindReplaceHandler::~FindReplaceHandler()
35 | {
36 | delete fIncrementalSearchFilter;
37 | }
38 |
39 |
40 | void
41 | FindReplaceHandler::MessageReceived(BMessage* message)
42 | {
43 | search_info info = _UnpackSearchMessage(*message);
44 |
45 | Sci::Guard guard(fEditor);
46 |
47 | const int length = fEditor->SendMessage(SCI_GETLENGTH);
48 | const Sci_Position anchor = fEditor->SendMessage(SCI_GETANCHOR);
49 | const Sci_Position current = fEditor->SendMessage(SCI_GETCURRENTPOS);
50 |
51 | const auto incrementalSearch = [&]() {
52 | if(fIncrementalSearch == false) {
53 | fIncrementalSearch = true;
54 | fSavedSelection = { anchor, current };
55 | }
56 | Sci_Position start = std::min(anchor, current);
57 | Sci_Position pos = _Find(fIncrementalSearchTerm, start, length, false, false, false);
58 |
59 | if(pos == -1) {
60 | pos = _Find(fIncrementalSearchTerm, 0, start, false, false, false);
61 | }
62 |
63 | if(pos == -1) {
64 | Set(fSavedSelection);
65 | } else {
66 | Set(Get());
67 | }
68 | };
69 |
70 | switch(message->what) {
71 | case REPLACEFIND:
72 | if(info.replace.empty() && info.find.empty()) {
73 | info.replace = fSearchLastInfo.replace;
74 | }
75 | // fallthrough
76 | case REPLACE: {
77 | int replaceMsg = (info.regex ? SCI_REPLACETARGETRE : SCI_REPLACETARGET);
78 | if(fSearchLastResult != Sci::Range{ -1, -1 }) {
79 | // we need to search again, because whitespace highlighting messes with
80 | // the results
81 | Set(fSearchLastFlags);
82 | Set(fSearchLastResult);
83 | fEditor->SendMessage(SCI_SEARCHINTARGET, (uptr_t) fSearchLastInfo.find.size(), (sptr_t) fSearchLastInfo.find.c_str());
84 | fEditor->SendMessage(replaceMsg, -1, (sptr_t) info.replace.c_str());
85 | Sci::Range target = Get();
86 | if(fSearchLastInfo.backwards == true) {
87 | std::swap(target.first, target.second);
88 | }
89 | fEditor->SendMessage(SCI_SETANCHOR, target.first);
90 | fEditor->SendMessage(SCI_SETCURRENTPOS, target.second);
91 | fSearchLastResult = { -1, -1 };
92 | }
93 | }
94 | if(message->what != REPLACEFIND) break;
95 | case FIND: {
96 | if(info.find.empty()) {
97 | info = fSearchLastInfo;
98 | }
99 | if((fSearchLastInfo.backwards == true && (anchor != fSearchLastResult.first
100 | || current != fSearchLastResult.second))
101 | || (fSearchLastInfo.backwards == false && (anchor != fSearchLastResult.second
102 | || current != fSearchLastResult.first))
103 | || info != fSearchLastInfo) {
104 | fNewSearch = true;
105 | }
106 | if(message->what == REPLACEFIND) {
107 | info = fSearchLastInfo;
108 | }
109 |
110 | if(fNewSearch == true) {
111 | if(info.inSelection == true) {
112 | fSearchTarget = Get();
113 | if(info.backwards == true) {
114 | std::swap(fSearchTarget.first, fSearchTarget.second);
115 | }
116 | } else {
117 | fSearchTarget = info.backwards
118 | ? Sci::Range(std::min(anchor, current), 0)
119 | : Sci::Range(std::max(anchor, current), length);
120 | }
121 | }
122 |
123 | auto temp = fSearchTarget;
124 |
125 | if(fNewSearch == false) {
126 | temp.first = current;
127 | }
128 |
129 | Sci_Position pos = _Find(info.find, temp.first, temp.second,
130 | info.matchCase, info.matchWord, info.regex);
131 |
132 | if(pos == -1 && info.wrapAround == true) {
133 | Sci_Position startAgain;
134 | if(info.inSelection == true) {
135 | startAgain = fSearchTarget.first;
136 | } else {
137 | startAgain = (info.backwards ? length : 0);
138 | }
139 | pos = _Find(info.find, startAgain, fSearchTarget.second,
140 | info.matchCase, info.matchWord, info.regex);
141 | }
142 | if(pos != -1) {
143 | fSearchLastResult = Get();
144 | if(info.backwards == true) {
145 | std::swap(fSearchLastResult.first, fSearchLastResult.second);
146 | }
147 | fEditor->SendMessage(SCI_SETANCHOR, fSearchLastResult.first);
148 | fEditor->SendMessage(SCI_SETCURRENTPOS, fSearchLastResult.second);
149 | fEditor->SendMessage(SCI_SCROLLCARET);
150 | }
151 | if(fReplyHandler != nullptr) {
152 | BMessage reply(FIND);
153 | reply.AddBool("found", pos != -1);
154 | message->SendReply(&reply, fReplyHandler);
155 | }
156 | fNewSearch = false;
157 | fSearchLastInfo = info;
158 | } break;
159 | case REPLACEALL: {
160 | Sci::UndoAction action(fEditor);
161 | int replaceMsg = (info.regex ? SCI_REPLACETARGETRE : SCI_REPLACETARGET);
162 | int occurences = 0;
163 | fEditor->SendMessage(info.inSelection ? SCI_TARGETFROMSELECTION : SCI_TARGETWHOLEDOCUMENT);
164 | auto target = Get();
165 | Sci_Position pos;
166 | do {
167 | pos = _Find(info.find, target.first, target.second,
168 | info.matchCase, info.matchWord, info.regex);
169 | if(pos != -1) {
170 | fEditor->SendMessage(replaceMsg, -1, (sptr_t) info.replace.c_str());
171 | target.first = Get();
172 | target.second = fEditor->SendMessage(SCI_GETLENGTH);
173 | occurences++;
174 | }
175 | } while(pos != -1);
176 | if(fReplyHandler != nullptr) {
177 | BMessage reply(REPLACEALL);
178 | reply.AddInt32("replaced", occurences);
179 | message->SendReply(&reply, fReplyHandler);
180 | }
181 | } break;
182 | case INCREMENTAL_SEARCH_CHAR: {
183 | const char* character = message->GetString("character", "");
184 | fIncrementalSearchTerm.append(character);
185 | incrementalSearch();
186 | } break;
187 | case INCREMENTAL_SEARCH_BACKSPACE: {
188 | if(!fIncrementalSearchTerm.empty()) {
189 | fIncrementalSearchTerm.pop_back();
190 | incrementalSearch();
191 | }
192 | } break;
193 | case INCREMENTAL_SEARCH_CANCEL: {
194 | fIncrementalSearch = false;
195 | fIncrementalSearchTerm = "";
196 | Set(fSavedSelection);
197 | Looper()->RemoveCommonFilter(fIncrementalSearchFilter);
198 | } break;
199 | case INCREMENTAL_SEARCH_COMMIT: {
200 | fIncrementalSearch = false;
201 | search_info si = {};
202 | si.wrapAround = true;
203 | si.find = fIncrementalSearchTerm;
204 | fIncrementalSearchTerm = "";
205 | Looper()->RemoveCommonFilter(fIncrementalSearchFilter);
206 | } break;
207 | }
208 | }
209 |
210 |
211 | FindReplaceHandler::IncrementalSearchMessageFilter::IncrementalSearchMessageFilter(BHandler* handler)
212 | :
213 | BMessageFilter(B_KEY_DOWN),
214 | fHandler(handler)
215 | {
216 | }
217 |
218 |
219 | filter_result
220 | FindReplaceHandler::IncrementalSearchMessageFilter::Filter(BMessage* message, BHandler** target)
221 | {
222 | if(message->what == B_KEY_DOWN) {
223 | BLooper *looper = Looper();
224 | const char* bytes;
225 | message->FindString("bytes", &bytes);
226 | if(bytes[0] == B_RETURN) {
227 | looper->PostMessage(INCREMENTAL_SEARCH_COMMIT, fHandler);
228 | } else if(bytes[0] == B_ESCAPE) {
229 | looper->PostMessage(INCREMENTAL_SEARCH_CANCEL, fHandler);
230 | } else if(bytes[0] == B_BACKSPACE) {
231 | looper->PostMessage(INCREMENTAL_SEARCH_BACKSPACE, fHandler);
232 | } else {
233 | BMessage msg(INCREMENTAL_SEARCH_CHAR);
234 | msg.AddString("character", &bytes[0]);
235 | Looper()->PostMessage(&msg, fHandler);
236 | }
237 | return B_SKIP_MESSAGE;
238 | }
239 | return B_DISPATCH_MESSAGE;
240 | }
241 |
242 |
243 |
244 | Sci_Position
245 | FindReplaceHandler::_Find(std::string search, Sci_Position start,
246 | Sci_Position end, bool matchCase, bool matchWord, bool regex)
247 | {
248 | int searchFlags = 0;
249 | if(matchCase == true)
250 | searchFlags |= SCFIND_MATCHCASE;
251 | if(matchWord == true)
252 | searchFlags |= SCFIND_WHOLEWORD;
253 | if(regex == true)
254 | searchFlags |= SCFIND_REGEXP | SCFIND_CXX11REGEX;
255 | Set(searchFlags);
256 | fSearchLastFlags = searchFlags;
257 |
258 | Set({start, end});
259 |
260 | fSearchLast = search;
261 | Sci_Position pos = fEditor->SendMessage(SCI_SEARCHINTARGET,
262 | (uptr_t) search.size(), (sptr_t) search.c_str());
263 | return pos;
264 | }
265 |
266 |
267 | FindReplaceHandler::search_info
268 | FindReplaceHandler::_UnpackSearchMessage(BMessage& message)
269 | {
270 | search_info info;
271 | info.inSelection = message.GetBool("inSelection");
272 | info.matchCase = message.GetBool("matchCase");
273 | info.matchWord = message.GetBool("matchWord");
274 | info.wrapAround = message.GetBool("wrapAround");
275 | info.backwards = message.GetBool("backwards");
276 | info.regex = message.GetBool("regex");
277 | info.find = message.GetString("findText", "");
278 | info.replace = message.GetString("replaceText", "");
279 | return info;
280 | }
281 |
--------------------------------------------------------------------------------
/src/editor/FindReplaceHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 | #ifndef FINDREPLACEHANLDER_H
6 | #define FINDREPLACEHANDLER_H
7 |
8 |
9 | #include
10 |
11 | #include
12 | #include
13 | #include
14 |
15 | #include "ScintillaUtils.h"
16 |
17 |
18 | class BScintillaView;
19 |
20 |
21 | class FindReplaceHandler : public BHandler {
22 | public:
23 | enum {
24 | FIND = 'find',
25 | REPLACE = 'repl',
26 | REPLACEFIND = 'fnrp',
27 | REPLACEALL = 'rpla',
28 | };
29 | FindReplaceHandler(BScintillaView* editor,
30 | BHandler* replyHandler = nullptr);
31 | ~FindReplaceHandler();
32 | virtual void MessageReceived(BMessage* message);
33 |
34 | BMessageFilter* IncrementalSearchFilter() const { return fIncrementalSearchFilter; }
35 |
36 | private:
37 | enum {
38 | INCREMENTAL_SEARCH_CHAR = 'incs',
39 | INCREMENTAL_SEARCH_BACKSPACE = 'incb',
40 | INCREMENTAL_SEARCH_CANCEL = 'ince',
41 | INCREMENTAL_SEARCH_COMMIT = 'incc'
42 | };
43 |
44 | class IncrementalSearchMessageFilter : public BMessageFilter
45 | {
46 | public:
47 | IncrementalSearchMessageFilter(BHandler* handler);
48 |
49 | virtual filter_result Filter(BMessage* message, BHandler** target);
50 |
51 | private:
52 | BHandler *fHandler;
53 | };
54 |
55 | struct search_info {
56 | bool inSelection : 1;
57 | bool matchCase : 1;
58 | bool matchWord : 1;
59 | bool wrapAround : 1;
60 | bool backwards : 1;
61 | bool regex : 1;
62 | std::string find;
63 | std::string replace;
64 |
65 | bool operator ==(const search_info& rhs) const {
66 | return inSelection == rhs.inSelection
67 | && matchCase == rhs.matchCase
68 | && matchWord == rhs.matchWord
69 | && wrapAround == rhs.wrapAround
70 | && backwards == rhs.backwards
71 | && regex == rhs.regex
72 | && find == rhs.find
73 | && replace == rhs.replace;
74 | }
75 | bool operator !=(const search_info& rhs) const {
76 | return !(*this == rhs);
77 | }
78 | };
79 | Sci_Position _Find(std::string search, Sci_Position start,
80 | Sci_Position end, bool matchCase, bool matchWord,
81 | bool regex);
82 | search_info _UnpackSearchMessage(BMessage& message);
83 |
84 | template
85 | typename T::type Get() { return T::Get(fEditor); }
86 | template
87 | void Set(typename T::type value) { T::Set(fEditor, value); }
88 |
89 | BScintillaView* fEditor;
90 | BHandler* fReplyHandler;
91 |
92 | Scintilla::Range fSearchTarget;
93 | Scintilla::Range fSearchLastResult;
94 | std::string fSearchLast;
95 | int fSearchLastFlags;
96 | bool fNewSearch;
97 | search_info fSearchLastInfo;
98 |
99 | bool fIncrementalSearch;
100 | std::string fIncrementalSearchTerm;
101 | Scintilla::Range fSavedSelection;
102 | BMessageFilter* fIncrementalSearchFilter;
103 | };
104 |
105 |
106 | #endif // FINDREPLACEHANDLER_H
107 |
--------------------------------------------------------------------------------
/src/editor/GoToLineWindow.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2017 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #include "GoToLineWindow.h"
7 |
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | #include "Utils.h"
17 |
18 |
19 | #undef B_TRANSLATION_CONTEXT
20 | #define B_TRANSLATION_CONTEXT "GoToLineWindow"
21 |
22 |
23 | GoToLineWindow::GoToLineWindow(BWindow* owner)
24 | :
25 | BWindow(BRect(0, 0, 0, 0), B_TRANSLATE("Go to line"), B_MODAL_WINDOW_LOOK,
26 | B_MODAL_SUBSET_WINDOW_FEEL,
27 | B_NOT_RESIZABLE | B_NOT_MOVABLE | B_AUTO_UPDATE_SIZE_LIMITS),
28 | fOwner(owner)
29 | {
30 | fLine = new BTextControl("GoToLineTC", B_TRANSLATE("Go to line:"), "1", nullptr);
31 | for(uint8 i = 0; i < '0'; i++)
32 | fLine->TextView()->DisallowChar(static_cast(i));
33 | for(uint8 i = '9' + 1; i < 255; i++)
34 | fLine->TextView()->DisallowChar(static_cast(i));
35 | fGo = new BButton("GoButton", B_TRANSLATE("OK"), new BMessage(GTLW_GO));
36 | fGo->MakeDefault(true);
37 | fCancel = new BButton("CancelButton", B_TRANSLATE("Cancel"), new BMessage(GTLW_CANCEL));
38 |
39 | AddCommonFilter(new KeyDownMessageFilter(GTLW_CANCEL, B_ESCAPE));
40 |
41 | AddToSubset(fOwner);
42 |
43 | BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 5);
44 | layout->SetInsets(5, 5, 5, 5);
45 | SetLayout(layout);
46 | layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
47 | BLayoutBuilder::Group<>(layout)
48 | .Add(fLine)
49 | .AddGroup(B_HORIZONTAL, 5)
50 | .Add(fCancel)
51 | .Add(fGo)
52 | .End();
53 | }
54 |
55 |
56 | void
57 | GoToLineWindow::MessageReceived(BMessage* message)
58 | {
59 | switch(message->what) {
60 | case GTLW_GO: {
61 | int32 line = std::stoi(fLine->Text());
62 | message->AddInt32("line", line);
63 | fOwner->PostMessage(message);
64 | }
65 | case GTLW_CANCEL:
66 | Hide();
67 | break;
68 | default:
69 | BWindow::MessageReceived(message);
70 | break;
71 | }
72 | }
73 |
74 |
75 | void
76 | GoToLineWindow::ShowCentered(BRect ownerRect)
77 | {
78 | CenterIn(ownerRect);
79 | Show();
80 | }
81 |
82 |
83 | void
84 | GoToLineWindow::WindowActivated(bool active)
85 | {
86 | fLine->MakeFocus();
87 | fLine->TextView()->SelectAll();
88 | }
89 |
--------------------------------------------------------------------------------
/src/editor/GoToLineWindow.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2017 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #ifndef GOTOLINEWINDOW_H
7 | #define GOTOLINEWINDOW_H
8 |
9 |
10 | #include
11 |
12 |
13 | class BButton;
14 | class BTextControl;
15 |
16 |
17 | enum {
18 | GTLW_CANCEL = 'gtlc',
19 | GTLW_GO = 'gtlg'
20 | };
21 |
22 |
23 | class GoToLineWindow : public BWindow {
24 | public:
25 | GoToLineWindow(BWindow* owner);
26 |
27 | void MessageReceived(BMessage* message);
28 | void ShowCentered(BRect ownerRect);
29 | void WindowActivated(bool active);
30 |
31 | private:
32 | BTextControl* fLine;
33 | BButton* fGo;
34 | BButton* fCancel;
35 |
36 | BWindow* fOwner;
37 | };
38 |
39 |
40 | #endif // GOTOLINEWINDOW_H
41 |
--------------------------------------------------------------------------------
/src/editor/QuitAlert.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #include "QuitAlert.h"
7 |
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | #include
17 | #include
18 |
19 | #include "EditorWindow.h"
20 | #include "Utils.h"
21 |
22 |
23 | #undef B_TRANSLATION_CONTEXT
24 | #define B_TRANSLATION_CONTEXT "QuitAlert"
25 |
26 |
27 | namespace {
28 | const int kSemTimeOut = 50000;
29 | const uint32 kMaxItems = 4;
30 | }
31 |
32 |
33 | QuitAlert::QuitAlert(const std::vector &unsavedFiles)
34 | :
35 | BWindow(BRect(100, 100, 200, 200), B_TRANSLATE("Unsaved files"), B_MODAL_WINDOW,
36 | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS, 0),
37 | fUnsavedFiles(unsavedFiles),
38 | fAlertValue(0),
39 | fCheckboxes(unsavedFiles.size(), nullptr)
40 | {
41 | _InitInterface();
42 | CenterOnScreen();
43 | }
44 |
45 |
46 | QuitAlert::~QuitAlert()
47 | {
48 | if (fAlertSem >= B_OK)
49 | delete_sem(fAlertSem);
50 | }
51 |
52 |
53 | void
54 | QuitAlert::_InitInterface()
55 | {
56 | fMessageString = new BStringView("message", B_TRANSLATE("There are unsaved changes.\nSelect the files to save."));
57 | fSaveAll = new BButton(B_TRANSLATE("Save all"), new BMessage((uint32) Actions::SAVE_ALL));
58 | fSaveSelected = new BButton(B_TRANSLATE("Save selected"), new BMessage((uint32) Actions::SAVE_SELECTED));
59 | fDontSave = new BButton(B_TRANSLATE("Don't save"), new BMessage((uint32) Actions::DONT_SAVE));
60 | fCancel = new BButton(B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED));
61 | fCancel->MakeDefault(true);
62 | BGroupView* filesView = new BGroupView(B_VERTICAL, 0);
63 | filesView->SetViewUIColor(B_CONTROL_BACKGROUND_COLOR);
64 | fScrollView = new BScrollView("files", filesView, 0, false, true);
65 | BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
66 | .Add(fMessageString)
67 | .Add(fScrollView)
68 | .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
69 | .Add(fSaveAll)
70 | .Add(fSaveSelected)
71 | .Add(fDontSave)
72 | .AddGlue()
73 | .Add(fCancel)
74 | .End()
75 | .SetInsets(B_USE_SMALL_INSETS);
76 |
77 | font_height fh;
78 | be_plain_font->GetHeight(&fh);
79 | float textHeight = fh.ascent + fh.descent + fh.leading + 5;
80 | fScrollView->SetExplicitSize(BSize(B_SIZE_UNSET,
81 | textHeight * std::min(fUnsavedFiles.size(), kMaxItems) + 25.0f));
82 | BScrollBar* bar = fScrollView->ScrollBar(B_VERTICAL);
83 | bar->SetSteps(textHeight / 2.0f, textHeight * 3.0f / 2.0f);
84 | bar->SetRange(0.0f, fUnsavedFiles.size() > kMaxItems ?
85 | (textHeight + 3.0f) * (fUnsavedFiles.size() - kMaxItems) : 0.0f);
86 |
87 | EditorWindow* current;
88 | BGroupLayout* files = filesView->GroupLayout();
89 | files->SetInsets(B_USE_SMALL_INSETS);
90 | for(int i = 0; i < fUnsavedFiles.size(); ++i) {
91 | fCheckboxes[i] = new BCheckBox("file", fUnsavedFiles[i].c_str(), new BMessage((uint32) i));
92 | SetChecked(fCheckboxes[i]);
93 | files->AddView(fCheckboxes[i]);
94 | }
95 | }
96 |
97 |
98 | void
99 | QuitAlert::Show()
100 | {
101 | BWindow::Show();
102 | fScrollView->SetExplicitSize(BSize(Bounds().Width(), B_SIZE_UNSET));
103 | }
104 |
105 |
106 | // borrowed from BAlert
107 | std::vector
108 | QuitAlert::Go()
109 | {
110 | fAlertSem = create_sem(0, "AlertSem");
111 | if (fAlertSem < 0) {
112 | Quit();
113 | return std::vector(0);
114 | }
115 |
116 | // Get the originating window, if it exists
117 | BWindow* window = dynamic_cast(
118 | BLooper::LooperForThread(find_thread(nullptr)));
119 |
120 | Show();
121 |
122 | if (window != nullptr) {
123 | status_t status;
124 | for (;;) {
125 | do {
126 | status = acquire_sem_etc(fAlertSem, 1, B_RELATIVE_TIMEOUT,
127 | kSemTimeOut);
128 | // We've (probably) had our time slice taken away from us
129 | } while (status == B_INTERRUPTED);
130 |
131 | if (status == B_BAD_SEM_ID) {
132 | // Semaphore was finally nuked in MessageReceived
133 | break;
134 | }
135 | window->UpdateIfNeeded();
136 | }
137 | } else {
138 | // No window to update, so just hang out until we're done.
139 | while (acquire_sem(fAlertSem) == B_INTERRUPTED) {
140 | }
141 | }
142 |
143 | // Have to cache the value since we delete on Quit()
144 | auto value = fAlertValue;
145 | if (Lock())
146 | Quit();
147 |
148 | return value;
149 | }
150 |
151 |
152 | void
153 | QuitAlert::MessageReceived(BMessage* message)
154 | {
155 | switch(message->what) {
156 | case Actions::SAVE_ALL: {
157 | fAlertValue = std::vector(fUnsavedFiles.size(), true);
158 | } break;
159 | case Actions::SAVE_SELECTED: {
160 | fAlertValue = std::vector(fUnsavedFiles.size(), false);
161 | for(uint32 i = 0; i < fCheckboxes.size(); ++i) {
162 | fAlertValue[i] = fCheckboxes[i]->Value() ? true : false;
163 | }
164 | } break;
165 | case Actions::DONT_SAVE: {
166 | fAlertValue = std::vector(fUnsavedFiles.size(), false);
167 | } break;
168 | default: {
169 | BWindow::MessageReceived(message);
170 | } return;
171 | }
172 | delete_sem(fAlertSem);
173 | fAlertSem = -1;
174 | }
175 |
--------------------------------------------------------------------------------
/src/editor/QuitAlert.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #ifndef QUITALERT_H
7 | #define QUITALERT_H
8 |
9 |
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 |
17 | class BButton;
18 | class BCheckBox;
19 | class BStringView;
20 | class BScrollView;
21 |
22 | class EditorWindow;
23 |
24 |
25 | class QuitAlert : public BWindow {
26 | public:
27 | QuitAlert(const std::vector &unsavedFiles);
28 | ~QuitAlert();
29 |
30 | void MessageReceived(BMessage* message);
31 | virtual void Show();
32 | std::vector Go();
33 | private:
34 | enum Actions {
35 | SAVE_ALL = 'sval',
36 | SAVE_SELECTED = 'svsl',
37 | DONT_SAVE = 'dnsv'
38 | };
39 | const std::vector fUnsavedFiles;
40 | BScrollView* fScrollView;
41 | BStringView* fMessageString;
42 | BButton* fSaveAll;
43 | BButton* fSaveSelected;
44 | BButton* fDontSave;
45 | BButton* fCancel;
46 | std::vector fCheckboxes;
47 | std::vector fAlertValue;
48 | sem_id fAlertSem;
49 |
50 | void _InitInterface();
51 | };
52 |
53 |
54 | #endif // QUITALERT_H
55 |
--------------------------------------------------------------------------------
/src/find/FindScintillaView.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #include "FindScintillaView.h"
7 |
8 | #include
9 |
10 | #include "FindStatusView.h"
11 | #include "Utils.h"
12 |
13 |
14 | namespace find {
15 |
16 | ScintillaView::ScintillaView(const char* name, uint32 getMessage,
17 | uint32 clearMessage, uint32 applyMessage, uint32 flags, bool horizontal,
18 | bool vertical, border_style border)
19 | :
20 | BScintillaView(name, flags, horizontal, vertical, border)
21 | {
22 | SendMessage(SCI_SETSELEOLFILLED, 1);
23 |
24 | _UpdateColors();
25 | fStatusView = new find::StatusView(this,
26 | getMessage, clearMessage, applyMessage);
27 | }
28 |
29 |
30 | void
31 | ScintillaView::DoLayout()
32 | {
33 | BScintillaView::DoLayout();
34 |
35 | fStatusView->ResizeToPreferred();
36 | }
37 |
38 |
39 | void
40 | ScintillaView::FrameResized(float width, float height)
41 | {
42 | BScintillaView::FrameResized(width, height);
43 |
44 | fStatusView->ResizeToPreferred();
45 | }
46 |
47 |
48 | void
49 | ScintillaView::MessageReceived(BMessage* message)
50 | {
51 | switch(message->what) {
52 | case B_COLORS_UPDATED: {
53 | _UpdateColors();
54 | } break;
55 | default: {
56 | BScintillaView::MessageReceived(message);
57 | } break;
58 | }
59 | }
60 |
61 |
62 | void
63 | ScintillaView::_UpdateColors()
64 | {
65 | rgb_color fore = ui_color(B_DOCUMENT_TEXT_COLOR);
66 | rgb_color back = ui_color(B_DOCUMENT_BACKGROUND_COLOR);
67 | SendMessage(SCI_STYLESETFORE, STYLE_DEFAULT, rgb_colorToSciColor(fore));
68 | SendMessage(SCI_STYLESETBACK, STYLE_DEFAULT, rgb_colorToSciColor(back));
69 | SendMessage(SCI_STYLESETFORE, 0, rgb_colorToSciColor(fore));
70 | SendMessage(SCI_STYLESETBACK, 0, rgb_colorToSciColor(back));
71 | }
72 |
73 | } // namespace find
74 |
--------------------------------------------------------------------------------
/src/find/FindScintillaView.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #ifndef FINDSCINTILLAVIEW_H
7 | #define FINDSCINTILLAVIEW_H
8 |
9 |
10 | #include
11 |
12 |
13 | namespace find {
14 |
15 | class StatusView;
16 |
17 |
18 | class ScintillaView : public BScintillaView
19 | {
20 | public:
21 | ScintillaView(const char* name, uint32 getMessage, uint32 clearMessage,
22 | uint32 applyMessage, uint32 flags = 0, bool horizontal = true,
23 | bool vertical = true, border_style border = B_FANCY_BORDER);
24 |
25 | virtual void DoLayout();
26 | virtual void FrameResized(float width, float height);
27 | virtual void MessageReceived(BMessage* message);
28 |
29 | private:
30 | void _UpdateColors();
31 |
32 | StatusView* fStatusView;
33 | };
34 |
35 | } // namespace find
36 |
37 | #endif // FINDSCINTILLAVIEW_H
38 |
--------------------------------------------------------------------------------
/src/find/FindStatusView.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2012, Haiku, Inc. All Rights Reserved.
3 | * Distributed under the terms of the MIT License.
4 | *
5 | * Authors:
6 | * Vlad Slepukhin
7 | * Siarzhuk Zharski
8 | *
9 | * Copied from Haiku commit a609673ce8c942d91e14f24d1d8832951ab27964.
10 | * Modifications:
11 | * Copyright 2019 Kacper Kasper
12 | * Distributed under the terms of the MIT License.
13 | */
14 |
15 |
16 | #include "FindStatusView.h"
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | #include "FindWindow.h"
33 |
34 |
35 | #undef B_TRANSLATION_CONTEXT
36 | #define B_TRANSLATION_CONTEXT "FindStatusView"
37 |
38 |
39 | namespace {
40 | const float kHorzSpacing = 5.f;
41 | const char* kLabel = B_TRANSLATE_MARK("History");
42 | }
43 |
44 |
45 | namespace find {
46 |
47 | StatusView::StatusView(BScrollView* scrollView, uint32 getMessage,
48 | uint32 clearMessage, uint32 applyMessage)
49 | :
50 | controls::StatusView(scrollView),
51 | fPressed(false),
52 | fButtonWidth(scrollView->ScrollBar(B_HORIZONTAL)->Frame().Height() + kHorzSpacing * 2),
53 | fGetMessage(getMessage),
54 | fClearMessage(clearMessage),
55 | fApplyMessage(applyMessage)
56 | {
57 | SetFont(be_plain_font);
58 | float fontSize = 10.f * (be_plain_font->Size() / 12.f);
59 | SetFontSize(fontSize);
60 | }
61 |
62 |
63 | StatusView::~StatusView()
64 | {
65 | }
66 |
67 |
68 | void
69 | StatusView::Draw(BRect updateRect)
70 | {
71 | float width, height;
72 | GetPreferredSize(&width, &height);
73 | if (width <= 0)
74 | return;
75 |
76 | rgb_color highColor = HighColor();
77 | BRect bounds(Bounds());
78 | bounds.bottom = height;
79 | bounds.right = width;
80 |
81 | rgb_color base = tint_color(ViewColor(), B_DARKEN_2_TINT);
82 |
83 | _DrawButton(bounds);
84 |
85 | be_control_look->DrawScrollViewFrame(this, bounds, bounds, BRect(), BRect(),
86 | ViewColor(), B_FANCY_BORDER, 0,
87 | BControlLook::B_LEFT_BORDER | BControlLook::B_BOTTOM_BORDER);
88 |
89 | if(ScrollView()->IsBorderHighlighted() && Window()->IsActive()) {
90 | SetHighUIColor(B_KEYBOARD_NAVIGATION_COLOR);
91 | } else {
92 | SetHighUIColor(B_PANEL_BACKGROUND_COLOR, B_DARKEN_2_TINT);
93 | }
94 | StrokeLine(bounds.LeftTop(), bounds.RightTop());
95 |
96 | // BControlLook mutates color
97 | SetHighColor(base);
98 | BPoint rt = bounds.RightTop();
99 | rt.y++;
100 | StrokeLine(rt, bounds.RightBottom());
101 |
102 | font_height fontHeight;
103 | GetFontHeight(&fontHeight);
104 |
105 | float x = 0.0f;
106 | float y = (bounds.bottom + bounds.top
107 | + ceilf(fontHeight.ascent) - ceilf(fontHeight.descent)) / 2;
108 | if(fPressed) {
109 | x++;
110 | y++;
111 | }
112 | SetHighUIColor(B_PANEL_TEXT_COLOR);
113 | DrawString(B_TRANSLATE(kLabel), BPoint(x + kHorzSpacing, y));
114 | SetHighColor(highColor);
115 | }
116 |
117 |
118 | void
119 | StatusView::MouseDown(BPoint where)
120 | {
121 | fPressed = true;
122 | Invalidate();
123 | _ShowHistoryMenu();
124 | }
125 |
126 |
127 | void
128 | StatusView::MessageReceived(BMessage* message)
129 | {
130 | if(message->what == fGetMessage && message->IsReply()) {
131 | BPopUpMenu* menu = new BPopUpMenu("HistoryMenu", false, false);
132 |
133 | int32 count;
134 | if(message->GetInfo("mru", nullptr, &count) != B_OK) {
135 | BMenuItem* mi = new BMenuItem(B_TRANSLATE(""), nullptr);
136 | mi->SetEnabled(false);
137 | menu->AddItem(mi);
138 | } else {
139 | for(int32 i = count; i >= 0; --i) {
140 | BString item;
141 | if(message->FindString("mru", i, &item) == B_OK) {
142 | BMessage* msg = new BMessage((uint32) fApplyMessage);
143 | msg->AddInt32("item", i);
144 | BMenuItem* mi = new BMenuItem(item.String(), msg);
145 | menu->AddItem(mi);
146 | }
147 | }
148 | menu->AddSeparatorItem();
149 | BMenuItem* clear = new BMenuItem(B_TRANSLATE("Clear"),
150 | new BMessage((uint32) fClearMessage));
151 | menu->AddItem(clear);
152 | menu->SetTargetForItems(Window());
153 | }
154 |
155 | BPoint point = Parent()->Bounds().LeftBottom();
156 | point.x += 2; // border width
157 | point.y += 3 + ScrollView()->ScrollBar(B_HORIZONTAL)->Frame().Height();
158 | ConvertToScreen(&point);
159 | BRect clickToOpenRect(Parent()->Bounds());
160 | ConvertToScreen(&clickToOpenRect);
161 | menu->Go(point, true, true, clickToOpenRect);
162 | fPressed = false;
163 | delete menu;
164 | } else {
165 | BView::MessageReceived(message);
166 | }
167 | }
168 |
169 |
170 | float
171 | StatusView::Width()
172 | {
173 | return fButtonWidth + StringWidth(B_TRANSLATE(kLabel));
174 | }
175 |
176 |
177 | void
178 | StatusView::_DrawButton(BRect rect)
179 | {
180 | rgb_color baseColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
181 | B_LIGHTEN_1_TINT);
182 | uint32 flags = 0;
183 | if(fPressed)
184 | flags |= BControlLook::B_ACTIVATED;
185 | if(Window()->IsActive() == false)
186 | flags |= BControlLook::B_DISABLED;
187 | be_control_look->DrawButtonBackground(this, rect, rect, baseColor, flags,
188 | BControlLook::B_ALL_BORDERS, B_HORIZONTAL);
189 | rect.left += rect.right - ScrollView()->ScrollBar(B_HORIZONTAL)->Frame().Height() - 1;
190 | rect.bottom -= 2;
191 | be_control_look->DrawArrowShape(this, rect, rect, baseColor,
192 | BControlLook::B_DOWN_ARROW, flags, B_DARKEN_MAX_TINT);
193 | }
194 |
195 |
196 | void
197 | StatusView::_ShowHistoryMenu()
198 | {
199 | BMessenger windowMsgr(Window());
200 | windowMsgr.SendMessage(fGetMessage, this);
201 | }
202 |
203 | } // namespace find
204 |
--------------------------------------------------------------------------------
/src/find/FindStatusView.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2012, Haiku, Inc. All Rights Reserved.
3 | * Distributed under the terms of the MIT License.
4 | *
5 | * Authors:
6 | * Vlad Slepukhin
7 | * Siarzhuk Zharski
8 | *
9 | * Copied from Haiku commit a609673ce8c942d91e14f24d1d8832951ab27964.
10 | * Modifications:
11 | * Copyright 2018-2019 Kacper Kasper
12 | * Distributed under the terms of the MIT License.
13 | */
14 | #ifndef FIND_STATUS_VIEW_H
15 | #define FIND_STATUS_VIEW_H
16 |
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "StatusView.h"
23 |
24 |
25 | class BScrollView;
26 |
27 | namespace find {
28 |
29 | class StatusView : public controls::StatusView {
30 | public:
31 | StatusView(BScrollView* scrollView,
32 | uint32 getMessage, uint32 clearMessage,
33 | uint32 applyMessage);
34 | ~StatusView();
35 |
36 | virtual void Draw(BRect bounds);
37 | virtual void MouseDown(BPoint point);
38 | virtual void MessageReceived(BMessage* message);
39 |
40 | protected:
41 | virtual float Width();
42 |
43 | private:
44 | void _ShowHistoryMenu();
45 | void _DrawButton(BRect rect);
46 |
47 | private:
48 | bool fPressed;
49 | float fButtonWidth;
50 | uint32 fGetMessage;
51 | uint32 fClearMessage;
52 | uint32 fApplyMessage;
53 | };
54 |
55 | } // namespace find
56 |
57 | #endif // FIND_STATUS_VIEW_H
58 |
--------------------------------------------------------------------------------
/src/find/FindWindow.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2017 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #ifndef FINDWINDOW_H
7 | #define FINDWINDOW_H
8 |
9 |
10 | #include
11 |
12 | #include
13 | #include
14 | #include
15 |
16 |
17 | class BBox;
18 | class BButton;
19 | class BCheckBox;
20 | class BMessage;
21 | class BRadioButton;
22 | class BStringView;
23 | namespace find {
24 | class ScintillaView;
25 | }
26 |
27 |
28 | enum {
29 | FINDWINDOW_FIND = 'fwfd',
30 | FINDWINDOW_REPLACE = 'fwrp',
31 | FINDWINDOW_REPLACEFIND = 'fwrf',
32 | FINDWINDOW_REPLACEALL = 'fwra',
33 | FINDWINDOW_QUITTING = 'FWQU'
34 | };
35 |
36 |
37 | class FindWindow : public BWindow {
38 | public:
39 | FindWindow(BMessage *state, BPath settingsPath);
40 | ~FindWindow();
41 |
42 | void MessageReceived(BMessage* message);
43 | void WindowActivated(bool active);
44 | void Quit();
45 |
46 | void SetFindText(const std::string text);
47 |
48 | private:
49 | enum Actions {
50 | MATCH_CASE = 'mtcs',
51 | MATCH_WORD = 'mtwd',
52 | WRAP_AROUND = 'wrar',
53 | BACKWARDS = 'back',
54 | IN_SELECTION = 'insl',
55 | REGEX = 'rege'
56 | };
57 | enum HistoryRequests {
58 | GET_FIND_HISTORY = 'fmru',
59 | GET_REPLACE_HISTORY = 'rmru',
60 | CLEAR_FIND_HISTORY = 'cfmr',
61 | CLEAR_REPLACE_HISTORY = 'crmr',
62 | APPLY_FIND_ITEM = 'afit',
63 | APPLY_REPLACE_ITEM = 'arit'
64 | };
65 | void _InitInterface();
66 | void _LoadHistory();
67 | void _SaveHistory();
68 |
69 | BStringView* fFindString;
70 | find::ScintillaView* fFindTC;
71 | BStringView* fReplaceString;
72 | find::ScintillaView* fReplaceTC;
73 |
74 | BButton* fFindButton;
75 | BButton* fReplaceButton;
76 | BButton* fReplaceFindButton;
77 | BButton* fReplaceAllButton;
78 |
79 | BCheckBox* fMatchCaseCB;
80 | BCheckBox* fMatchWordCB;
81 | BCheckBox* fWrapAroundCB;
82 | BCheckBox* fBackwardsCB;
83 | BCheckBox* fInSelectionCB;
84 | BCheckBox* fRegexCB;
85 |
86 | BPath fSettingsPath;
87 | BMessage fFindHistory;
88 | BMessage fReplaceHistory;
89 |
90 | bool fFlagsChanged;
91 | std::string fOldFindText;
92 | std::string fOldReplaceText;
93 | };
94 |
95 |
96 | #endif // FINDWINDOW_H
97 |
--------------------------------------------------------------------------------
/src/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #include "App.h"
7 |
8 | #include
9 |
10 | #include
11 |
12 | #include "Utils.h"
13 |
14 |
15 | int
16 | main(int argc, char** argv)
17 | {
18 | std::string arg1 = argc > 1 ? argv[1] : "";
19 | if(argc > 1 && (arg1 == "-h" || arg1 == "--help")) {
20 | fprintf(stderr, "Usage: Koder [options] file...\n");
21 | fprintf(stderr, "Options:\n");
22 | fprintf(stderr, " -h, --help\t\tPrints this message.\n");
23 | fprintf(stderr, " -w, --wait\t\tWait for the window to quit before "
24 | "returning.\n"
25 | "\t\t\tOpening in window stacks is not supported in this mode.\n"
26 | "\t\t\tCurrently accepts only one filename.\n");
27 | return 1;
28 | }
29 |
30 | if(argc > 1 && (arg1 == "-w" || arg1 == "--wait")) {
31 | if(argc > 3) {
32 | fprintf(stderr, "Koder accepts only one filename when launching "
33 | "in --wait mode.\n");
34 | return 1;
35 | }
36 | BRoster roster;
37 | team_id team = roster.TeamFor(gAppMime);
38 | if(team == B_ERROR) {
39 | BMessage* suppressMessage = new BMessage(SUPPRESS_INITIAL_WINDOW);
40 | status_t status = roster.Launch(gAppMime, suppressMessage, &team);
41 | delete suppressMessage;
42 | if(status != B_OK && status != B_ALREADY_RUNNING) {
43 | fprintf(stderr, "An issue occured while trying to launch Koder.\n");
44 | return 1;
45 | }
46 | }
47 | BMessage windowMessage(WINDOW_NEW_WITH_QUIT_REPLY);
48 | // parse filename if any
49 | // TODO: support -- for piping
50 | if(argc > 2) {
51 | int32 line, column;
52 | std::string filename = ParseFileArgument(argv[2], &line, &column);
53 | if(filename.find('/') != 0) {
54 | BPath absolute(".", filename.c_str(), true);
55 | filename = absolute.Path();
56 | }
57 | entry_ref ref;
58 | BEntry(filename.c_str()).GetRef(&ref);
59 | windowMessage.AddRef("refs", &ref);
60 | if(line != -1) {
61 | windowMessage.AddInt32("be:line", line);
62 | }
63 | if(column != -1) {
64 | windowMessage.AddInt32("be:column", column);
65 | }
66 | }
67 | BMessenger messenger(gAppMime, team);
68 | BMessage reply;
69 | messenger.SendMessage(&windowMessage, &reply);
70 | return 0;
71 | } else {
72 | App* app = new App();
73 | app->Init();
74 | app->Run();
75 | delete app;
76 |
77 | return 0;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/preferences/AppPreferencesWindow.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2019 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #ifndef APPPREFERENCESWINDOW_H
7 | #define APPPREFERENCESWINDOW_H
8 |
9 |
10 | #include
11 |
12 |
13 | class BBox;
14 | class BButton;
15 | class BCheckBox;
16 | class BPopUpMenu;
17 | class BMenuField;
18 | class BMessage;
19 | class BRadioButton;
20 | class BSpinner;
21 | class BStringView;
22 | class BTextControl;
23 | class BView;
24 | class Preferences;
25 |
26 |
27 | const uint32 APP_PREFERENCES_CHANGED = 'apch';
28 | const uint32 APP_PREFERENCES_QUITTING = 'APQU';
29 |
30 |
31 | class AppPreferencesWindow : public BWindow {
32 | public:
33 | AppPreferencesWindow(Preferences* preferences);
34 | ~AppPreferencesWindow();
35 |
36 | void MessageReceived(BMessage* message);
37 | void Quit();
38 |
39 | private:
40 | enum Actions {
41 | COMPACT_LANG_MENU = 'clnm',
42 | TOOLBAR = 'tlbr',
43 | TOOLBAR_ICON_SIZE = 'tlis',
44 | FULL_PATH_IN_TITLE = 'fpit',
45 | TABS_TO_SPACES = 'ttsp',
46 | TAB_WIDTH = 'tbwd',
47 | LINE_HIGHLIGHTING = 'lhlt',
48 | LINE_HIGHLIGHTING_BG = 'lhlb',
49 | LINE_HIGHLIGHTING_FRAME = 'lhlf',
50 |
51 | LINE_NUMBERS = 'lnum',
52 | FOLD_MARGIN = 'fldm',
53 | BOOKMARK_MARGIN = 'bkmm',
54 |
55 | LINELIMIT_COLUMN = 'llcl',
56 | LINELIMIT_SHOW = 'llsh',
57 | LINELIMIT_BACKGROUND = 'llbk',
58 | LINELIMIT_LINE = 'llln',
59 |
60 | INDENTGUIDES_SHOW = 'igsh',
61 | INDENTGUIDES_REAL = 'igrl',
62 | INDENTGUIDES_FORWARD = 'igfw',
63 | INDENTGUIDES_BOTH = 'igbo',
64 |
65 | BRACES_HIGHLIGHTING = 'bhlt',
66 |
67 | EDITOR_STYLE = 'styl',
68 |
69 | ATTACH_WINDOWS = 'atwn',
70 | HIGHLIGHT_TRAILING_WS = 'hltw',
71 | TRIM_TRAILING_WS_SAVE = 'ttws',
72 |
73 | USE_EDITORCONFIG = 'uecf',
74 | APPEND_NL_AT_THE_END = 'apae',
75 | ALWAYS_OPEN_IN_NEW_WINDOW='aonw',
76 | USE_CUSTOM_FONT = 'ucfn',
77 | FONT_CHANGED = 'fnch',
78 | FONT_SIZE_CHANGED = 'fsch',
79 |
80 | REVERT = 'rvrt'
81 | };
82 |
83 | void _InitInterface();
84 | void _SyncPreferences(Preferences* preferences);
85 |
86 | void _PreferencesModified();
87 | void _SetLineLimitBoxEnabled(bool enabled);
88 | void _SetLineHighlightingBoxEnabled(bool enabled);
89 | void _SetIndentGuidesBoxEnabled(bool enabled);
90 | void _SetFontBoxEnabled(bool enabled);
91 | void _SetToolbarBoxEnabled(bool enabled);
92 | void _PopulateStylesMenu();
93 | void _UpdateFontMenu();
94 |
95 | Preferences* fStartPreferences;
96 | Preferences* fPreferences;
97 |
98 | BBox* fVisualBox;
99 | BBox* fBehaviorBox;
100 | BBox* fIndentationBox;
101 | BBox* fTrailingWSBox;
102 |
103 | BCheckBox* fCompactLangMenuCB;
104 | BCheckBox* fFullPathInTitleCB;
105 | BCheckBox* fTabsToSpacesCB;
106 | BTextControl* fTabWidthTC;
107 | BBox* fLineHighlightingBox;
108 | BCheckBox* fLineHighlightingCB;
109 | BRadioButton* fLineHighlightingBackgroundRadio;
110 | BRadioButton* fLineHighlightingFrameRadio;
111 |
112 | BBox* fToolbarBox;
113 | BCheckBox* fToolbarCB;
114 | BPopUpMenu* fToolbarIconSizeMenu;
115 | BMenuField* fToolbarIconSizeMF;
116 |
117 | BBox* fMarginsBox;
118 | BCheckBox* fLineNumbersCB;
119 | BCheckBox* fFoldMarginCB;
120 | BCheckBox* fBookmarkMarginCB;
121 |
122 | BCheckBox* fLineLimitShowCB;
123 | BTextControl* fLineLimitColumnTC;
124 |
125 | BBox* fLineLimitBox;
126 |
127 | BRadioButton* fLineLimitBackgroundRadio;
128 | BRadioButton* fLineLimitLineRadio;
129 |
130 | BBox* fIndentGuidesBox;
131 | BCheckBox* fIndentGuidesShowCB;
132 | BRadioButton* fIndentGuidesRealRadio;
133 | BRadioButton* fIndentGuidesLookForwardRadio;
134 | BRadioButton* fIndentGuidesLookBothRadio;
135 |
136 | BCheckBox* fBracesHighlightingCB;
137 |
138 | BPopUpMenu* fEditorStyleMenu;
139 | BMenuField* fEditorStyleMF;
140 |
141 | BCheckBox* fAttachNewWindowsCB;
142 | BCheckBox* fHighlightTrailingWSCB;
143 | BCheckBox* fTrimTrailingWSOnSaveCB;
144 |
145 | BCheckBox* fUseEditorconfigCB;
146 | BCheckBox* fAlwaysOpenInNewWindowCB;
147 | BCheckBox* fAppendNLAtTheEndCB;
148 |
149 | BBox* fFontBox;
150 | BCheckBox* fUseCustomFontCB;
151 | BMenuField* fFontMF;
152 | BSpinner* fFontSizeSpinner;
153 | BPopUpMenu* fFontMenu;
154 |
155 | BButton* fRevertButton;
156 | };
157 |
158 |
159 | #endif // APPPREFERENCESWINDOW_H
160 |
--------------------------------------------------------------------------------
/src/preferences/Preferences.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #include "Preferences.h"
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #include "Languages.h"
13 | #include "File.h"
14 | #include "Utils.h"
15 |
16 |
17 | #undef B_TRANSLATION_CONTEXT
18 | #define B_TRANSLATION_CONTEXT "Preferences"
19 |
20 |
21 | namespace {
22 | const char* kErrorTitle = B_TRANSLATE_MARK("Editor settings");
23 | const char* kErrorUnknown = B_TRANSLATE_MARK("Unknown error.");
24 | const char* kErrorBadValue[] = {
25 | B_TRANSLATE_MARK("Something wrong has happened while opening the "
26 | "configuration file. Your personal settings will not be %s%."),
27 | B_TRANSLATE_MARK_COMMENT("loaded", "settings will not be _"),
28 | B_TRANSLATE_MARK_COMMENT("saved", "settings will not be _")
29 | };
30 | const char* kErrorAccessDenied[] = {
31 | B_TRANSLATE_MARK("Access was denied while opening the configuration "
32 | "file. Make sure you have %s% permission for your settings "
33 | "directory."),
34 | B_TRANSLATE_MARK_COMMENT("read", "Make sure you have _ permission for"),
35 | B_TRANSLATE_MARK_COMMENT("write", "Make sure you have _ permission for")
36 | };
37 | const char* kErrorNoMemory[] = {
38 | B_TRANSLATE_MARK("There is not enough memory available to %s% the "
39 | "configuration file. Try closing a few applications and restart "
40 | "the editor."),
41 | B_TRANSLATE_MARK_COMMENT("load", "to _ the configuration"),
42 | B_TRANSLATE_MARK_COMMENT("save", "to _ the configuration")
43 | };
44 | }
45 |
46 |
47 | std::shared_ptr
48 | Preferences::_OpenFile(const char* filename, uint32 openMode)
49 | {
50 | if (openMode == B_WRITE_ONLY)
51 | openMode |= B_CREATE_FILE | B_ERASE_FILE;
52 | const int index = (openMode == B_READ_ONLY) ? 1 : 2;
53 | auto file = std::make_shared(filename, openMode);
54 | status_t result = file->InitCheck();
55 | if (result != B_OK) {
56 | BString error = B_TRANSLATE(kErrorUnknown);
57 | switch (result) {
58 | case B_BAD_VALUE:
59 | error = B_TRANSLATE(kErrorBadValue[0]);
60 | error.ReplaceFirst("%s%", B_TRANSLATE(kErrorBadValue[index]));
61 | break;
62 | case B_PERMISSION_DENIED:
63 | error = B_TRANSLATE(kErrorAccessDenied[0]);
64 | error.ReplaceFirst("%s%", B_TRANSLATE(kErrorAccessDenied[index]));
65 | break;
66 | case B_NO_MEMORY:
67 | error = B_TRANSLATE(kErrorNoMemory[0]);
68 | error.ReplaceFirst("%s%", B_TRANSLATE(kErrorNoMemory[index]));
69 | break;
70 | default:
71 | // if opened for reading and not found don't throw "Unknown error."
72 | if(index == 1)
73 | return std::shared_ptr();
74 | }
75 | OKAlert(B_TRANSLATE(kErrorTitle), error, B_WARNING_ALERT);
76 | return std::shared_ptr();
77 | }
78 | return file;
79 | }
80 |
81 |
82 | void
83 | Preferences::Load(const char* filename)
84 | {
85 | auto file = _OpenFile(filename, B_READ_ONLY);
86 | BMessage storage;
87 | if (file)
88 | storage.Unflatten(file.get());
89 | fTabWidth = storage.GetUInt8("tabWidth", 4);
90 | fTabsToSpaces = storage.GetBool("tabsToSpaces", false);
91 | fLineHighlighting = storage.GetBool("lineHighlighting", true);
92 | fLineHighlightingMode = storage.GetUInt8("lineHighlightingMode", 0);
93 | fLineNumbers = storage.GetBool("lineNumbers", true);
94 | fFoldMargin = storage.GetBool("foldMargin", true);
95 | fBookmarkMargin = storage.GetBool("bookmarkMargin", true);
96 | fIndentGuidesShow = storage.GetBool("indentGuidesShow", true);
97 | fIndentGuidesMode = storage.GetUInt8("indentGuidesMode", 1); // SC_IV_REAL
98 | fWhiteSpaceVisible = storage.GetBool("whiteSpaceVisible", false);
99 | fEOLVisible = storage.GetBool("EOLVisible", false);
100 | fLineLimitShow = storage.GetBool("lineLimitShow", false);
101 | fLineLimitMode = storage.GetUInt8("lineLimitMode", 1); // EDGE_LINE
102 | fLineLimitColumn = storage.GetUInt32("lineLimitColumn", 80);
103 | fWrapLines = storage.GetBool("wrapLines", false);
104 | fBracesHighlighting = storage.GetBool("bracesHighlighting", true);
105 | fFullPathInTitle = storage.GetBool("fullPathInTitle", true);
106 | fCompactLangMenu = storage.GetBool("compactLangMenu", true);
107 | fToolbar = storage.GetBool("toolbar", true);
108 | fOpenWindowsInStack = storage.GetBool("openWindowsInStack", true);
109 | fHighlightTrailingWhitespace = storage.GetBool("highlightTrailingWhitespace", false);
110 | fTrimTrailingWhitespaceOnSave = storage.GetBool("trimTrailingWhitespaceOnSave", false);
111 | fAppendNLAtTheEndIfNotPresent = storage.GetBool("appendNLAtTheEndIfNotPresent", true);
112 | fStyle = storage.GetString("style", "default");
113 | fWindowRect = storage.GetRect("windowRect", BRect(50, 50, 450, 450));
114 | fUseEditorconfig = storage.GetBool("useEditorconfig", true);
115 | fAlwaysOpenInNewWindow = storage.GetBool("alwaysOpenInNewWindow", false);
116 | fUseCustomFont = storage.GetBool("useCustomFont", false);
117 | fFontFamily = storage.GetString("fontFamily", "Noto Sans Mono");
118 | fFontSize = storage.GetUInt8("fontSize", 12);
119 | fToolbarIconSizeMultiplier = storage.GetUInt8("toolbarIconSizeMultiplier", 3);
120 | if(storage.FindMessage("findWindowState", &fFindWindowState) != B_OK)
121 | fFindWindowState = BMessage();
122 | }
123 |
124 |
125 | void
126 | Preferences::Save(const char* filename)
127 | {
128 | BackupFileGuard backupGuard(filename);
129 |
130 | auto file = _OpenFile(filename, B_WRITE_ONLY);
131 | BMessage storage;
132 | storage.AddUInt8("tabWidth", fTabWidth);
133 | storage.AddBool("tabsToSpaces", fTabsToSpaces);
134 | storage.AddBool("lineHighlighting", fLineHighlighting);
135 | storage.AddUInt8("lineHighlightingMode", fLineHighlightingMode);
136 | storage.AddBool("lineNumbers", fLineNumbers);
137 | storage.AddBool("foldMargin", fFoldMargin);
138 | storage.AddBool("bookmarkMargin", fBookmarkMargin);
139 | storage.AddBool("whiteSpaceVisible", fWhiteSpaceVisible);
140 | storage.AddBool("EOLVisible", fEOLVisible);
141 | storage.AddBool("indentGuidesShow", fIndentGuidesShow);
142 | storage.AddUInt8("indentGuidesMode", fIndentGuidesMode);
143 | storage.AddBool("lineLimitShow", fLineLimitShow);
144 | storage.AddUInt8("lineLimitMode", fLineLimitMode);
145 | storage.AddUInt32("lineLimitColumn", fLineLimitColumn);
146 | storage.AddBool("wrapLines", fWrapLines);
147 | storage.AddBool("bracesHighlighting", fBracesHighlighting);
148 | storage.AddBool("fullPathInTitle", fFullPathInTitle);
149 | storage.AddBool("compactLangMenu", fCompactLangMenu);
150 | storage.AddBool("toolbar", fToolbar);
151 | storage.AddBool("openWindowsInStack", fOpenWindowsInStack);
152 | storage.AddBool("highlightTrailingWhitespace", fHighlightTrailingWhitespace);
153 | storage.AddBool("trimTrailingWhitespaceOnSave", fTrimTrailingWhitespaceOnSave);
154 | storage.AddBool("appendNLAtTheEndIfNotPresent", fAppendNLAtTheEndIfNotPresent);
155 | storage.AddString("style", fStyle.c_str());
156 | storage.AddRect("windowRect", fWindowRect);
157 | storage.AddMessage("findWindowState", &fFindWindowState);
158 | storage.AddBool("alwaysOpenInNewWindow", fAlwaysOpenInNewWindow);
159 | storage.AddBool("useEditorconfig", fUseEditorconfig);
160 | storage.AddBool("useCustomFont", fUseCustomFont);
161 | storage.AddString("fontFamily", fFontFamily.c_str());
162 | storage.AddUInt8("fontSize", fFontSize);
163 | storage.AddUInt8("toolbarIconSizeMultiplier", fToolbarIconSizeMultiplier);
164 | if (file) {
165 | storage.Flatten(file.get());
166 | backupGuard.SaveSuccessful();
167 | }
168 | }
169 |
170 |
171 | Preferences&
172 | Preferences::operator =(Preferences& p)
173 | {
174 | fSettingsPath = p.fSettingsPath;
175 | fTabWidth = p.fTabWidth;
176 | fTabsToSpaces = p.fTabsToSpaces;
177 | fLineHighlighting = p.fLineHighlighting;
178 | fLineHighlightingMode = p.fLineHighlightingMode;
179 | fLineNumbers = p.fLineNumbers;
180 | fFoldMargin = p.fFoldMargin;
181 | fBookmarkMargin = p.fBookmarkMargin;
182 | fEOLVisible = p.fEOLVisible;
183 | fWhiteSpaceVisible = p.fWhiteSpaceVisible;
184 | fIndentGuidesShow = p.fIndentGuidesShow;
185 | fIndentGuidesMode = p.fIndentGuidesMode;
186 | fLineLimitShow = p.fLineLimitShow;
187 | fLineLimitMode = p.fLineLimitMode;
188 | fLineLimitColumn = p.fLineLimitColumn;
189 | fWrapLines = p.fWrapLines;
190 | fBracesHighlighting = p.fBracesHighlighting;
191 | fFullPathInTitle = p.fFullPathInTitle;
192 | fCompactLangMenu = p.fCompactLangMenu;
193 | fToolbar = p.fToolbar;
194 | fOpenWindowsInStack = p.fOpenWindowsInStack;
195 | fHighlightTrailingWhitespace = p.fHighlightTrailingWhitespace;
196 | fTrimTrailingWhitespaceOnSave = p.fTrimTrailingWhitespaceOnSave;
197 | fAppendNLAtTheEndIfNotPresent = p.fAppendNLAtTheEndIfNotPresent;
198 | fStyle = p.fStyle;
199 | fWindowRect = p.fWindowRect;
200 | fFindWindowState = p.fFindWindowState;
201 | fAlwaysOpenInNewWindow = p.fAlwaysOpenInNewWindow;
202 | fUseCustomFont = p.fUseCustomFont;
203 | fFontFamily = p.fFontFamily;
204 | fFontSize = p.fFontSize;
205 | fToolbarIconSizeMultiplier = p.fToolbarIconSizeMultiplier;
206 | fUseEditorconfig = p.fUseEditorconfig;
207 |
208 | return *this;
209 | }
210 |
--------------------------------------------------------------------------------
/src/preferences/Preferences.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #ifndef PREFERENCES_H
7 | #define PREFERENCES_H
8 |
9 |
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 |
17 | class BFile;
18 |
19 |
20 | class Preferences {
21 | private:
22 | std::shared_ptr _OpenFile(const char* filename, uint32 openMode);
23 |
24 | public:
25 | void Load(const char* filename);
26 | void Save(const char* filename);
27 |
28 | Preferences& operator =(Preferences& p);
29 |
30 | BPath fSettingsPath;
31 |
32 | // file specific
33 | uint8 fTabWidth;
34 | bool fTabsToSpaces;
35 | // broadcast to all editors
36 | bool fLineHighlighting;
37 | uint8 fLineHighlightingMode;
38 | bool fLineNumbers;
39 | bool fFoldMargin;
40 | bool fBookmarkMargin;
41 | bool fEOLVisible;
42 | bool fWhiteSpaceVisible;
43 | bool fIndentGuidesShow;
44 | uint8 fIndentGuidesMode;
45 | bool fLineLimitShow;
46 | uint8 fLineLimitMode;
47 | uint32 fLineLimitColumn;
48 | bool fWrapLines;
49 | bool fBracesHighlighting;
50 | bool fFullPathInTitle;
51 | bool fCompactLangMenu;
52 | bool fToolbar;
53 | bool fOpenWindowsInStack;
54 | bool fHighlightTrailingWhitespace;
55 | bool fTrimTrailingWhitespaceOnSave;
56 | bool fAppendNLAtTheEndIfNotPresent;
57 | bool fUseEditorconfig;
58 | bool fAlwaysOpenInNewWindow;
59 | bool fUseCustomFont;
60 | std::string fFontFamily;
61 | uint8 fFontSize;
62 | uint8 fToolbarIconSizeMultiplier;
63 | std::string fStyle;
64 | // application state
65 | BRect fWindowRect;
66 | BMessage fFindWindowState;
67 | };
68 |
69 |
70 | #endif // PREFERENCES_H
71 |
--------------------------------------------------------------------------------
/src/support/Editorconfig.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #include "Editorconfig.h"
7 |
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 | #include
16 | #include
17 |
18 |
19 | bool
20 | Editorconfig::Find(BPath* filePath, BPath* editorconfigPath)
21 | {
22 | if(filePath == nullptr) return false;
23 |
24 | bool found = false;
25 | BPath parentPath(*filePath);
26 | BDirectory parentDir;
27 | BEntry editorconfigFile;
28 | do {
29 | parentPath.GetParent(&parentPath);
30 | parentDir.SetTo(parentPath.Path());
31 | editorconfigFile.SetTo(&parentDir, ".editorconfig");
32 | found = editorconfigFile.Exists();
33 | } while(!found && !parentDir.IsRootDirectory());
34 | if(found && editorconfigPath != nullptr) {
35 | editorconfigFile.GetPath(editorconfigPath);
36 | }
37 | return found;
38 | }
39 |
40 |
41 | bool
42 | Editorconfig::Parse(const char* filename, BMessage* propertiesDict)
43 | {
44 | if(propertiesDict == nullptr) return false;
45 |
46 | std::ifstream file(filename, std::ifstream::in);
47 | if(!file.is_open()) return false;
48 |
49 | std::string currentSectionName;
50 | BMessage currentSection;
51 |
52 | std::string line;
53 | do {
54 | std::getline(file, line);
55 | if(line.empty() || line[0] == '#' || line[0] == ';') continue;
56 | if(line[0] == '[' && line[line.size() - 1] == ']') {
57 | // section
58 | if(!currentSectionName.empty() && !currentSection.IsEmpty()) {
59 | propertiesDict->AddMessage(currentSectionName.c_str(), ¤tSection);
60 | currentSection.MakeEmpty();
61 | }
62 | currentSectionName = line.substr(1, line.size() - 2);
63 | } else {
64 | // property
65 | std::string name, value;
66 | line.erase(std::remove_if(line.begin(), line.end(), [](char x) { return std::isspace(x); }), line.end());
67 | std::istringstream linestream(line);
68 | std::getline(linestream, name, '=');
69 | std::getline(linestream, value, '=');
70 | currentSection.AddString(name.c_str(), value.c_str());
71 | }
72 | } while(!file.eof());
73 | if(!currentSectionName.empty() && !currentSection.IsEmpty()) {
74 | propertiesDict->AddMessage(currentSectionName.c_str(), ¤tSection);
75 | }
76 | file.close();
77 | return true;
78 | }
79 |
80 |
81 | void
82 | Editorconfig::MatchFilename(const char* filename, const BMessage* allProperties,
83 | BMessage* properties)
84 | {
85 | if(allProperties == nullptr) return;
86 |
87 | char* name;
88 | uint32 type;
89 | int32 count;
90 | for(int32 i = 0;
91 | allProperties->GetInfo(B_MESSAGE_TYPE, i, &name, &type, &count) == B_OK;
92 | i++) {
93 | BString regexStr(name);
94 | bool dirSpecific = false;
95 | int32 slashIndex = regexStr.FindFirst("/");
96 | if(slashIndex != B_ERROR && slashIndex > 0 && regexStr[slashIndex - 1] != '\\')
97 | dirSpecific = true;
98 | int32 inBraceCount = 0;
99 | int32 c = 0;
100 | while(c < regexStr.Length()) {
101 | if(regexStr[c] == '*') {
102 | if(c > 0 && regexStr[c - 1] == '\\') {
103 | c++;
104 | continue;
105 | }
106 | // **
107 | if(c < regexStr.Length() - 1 && regexStr[c + 1] == '*') {
108 | regexStr.Replace("**", "(.+)", 1, c);
109 | c += strlen("(.+)");
110 | } else {
111 | BString s;
112 | if(dirSpecific) s = "([^/]+)";
113 | else s = "(.+)";
114 | regexStr.Replace("*", s, 1, c);
115 | c += s.Length();
116 | }
117 | continue;
118 | } else if(regexStr[c] == '!') {
119 | // FIXME: only if in []?
120 | if(c > 0 && regexStr[c - 1] == '\\') {
121 | c++;
122 | continue;
123 | }
124 | regexStr.Replace("!", "^", 1, c);
125 | } else if(regexStr[c] == '.') {
126 | regexStr.Replace(".", "\\.", 1, c);
127 | c += 2;
128 | continue;
129 | }
130 | if(regexStr[c] == '{') {
131 | if(c > 0 && regexStr[c - 1] == '\\') {
132 | c++;
133 | continue;
134 | }
135 | inBraceCount++;
136 | regexStr.Replace("{", "(", 1, c);
137 | }
138 | if(inBraceCount > 0) {
139 | if(c > 0 && regexStr[c - 1] == '\\') {
140 | c++;
141 | continue;
142 | }
143 | if(regexStr[c] == ',')
144 | regexStr.Replace(",", "|", 1, c);
145 | if(regexStr[c] == '}') {
146 | inBraceCount--;
147 | regexStr.Replace("}", ")", 1, c);
148 | }
149 | }
150 | c++;
151 | }
152 |
153 | if(inBraceCount != 0) return;
154 |
155 | std::regex expr(regexStr.String());
156 | if(properties != nullptr && std::regex_match(filename, expr)) {
157 | BMessage globProperties;
158 | if(allProperties->FindMessage(name, &globProperties) == B_OK) {
159 | char* stringName;
160 | for(int32 j = 0;
161 | globProperties.GetInfo(B_STRING_TYPE, j, &stringName, &type, &count) == B_OK;
162 | j++) {
163 | BString value;
164 | globProperties.FindString(stringName, &value);
165 | properties->RemoveName(stringName);
166 | properties->AddString(stringName, value);
167 | }
168 | }
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/src/support/Editorconfig.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 | #ifndef EDITORCONFIG_H
6 | #define EDITORCONFIG_H
7 |
8 |
9 | #include
10 | #include
11 |
12 |
13 | class Editorconfig {
14 | public:
15 | static bool Find(BPath* filePath, BPath* editorconfigPath);
16 | static bool Parse(const char* filename, BMessage* propertiesDict);
17 | static void MatchFilename(const char* filename,
18 | const BMessage* allProperties, BMessage* properties);
19 | };
20 |
21 |
22 | #endif // EDITORCONFIG_H
23 |
--------------------------------------------------------------------------------
/src/support/File.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 |
7 | #include "File.h"
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | #include
17 | #include
18 |
19 |
20 | namespace {
21 |
22 | const std::string kCaretPositionAttribute = "be:caret_position";
23 | const std::string kBookmarksAttribute = "koder:bookmarks";
24 |
25 | }
26 |
27 |
28 | using Entry = BPrivate::BEntryOperationEngineBase::Entry;
29 |
30 |
31 | File::File(const entry_ref* ref, uint32 openMode)
32 | :
33 | BFile(ref, openMode)
34 | {
35 | }
36 |
37 |
38 | File::File(const BEntry* entry, uint32 openMode)
39 | :
40 | BFile(entry, openMode)
41 | {
42 | }
43 |
44 |
45 | File::File(const char* path, uint32 openMode)
46 | :
47 | BFile(path, openMode)
48 | {
49 | }
50 |
51 |
52 | std::vector
53 | File::Read()
54 | {
55 | off_t size;
56 | GetSize(&size);
57 | std::vector buffer(size + 1);
58 | BFile::Read(buffer.data(), buffer.size());
59 | buffer[size] = 0;
60 | return buffer;
61 | }
62 |
63 |
64 | void
65 | File::Write(std::vector &buffer)
66 | {
67 | BFile::Write(buffer.data(), buffer.size() - 1);
68 | }
69 |
70 |
71 | void
72 | File::WriteCaretPosition(int32 caretPos)
73 | {
74 | BFile::WriteAttr(kCaretPositionAttribute.c_str(), B_INT32_TYPE, 0,
75 | &caretPos, sizeof(int32));
76 | }
77 |
78 |
79 | int32
80 | File::ReadCaretPosition()
81 | {
82 | int32 caretPos = 0;
83 | BFile::ReadAttr(kCaretPositionAttribute.c_str(), B_INT32_TYPE, 0,
84 | &caretPos, sizeof(int32));
85 | return caretPos;
86 | }
87 |
88 |
89 | void
90 | File::WriteMimeType(std::string mimeType)
91 | {
92 | BNodeInfo info(this);
93 | info.SetType(mimeType.c_str());
94 | }
95 |
96 |
97 | std::string
98 | File::ReadMimeType()
99 | {
100 | std::string mimeType(B_MIME_TYPE_LENGTH, 0);
101 | BNodeInfo info(this);
102 | info.GetType(mimeType.data());
103 | return mimeType;
104 | }
105 |
106 |
107 | void
108 | File::WriteBookmarks(BMessage bookmarks)
109 | {
110 | BMallocIO mallocIO;
111 | bookmarks.Flatten(&mallocIO);
112 | BFile::WriteAttr(kBookmarksAttribute.c_str(), B_MESSAGE_TYPE, 0,
113 | mallocIO.Buffer(), mallocIO.BufferLength());
114 | }
115 |
116 |
117 | BMessage
118 | File::ReadBookmarks()
119 | {
120 | BMessage bookmarks;
121 | attr_info info;
122 | BFile::GetAttrInfo(kBookmarksAttribute.c_str(), &info);
123 | if(info.type == B_MESSAGE_TYPE) {
124 | std::vector buffer(info.size);
125 | BFile::ReadAttr(kBookmarksAttribute.c_str(), B_MESSAGE_TYPE, 0,
126 | buffer.data(), buffer.size());
127 | BMemoryIO memIO(buffer.data(), buffer.size());
128 | bookmarks.Unflatten(&memIO);
129 | }
130 | return bookmarks;
131 | }
132 |
133 |
134 | status_t
135 | File::Monitor(bool enable, BHandler* handler)
136 | {
137 | return File::Monitor(this, enable, handler);
138 | }
139 |
140 |
141 | status_t
142 | File::Monitor(BStatable* file, bool enable, BHandler* handler)
143 | {
144 | if(file == nullptr)
145 | return B_BAD_VALUE;
146 |
147 | uint32 flags = (enable ? B_WATCH_NAME | B_WATCH_STAT : B_STOP_WATCHING);
148 | node_ref nref;
149 | file->GetNodeRef(&nref);
150 | return watch_node(&nref, flags, handler);
151 | }
152 |
153 |
154 | bool
155 | File::CanWrite(BStatable* file)
156 | {
157 | if(file == nullptr)
158 | return false;
159 |
160 | BVolume volume;
161 | if(file->GetVolume(&volume) < B_OK) {
162 | return false;
163 | }
164 | if(volume.IsReadOnly()) {
165 | return false;
166 | }
167 |
168 | mode_t permissions;
169 | if(file->GetPermissions(&permissions) < B_OK) {
170 | return false;
171 | }
172 |
173 | if(permissions & (S_IWUSR | S_IWGRP | S_IWOTH)) {
174 | return true;
175 | }
176 | return false;
177 | }
178 |
179 |
180 | BackupFileGuard::BackupFileGuard(const char* path, BHandler* handler)
181 | :
182 | fPath(path ? path : ""),
183 | fSuccess(false)
184 | {
185 | // TODO: more random backup name
186 | if(fPath.empty())
187 | return;
188 |
189 | if(BEntry(fPath.c_str()).Exists() == false) {
190 | fPath = "";
191 | return;
192 | }
193 |
194 | BCopyEngine copier;
195 | Entry src(fPath.c_str());
196 | Entry dest((fPath + "~").c_str());
197 | copier.CopyEntry(src, dest);
198 | }
199 |
200 |
201 | BackupFileGuard::~BackupFileGuard()
202 | {
203 | if(fPath.empty() || !fSuccess)
204 | return;
205 |
206 | BEntry((fPath + "~").c_str()).Remove();
207 | }
208 |
209 |
210 | void
211 | BackupFileGuard::SaveSuccessful()
212 | {
213 | fSuccess = true;
214 | }
215 |
--------------------------------------------------------------------------------
/src/support/File.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 | #ifndef FILE_H
6 | #define FILE_H
7 |
8 |
9 | #include
10 | #include
11 |
12 | #include
13 | #include
14 |
15 |
16 | struct entry_ref;
17 | class BEntry;
18 |
19 |
20 | class File : public BFile {
21 | public:
22 | File(const entry_ref* ref, uint32 openMode);
23 | File(const BEntry* entry, uint32 openMode);
24 | File(const char* path, uint32 openMode);
25 |
26 | std::vector Read();
27 | void Write(std::vector &buffer);
28 |
29 | int32 ReadCaretPosition();
30 | void WriteCaretPosition(int32 caretPos);
31 | std::string ReadMimeType();
32 | void WriteMimeType(std::string mimeType);
33 | BMessage ReadBookmarks();
34 | void WriteBookmarks(BMessage bookmarks);
35 |
36 | status_t Monitor(bool enable, BHandler* handler);
37 |
38 | static status_t Monitor(BStatable* file, bool enable,
39 | BHandler* handler);
40 | static bool CanWrite(BStatable* file);
41 | };
42 |
43 |
44 | /**
45 | * BackupFileGuard will create a backup of a file and let it exist until the
46 | * guard goes out of scope. If SaveSuccessful() checkpoint is not reached
47 | * (for example the program crashed or an exception was thrown) the backup file
48 | * will not be removed.
49 | * If path does not exist or is empty does nothing.
50 | */
51 | class BackupFileGuard {
52 | public:
53 | BackupFileGuard(const char* path, BHandler *handler = nullptr);
54 | ~BackupFileGuard();
55 |
56 | void SaveSuccessful();
57 | private:
58 | std::string fPath;
59 | bool fSuccess;
60 | };
61 |
62 |
63 | #endif // FILE_H
64 |
--------------------------------------------------------------------------------
/src/support/Languages.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2018 Kacper Kasper
3 | * All rights reserved. Distributed under the terms of the MIT license.
4 | */
5 |
6 | #ifndef LANGUAGES_H
7 | #define LANGUAGES_H
8 |
9 |
10 | #include