├── .clang-format ├── .gitattributes ├── .github └── workflows │ └── nightly.yml ├── .gitignore ├── .gitmodules ├── LICENCE ├── README.md ├── Sdk.zig ├── TODO ├── build.zig ├── design ├── app-icon.png ├── logo.png ├── logo.xcf ├── social-media-preview.png ├── social-media-preview.xcf └── ui │ ├── bigplans.md │ ├── gui-ramblings.zig │ ├── login-window.layout │ └── references │ ├── Preferences_Dialog.png │ ├── VS_Code_1.36.0-insider.png │ ├── bahn-app.png │ ├── ms-paint-xp.jpg │ ├── notepad-xp.jpg │ ├── preferences-dialog5.png │ ├── preferences_midi.png │ ├── umlet.png │ └── windows-11-login-screen.webp ├── documentation ├── app_flow.dot ├── app_flow.svg ├── screen01.png └── z3d.md ├── examples ├── features │ ├── GreatVibes-Regular.ttf │ ├── cat.rgba │ ├── data │ │ ├── .gitignore │ │ ├── metal-01.png │ │ ├── metal-02.png │ │ ├── twocubes.mtl │ │ ├── twocubes.obj │ │ └── twocubes.z3d │ ├── feature-demo.zig │ ├── pixelpattern.png │ ├── twocubes.z3d │ └── ziggy.png └── ui │ ├── demo.zig │ └── logo.png ├── src ├── CoreApplication.zig ├── Editor.zig ├── Input.zig ├── UserInterface.zig ├── c_interface.h ├── colors │ ├── css3.zig │ └── xkcd.zig ├── gl_es_2v0.zig ├── main │ ├── android.zig │ ├── common.zig │ ├── desktop.zig │ └── wasm.zig ├── rendering │ ├── DebugRenderer3D.zig │ ├── Renderer2D.zig │ ├── Renderer3D.zig │ ├── RendererSky.zig │ ├── ResourceManager.zig │ ├── gles-helper.zig │ ├── resource_pool.zig │ ├── stb_truetype.c │ └── z3d-format.zig ├── scintilla │ ├── CodeEditor.zig │ ├── code_editor.cpp │ └── code_editor.h ├── tools │ └── ear-clipper.zig ├── ui-data │ ├── FiraSans-Regular.ttf │ ├── SourceCodePro-Regular.ttf │ ├── checkbox-blank.png │ ├── checkbox-marked.png │ ├── radiobox-blank.png │ └── radiobox-marked.png ├── ui │ ├── DockLayout.zig │ ├── HorizontalStackLayout.zig │ ├── VerticalStackLayout.zig │ ├── core │ │ ├── Builder.zig │ │ ├── MemoryPool.zig │ │ ├── RingBuffer.zig │ │ ├── View.zig │ │ ├── Widget.zig │ │ ├── controls.zig │ │ ├── core_types.zig │ │ ├── events.zig │ │ ├── input.zig │ │ └── ui.zig │ ├── standard-controls │ │ ├── Button.zig │ │ ├── Canvas.zig │ │ ├── CheckBox.zig │ │ ├── CodeEditor.zig │ │ ├── ComboBox.zig │ │ ├── ContextMenu.zig │ │ ├── DockWindow.zig │ │ ├── GroupBox.zig │ │ ├── Label.zig │ │ ├── ListBox.zig │ │ ├── MenuBar.zig │ │ ├── NumericUpDown.zig │ │ ├── Panel.zig │ │ ├── Picture.zig │ │ ├── RadioButton.zig │ │ ├── RichTextEditor.zig │ │ ├── ScrollBar.zig │ │ ├── ScrollPanel.zig │ │ ├── StatusBar.zig │ │ ├── TabView.zig │ │ ├── TextBox.zig │ │ ├── ToolBar.zig │ │ ├── ToolButton.zig │ │ ├── TreeView.zig │ │ └── standard-controls.zig │ ├── standard-layout │ │ └── standard-layout.zig │ └── standard-renderer │ │ ├── data │ │ └── fonts │ │ │ ├── NotoSans-Black.ttf │ │ │ ├── NotoSans-BlackItalic.ttf │ │ │ ├── NotoSans-Bold.ttf │ │ │ ├── NotoSans-BoldItalic.ttf │ │ │ ├── NotoSans-ExtraBold.ttf │ │ │ ├── NotoSans-ExtraBoldItalic.ttf │ │ │ ├── NotoSans-ExtraLight.ttf │ │ │ ├── NotoSans-ExtraLightItalic.ttf │ │ │ ├── NotoSans-Italic.ttf │ │ │ ├── NotoSans-Light.ttf │ │ │ ├── NotoSans-LightItalic.ttf │ │ │ ├── NotoSans-Medium.ttf │ │ │ ├── NotoSans-MediumItalic.ttf │ │ │ ├── NotoSans-Regular.ttf │ │ │ ├── NotoSans-SemiBold.ttf │ │ │ ├── NotoSans-SemiBoldItalic.ttf │ │ │ ├── NotoSans-Thin.ttf │ │ │ ├── NotoSans-ThinItalic.ttf │ │ │ ├── NotoSansMono-VariableFont_wdth,wght.ttf │ │ │ ├── NotoSerif-Bold.ttf │ │ │ ├── NotoSerif-BoldItalic.ttf │ │ │ ├── NotoSerif-Italic.ttf │ │ │ ├── NotoSerif-Regular.ttf │ │ │ ├── OFL.txt │ │ │ ├── README.txt │ │ │ └── static │ │ │ ├── NotoSansMono │ │ │ ├── NotoSansMono-Black.ttf │ │ │ ├── NotoSansMono-Bold.ttf │ │ │ ├── NotoSansMono-ExtraBold.ttf │ │ │ ├── NotoSansMono-ExtraLight.ttf │ │ │ ├── NotoSansMono-Light.ttf │ │ │ ├── NotoSansMono-Medium.ttf │ │ │ ├── NotoSansMono-Regular.ttf │ │ │ ├── NotoSansMono-SemiBold.ttf │ │ │ └── NotoSansMono-Thin.ttf │ │ │ ├── NotoSansMono_Condensed │ │ │ ├── NotoSansMono_Condensed-Black.ttf │ │ │ ├── NotoSansMono_Condensed-Bold.ttf │ │ │ ├── NotoSansMono_Condensed-ExtraBold.ttf │ │ │ ├── NotoSansMono_Condensed-ExtraLight.ttf │ │ │ ├── NotoSansMono_Condensed-Light.ttf │ │ │ ├── NotoSansMono_Condensed-Medium.ttf │ │ │ ├── NotoSansMono_Condensed-Regular.ttf │ │ │ ├── NotoSansMono_Condensed-SemiBold.ttf │ │ │ └── NotoSansMono_Condensed-Thin.ttf │ │ │ ├── NotoSansMono_ExtraCondensed │ │ │ ├── NotoSansMono_ExtraCondensed-Black.ttf │ │ │ ├── NotoSansMono_ExtraCondensed-Bold.ttf │ │ │ ├── NotoSansMono_ExtraCondensed-ExtraBold.ttf │ │ │ ├── NotoSansMono_ExtraCondensed-ExtraLight.ttf │ │ │ ├── NotoSansMono_ExtraCondensed-Light.ttf │ │ │ ├── NotoSansMono_ExtraCondensed-Medium.ttf │ │ │ ├── NotoSansMono_ExtraCondensed-Regular.ttf │ │ │ ├── NotoSansMono_ExtraCondensed-SemiBold.ttf │ │ │ └── NotoSansMono_ExtraCondensed-Thin.ttf │ │ │ └── NotoSansMono_SemiCondensed │ │ │ ├── NotoSansMono_SemiCondensed-Black.ttf │ │ │ ├── NotoSansMono_SemiCondensed-Bold.ttf │ │ │ ├── NotoSansMono_SemiCondensed-ExtraBold.ttf │ │ │ ├── NotoSansMono_SemiCondensed-ExtraLight.ttf │ │ │ ├── NotoSansMono_SemiCondensed-Light.ttf │ │ │ ├── NotoSansMono_SemiCondensed-Medium.ttf │ │ │ ├── NotoSansMono_SemiCondensed-Regular.ttf │ │ │ ├── NotoSansMono_SemiCondensed-SemiBold.ttf │ │ │ └── NotoSansMono_SemiCondensed-Thin.ttf │ │ └── standard-renderer.zig └── zero-graphics.zig ├── tools ├── blender-exporter.py ├── http-server.zig ├── render-ztt-page.zig ├── zero-convert │ ├── api.h │ ├── converter.cpp │ └── main.zig └── zero-init │ ├── main.zig │ └── template │ ├── build.zig │ ├── gitattributes │ ├── gitignore │ └── src │ └── main.zig ├── vendor └── scintilla │ ├── cocoa │ ├── InfoBar.h │ ├── InfoBarCommunicator.h │ ├── PlatCocoa.h │ ├── QuartzTextLayout.h │ ├── QuartzTextStyle.h │ ├── QuartzTextStyleAttribute.h │ ├── ScintillaCocoa.h │ ├── ScintillaTest │ │ └── AppController.h │ └── ScintillaView.h │ ├── gtk │ ├── Converter.h │ ├── PlatGTK.cxx │ ├── ScintillaGTK.cxx │ ├── scintilla-marshal.c │ └── scintilla-marshal.h │ ├── include │ ├── ILexer.h │ ├── Platform.h │ ├── SciLexer.h │ ├── Scintilla.h │ └── ScintillaWidget.h │ ├── lexers │ ├── LexA68k.cxx │ ├── LexAPDL.cxx │ ├── LexASY.cxx │ ├── LexAU3.cxx │ ├── LexAVE.cxx │ ├── LexAVS.cxx │ ├── LexAbaqus.cxx │ ├── LexAda.cxx │ ├── LexAsm.cxx │ ├── LexAsn1.cxx │ ├── LexBaan.cxx │ ├── LexBash.cxx │ ├── LexBasic.cxx │ ├── LexBibTeX.cxx │ ├── LexBullant.cxx │ ├── LexCLW.cxx │ ├── LexCOBOL.cxx │ ├── LexCPP.cxx │ ├── LexCSS.cxx │ ├── LexCaml.cxx │ ├── LexCmake.cxx │ ├── LexCoffeeScript.cxx │ ├── LexConf.cxx │ ├── LexCrontab.cxx │ ├── LexCsound.cxx │ ├── LexD.cxx │ ├── LexDMAP.cxx │ ├── LexDMIS.cxx │ ├── LexECL.cxx │ ├── LexEScript.cxx │ ├── LexEiffel.cxx │ ├── LexErlang.cxx │ ├── LexFlagship.cxx │ ├── LexForth.cxx │ ├── LexFortran.cxx │ ├── LexGAP.cxx │ ├── LexGui4Cli.cxx │ ├── LexHTML.cxx │ ├── LexHaskell.cxx │ ├── LexInno.cxx │ ├── LexKVIrc.cxx │ ├── LexKix.cxx │ ├── LexLaTeX.cxx │ ├── LexLisp.cxx │ ├── LexLout.cxx │ ├── LexLua.cxx │ ├── LexMMIXAL.cxx │ ├── LexMPT.cxx │ ├── LexMSSQL.cxx │ ├── LexMagik.cxx │ ├── LexMarkdown.cxx │ ├── LexMatlab.cxx │ ├── LexMetapost.cxx │ ├── LexModula.cxx │ ├── LexMySQL.cxx │ ├── LexNimrod.cxx │ ├── LexNsis.cxx │ ├── LexOScript.cxx │ ├── LexOpal.cxx │ ├── LexOthers.cxx │ ├── LexPB.cxx │ ├── LexPLM.cxx │ ├── LexPO.cxx │ ├── LexPOV.cxx │ ├── LexPS.cxx │ ├── LexPascal.cxx │ ├── LexPerl.cxx │ ├── LexPowerPro.cxx │ ├── LexPowerShell.cxx │ ├── LexProgress.cxx │ ├── LexPython.cxx │ ├── LexR.cxx │ ├── LexRebol.cxx │ ├── LexRegistry.cxx │ ├── LexRuby.cxx │ ├── LexRust.cxx │ ├── LexSML.cxx │ ├── LexSQL.cxx │ ├── LexSTTXT.cxx │ ├── LexScriptol.cxx │ ├── LexSmalltalk.cxx │ ├── LexSorcus.cxx │ ├── LexSpecman.cxx │ ├── LexSpice.cxx │ ├── LexTACL.cxx │ ├── LexTADS3.cxx │ ├── LexTAL.cxx │ ├── LexTCL.cxx │ ├── LexTCMD.cxx │ ├── LexTeX.cxx │ ├── LexTxt2tags.cxx │ ├── LexVB.cxx │ ├── LexVHDL.cxx │ ├── LexVerilog.cxx │ ├── LexVisualProlog.cxx │ └── LexYAML.cxx │ ├── lexlib │ ├── Accessor.cxx │ ├── Accessor.h │ ├── CharacterCategory.cxx │ ├── CharacterCategory.h │ ├── CharacterSet.cxx │ ├── CharacterSet.h │ ├── LexAccessor.h │ ├── LexerBase.cxx │ ├── LexerBase.h │ ├── LexerModule.cxx │ ├── LexerModule.h │ ├── LexerNoExceptions.cxx │ ├── LexerNoExceptions.h │ ├── LexerSimple.cxx │ ├── LexerSimple.h │ ├── OptionSet.h │ ├── PropSetSimple.cxx │ ├── PropSetSimple.h │ ├── SparseState.h │ ├── StringCopy.h │ ├── StyleContext.cxx │ ├── StyleContext.h │ ├── SubStyles.h │ ├── WordList.cxx │ └── WordList.h │ ├── qt │ ├── ScintillaEdit │ │ ├── ScintillaDocument.cpp │ │ └── ScintillaDocument.h │ ├── ScintillaEditBase │ │ ├── PlatQt.cpp │ │ ├── PlatQt.h │ │ ├── ScintillaEditBase.cpp │ │ ├── ScintillaEditBase.h │ │ ├── ScintillaQt.cpp │ │ └── ScintillaQt.h │ └── ScintillaEditPy │ │ └── global.h │ ├── src │ ├── AutoComplete.cxx │ ├── AutoComplete.h │ ├── CallTip.cxx │ ├── CallTip.h │ ├── CaseConvert.cxx │ ├── CaseConvert.h │ ├── CaseFolder.cxx │ ├── CaseFolder.h │ ├── Catalogue.cxx │ ├── Catalogue.h │ ├── CellBuffer.cxx │ ├── CellBuffer.h │ ├── CharClassify.cxx │ ├── CharClassify.h │ ├── ContractionState.cxx │ ├── ContractionState.h │ ├── Decoration.cxx │ ├── Decoration.h │ ├── Document.cxx │ ├── Document.h │ ├── EditModel.cxx │ ├── EditModel.h │ ├── EditView.cxx │ ├── EditView.h │ ├── Editor.cxx │ ├── Editor.h │ ├── ExternalLexer.cxx │ ├── ExternalLexer.h │ ├── FontQuality.h │ ├── Indicator.cxx │ ├── Indicator.h │ ├── KeyMap.cxx │ ├── KeyMap.h │ ├── LineMarker.cxx │ ├── LineMarker.h │ ├── MarginView.cxx │ ├── MarginView.h │ ├── Partitioning.h │ ├── PerLine.cxx │ ├── PerLine.h │ ├── PositionCache.cxx │ ├── PositionCache.h │ ├── RESearch.cxx │ ├── RESearch.h │ ├── RunStyles.cxx │ ├── RunStyles.h │ ├── ScintillaBase.cxx │ ├── ScintillaBase.h │ ├── Selection.cxx │ ├── Selection.h │ ├── SplitVector.h │ ├── Style.cxx │ ├── Style.h │ ├── UniConversion.cxx │ ├── UniConversion.h │ ├── UnicodeFromUTF8.h │ ├── ViewStyle.cxx │ ├── ViewStyle.h │ ├── XPM.cxx │ └── XPM.h │ ├── test │ ├── examples │ │ └── x.cxx │ └── unit │ │ ├── catch.hpp │ │ ├── testCellBuffer.cxx │ │ ├── testCharClassify.cxx │ │ ├── testContractionState.cxx │ │ ├── testDecoration.cxx │ │ ├── testPartitioning.cxx │ │ ├── testRunStyles.cxx │ │ ├── testSparseState.cxx │ │ ├── testSplitVector.cxx │ │ └── unitTest.cxx │ └── win32 │ ├── CheckD2D.cxx │ ├── PlatWin.cxx │ ├── PlatWin.h │ ├── SciLexer.vcxproj │ ├── ScintRes.rc │ └── ScintillaWin.cxx └── www ├── .gitignore ├── application.ztt └── zero-graphics.js /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | 3 | SortIncludes: false 4 | MaxEmptyLinesToKeep: 1 5 | IndentWidth: 2 6 | ColumnLimit: 0 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.zig text=auto eol=lf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | zig-cache/ 2 | zig-out/ 3 | *.tga 4 | .build_config/ 5 | hackzig/ 6 | .vscode/ 7 | *.ll 8 | *.idsig 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ZigAndroidTemplate"] 2 | path = vendor/ZigAndroidTemplate 3 | url = https://github.com/MasterQ32/ZigAndroidTemplate 4 | [submodule "vendor/apple_pie"] 5 | path = vendor/apple_pie 6 | url = https://github.com/LuukDeGram/apple_pie 7 | [submodule "vendor/ZigAndroidTemplate"] 8 | path = vendor/ZigAndroidTemplate 9 | url = https://github.com/MasterQ32/ZigAndroidTemplate 10 | [submodule "vendor/stb"] 11 | path = vendor/stb 12 | url = https://github.com/nothings/stb 13 | [submodule "vendor/zigimg"] 14 | path = vendor/zigimg 15 | url = https://github.com/zigimg/zigimg 16 | [submodule "vendor/SDL.zig"] 17 | path = vendor/SDL.zig 18 | url = https://github.com/MasterQ32/SDL.zig 19 | [submodule "vendor/zlm"] 20 | path = vendor/zlm 21 | url = https://github.com/ziglibs/zlm 22 | [submodule "vendor/args"] 23 | path = vendor/args 24 | url = https://github.com/MasterQ32/zig-args 25 | [submodule "vendor/ZTT"] 26 | path = vendor/ztt 27 | url = https://github.com/MasterQ32/ZTT 28 | [submodule "vendor/zig-assimp"] 29 | path = vendor/zig-assimp 30 | url = https://github.com/MasterQ32/zig-assimp 31 | [submodule "vendor/zigstr"] 32 | path = vendor/zigstr 33 | url = https://github.com/jecolon/zigstr 34 | [submodule "vendor/ziglyph"] 35 | path = vendor/ziglyph 36 | url = https://github.com/jecolon/ziglyph 37 | [submodule "vendor/text-editor"] 38 | path = vendor/text-editor 39 | url = https://github.com/MasterQ32/TextEditor 40 | [submodule "vendor/nfd"] 41 | path = vendor/nfd 42 | url = https://github.com/fabioarnold/nfd-zig/ 43 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2022 Felix "xq" Queißner 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 15 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 18 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 19 | OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | zig will still try to link all libc libc it knows about, since our builtin.link_libc is just a bool 2 | see the switch here https://github.com/ziglang/zig/blob/5414bd48edd460ae8667c811e13aa9b5d9fab919/src/target.zig#L378 3 | which then gets passed to the linker here: https://github.com/ziglang/zig/blob/826179bff40fdbd8c3b11138897fcfbb3367def8/src/link/Elf.zig#L1658 4 | *all the libc libs 5 | erm 6 | that is wrong :D 7 | there is no pthread on android 8 | no rt and no util 9 | ikskuh: sounds like the fix is as simple as adding android to that switch then :) -------------------------------------------------------------------------------- /design/app-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/app-icon.png -------------------------------------------------------------------------------- /design/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/logo.png -------------------------------------------------------------------------------- /design/logo.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/logo.xcf -------------------------------------------------------------------------------- /design/social-media-preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/social-media-preview.png -------------------------------------------------------------------------------- /design/social-media-preview.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/social-media-preview.xcf -------------------------------------------------------------------------------- /design/ui/login-window.layout: -------------------------------------------------------------------------------- 1 | Panel { 2 | vertical-alignment: center; 3 | horizontal-alignment: center; 4 | 5 | TableLayout { 6 | columns: auto, 300; 7 | rows: auto, auto, auto, auto; 8 | 9 | company_logo : Picture { 10 | vertical-alignment: center; 11 | } 12 | 13 | Label { 14 | text: "Username:"; 15 | } 16 | 17 | username : TextBox { } 18 | 19 | Label { 20 | text: "Password:"; 21 | } 22 | 23 | password : TextBox { 24 | password-box: true; 25 | } 26 | 27 | cancel_button : Button { 28 | horizontal-alignment: left; 29 | text: "Cancel"; 30 | } 31 | 32 | login_button : Button { 33 | horizontal-alignment: right; 34 | text: "Login"; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /design/ui/references/Preferences_Dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/ui/references/Preferences_Dialog.png -------------------------------------------------------------------------------- /design/ui/references/VS_Code_1.36.0-insider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/ui/references/VS_Code_1.36.0-insider.png -------------------------------------------------------------------------------- /design/ui/references/bahn-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/ui/references/bahn-app.png -------------------------------------------------------------------------------- /design/ui/references/ms-paint-xp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/ui/references/ms-paint-xp.jpg -------------------------------------------------------------------------------- /design/ui/references/notepad-xp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/ui/references/notepad-xp.jpg -------------------------------------------------------------------------------- /design/ui/references/preferences-dialog5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/ui/references/preferences-dialog5.png -------------------------------------------------------------------------------- /design/ui/references/preferences_midi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/ui/references/preferences_midi.png -------------------------------------------------------------------------------- /design/ui/references/umlet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/ui/references/umlet.png -------------------------------------------------------------------------------- /design/ui/references/windows-11-login-screen.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/design/ui/references/windows-11-login-screen.webp -------------------------------------------------------------------------------- /documentation/app_flow.dot: -------------------------------------------------------------------------------- 1 | digraph { 2 | rankdir = LR; 3 | title = "Application"; 4 | nodesep = 1.5; 5 | 6 | _start [shape=none, label="Program startup"]; 7 | _end [shape=none, label="Program shutdown"]; 8 | 9 | no_graphics [label="App ready"]; 10 | graphics [label="Graphics ready"]; 11 | 12 | _start -> no_graphics [fontname="monospace", label=".init()"]; 13 | no_graphics -> _end [fontname="monospace", label=".deinit()"]; 14 | 15 | no_graphics -> no_graphics [fontname="monospace", label=".update()"]; 16 | 17 | no_graphics -> graphics [fontname="monospace", label=".setupGraphics()"]; 18 | graphics -> no_graphics [fontname="monospace", label=".teardownGraphics()"]; 19 | 20 | graphics -> graphics [fontname="monospace", label=".resize()"]; 21 | graphics -> graphics [fontname="monospace", label=".render()"]; 22 | graphics -> graphics [fontname="monospace", label=".update()"]; 23 | } -------------------------------------------------------------------------------- /documentation/screen01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/documentation/screen01.png -------------------------------------------------------------------------------- /documentation/z3d.md: -------------------------------------------------------------------------------- 1 | # Z3D Model Format 2 | 3 | Everything is encoded little-endian 4 | 5 | ```zig 6 | 7 | // size: variable 8 | const File = struct { 9 | header: Header, 10 | vertices: [header.vertex_count]Vertex, 11 | indices: [header.index_count]Index, 12 | meshes: [header.mesh_count]Mesh, 13 | }; 14 | 15 | // size: 24 16 | const Header = struct { 17 | magic: [4]u8 = .{ 0xae, 0x32, 0x51, 0x1d }, 18 | 19 | version: u16 = 1, 20 | type: enum(u8) { static = 0, dynamic = 1 }, 21 | _: u8 = undefined, 22 | 23 | vertex_count: u32, 24 | index_count: u32, 25 | mesh_count: u32, 26 | _: u32 = undefined, 27 | }; 28 | 29 | // size: 32 30 | const Vertex = struct { 31 | x: f32, 32 | y: f32, 33 | z: f32, 34 | nx: f32, 35 | ny: f32, 36 | nz: f32, 37 | u: f32, 38 | v: f32, 39 | }; 40 | 41 | // size: 2 42 | const Index = u16; 43 | 44 | // size: 128 45 | const Mesh = struct { 46 | offset: u32, 47 | length: u32, 48 | texture_file: [120]u8, // NUL padded 49 | }; 50 | ``` -------------------------------------------------------------------------------- /examples/features/GreatVibes-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/examples/features/GreatVibes-Regular.ttf -------------------------------------------------------------------------------- /examples/features/cat.rgba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/examples/features/cat.rgba -------------------------------------------------------------------------------- /examples/features/data/.gitignore: -------------------------------------------------------------------------------- 1 | *.blend* 2 | -------------------------------------------------------------------------------- /examples/features/data/metal-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/examples/features/data/metal-01.png -------------------------------------------------------------------------------- /examples/features/data/metal-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/examples/features/data/metal-02.png -------------------------------------------------------------------------------- /examples/features/data/twocubes.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'twocubes.blend' 2 | # Material Count: 2 3 | 4 | newmtl Blue_Cube 5 | Ns 323.999994 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.800000 0.800000 0.800000 8 | Ks 0.500000 0.500000 0.500000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.450000 11 | d 1.000000 12 | illum 2 13 | map_Kd metal-01.png 14 | 15 | newmtl Red_Cube 16 | Ns 225.000000 17 | Ka 1.000000 1.000000 1.000000 18 | Kd 0.800000 0.800000 0.800000 19 | Ks 0.500000 0.500000 0.500000 20 | Ke 0.000000 0.000000 0.000000 21 | Ni 1.450000 22 | d 1.000000 23 | illum 2 24 | map_Kd metal-02.png 25 | -------------------------------------------------------------------------------- /examples/features/data/twocubes.z3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/examples/features/data/twocubes.z3d -------------------------------------------------------------------------------- /examples/features/pixelpattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/examples/features/pixelpattern.png -------------------------------------------------------------------------------- /examples/features/twocubes.z3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/examples/features/twocubes.z3d -------------------------------------------------------------------------------- /examples/features/ziggy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/examples/features/ziggy.png -------------------------------------------------------------------------------- /examples/ui/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/examples/ui/logo.png -------------------------------------------------------------------------------- /src/c_interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | extern int zerog_ifloor(double v); 10 | extern int zerog_iceil(double v); 11 | extern double zerog_sqrt(double v); 12 | extern double zerog_pow(double a, double b); 13 | extern double zerog_fmod(double a, double b); 14 | extern double zerog_cos(double v); 15 | extern double zerog_acos(double v); 16 | extern double zerog_fabs(double v); 17 | extern size_t zerog_strlen(char const *str); 18 | 19 | extern void *zerog_memcpy(void *dst, void const *src, size_t num); 20 | extern void *zerog_memset(void *ptr, int value, size_t num); 21 | 22 | extern void zerog_panic(char const *msg); 23 | extern void *zerog_renderer2d_alloc(void *c_void, size_t size); 24 | extern void zerog_renderer2d_free(void *user_data, void *ptr); 25 | 26 | extern int zero_graphics_getDisplayDpi(); 27 | extern int zero_graphics_getWidth(); 28 | extern int zero_graphics_getHeight(); 29 | 30 | extern void *zero_graphics_alloc(void *raw_allocator, size_t size); 31 | extern void zero_graphics_writeLog(unsigned int log_level, char const *msg_ptr, size_t length); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif -------------------------------------------------------------------------------- /src/main/common.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | const stbttf_log = std.log.scoped(.stb_ttf); 4 | 5 | export fn zerog_renderer2d_alloc(user_data: ?*anyopaque, size: usize) ?*anyopaque { 6 | stbttf_log.info("alloc {} bytes with {?}", .{ size, user_data }); 7 | const allocator = @ptrCast(*std.mem.Allocator, @alignCast(@alignOf(*std.mem.Allocator), user_data orelse @panic("unexpected NULl!"))); 8 | 9 | const buffer = allocator.alignedAlloc(u8, 16, size + 16) catch return null; 10 | std.mem.writeIntNative(usize, buffer[0..@sizeOf(usize)], buffer.len); 11 | return buffer.ptr + 16; 12 | } 13 | 14 | export fn zerog_renderer2d_free(user_data: ?*anyopaque, ptr: ?*anyopaque) void { 15 | stbttf_log.info("free {?} with {?}", .{ ptr, user_data }); 16 | const allocator = @ptrCast(*std.mem.Allocator, @alignCast(@alignOf(*std.mem.Allocator), user_data orelse @panic("unexpected NULl!"))); 17 | 18 | const actual_buffer = @ptrCast([*]u8, ptr orelse return) - 16; 19 | const len = std.mem.readIntNative(usize, actual_buffer[0..@sizeOf(usize)]); 20 | 21 | allocator.free(actual_buffer[0..len]); 22 | } 23 | 24 | export fn zerog_panic(msg: [*:0]const u8) noreturn { 25 | @panic(std.mem.span(msg)); 26 | } 27 | 28 | export fn zerog_ifloor(v: f64) c_int { 29 | return @floatToInt(c_int, @floor(v)); 30 | } 31 | 32 | export fn zerog_iceil(v: f64) c_int { 33 | return @floatToInt(c_int, @ceil(v)); 34 | } 35 | 36 | export fn zerog_sqrt(v: f64) f64 { 37 | return std.math.sqrt(v); 38 | } 39 | export fn zerog_pow(a: f64, b: f64) f64 { 40 | return std.math.pow(f64, a, b); 41 | } 42 | export fn zerog_fmod(a: f64, b: f64) f64 { 43 | return @mod(a, b); 44 | } 45 | export fn zerog_cos(v: f64) f64 { 46 | return @cos(v); 47 | } 48 | export fn zerog_acos(v: f64) f64 { 49 | return std.math.acos(v); 50 | } 51 | export fn zerog_fabs(v: f64) f64 { 52 | return @fabs(v); 53 | } 54 | export fn zerog_strlen(str: ?[*:0]const u8) usize { 55 | return std.mem.len(str orelse return 0); 56 | } 57 | export fn zerog_memcpy(dst: ?[*]u8, src: ?[*]const u8, num: usize) ?[*]u8 { 58 | if (dst == null or src == null) 59 | @panic("Invalid usage of memcpy!"); 60 | std.mem.copy(u8, dst.?[0..num], src.?[0..num]); 61 | return dst; 62 | } 63 | export fn zerog_memset(ptr: ?[*]u8, value: c_int, num: usize) ?[*]u8 { 64 | if (ptr == null) 65 | @panic("Invalid usage of memset!"); 66 | std.mem.set(u8, ptr.?[0..num], @intCast(u8, value)); 67 | return ptr; 68 | } 69 | -------------------------------------------------------------------------------- /src/rendering/resource_pool.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub fn ResourcePool(comptime Resource: type, comptime Context: type, comptime destruct: fn (Context, *Resource) void) type { 4 | return struct { 5 | const Self = @This(); 6 | 7 | const Item = struct { 8 | refcount: usize, 9 | resource: Resource, 10 | }; 11 | 12 | const List = std.TailQueue(Item); 13 | const Node = std.TailQueue(Item).Node; 14 | 15 | arena: std.heap.ArenaAllocator, 16 | list: List, 17 | free_list: List, 18 | 19 | pub fn init(allocator: std.mem.Allocator) Self { 20 | return Self{ 21 | .arena = std.heap.ArenaAllocator.init(allocator), 22 | .list = List{}, 23 | .free_list = List{}, 24 | }; 25 | } 26 | 27 | pub fn deinit(self: *Self, context: Context) void { 28 | while (self.list.first) |node| { 29 | self.destroy(context, node); 30 | } 31 | self.arena.deinit(); 32 | self.* = undefined; 33 | } 34 | 35 | fn getNode(resource: *Resource) *Node { 36 | const item = @fieldParentPtr(Item, "resource", resource); 37 | const node = @fieldParentPtr(Node, "data", item); 38 | return node; 39 | } 40 | 41 | /// Creates a duplicate of the given resource and will return a pool-interned variant 42 | /// that can be passed around. 43 | /// Will have its resource count set to 1 for convenience. 44 | pub fn allocate(self: *Self, resource: Resource) error{OutOfMemory}!*Resource { 45 | 46 | // try pulling a node from the free list before allocating new memory. 47 | // by using both an arena and a free-list, cache locality is quite good 48 | // and allocation count is kept low. this is both useful for quick 49 | // alloc/release cycles as well as for long-lasting allocations. 50 | const node = if (self.free_list.pop()) |old_node| 51 | old_node 52 | else 53 | try self.arena.allocator().create(Node); 54 | node.* = .{ 55 | .data = .{ 56 | .refcount = 1, 57 | .resource = resource, 58 | }, 59 | }; 60 | self.list.append(node); 61 | return &node.data.resource; 62 | } 63 | 64 | /// Increases the reference count by one. 65 | pub fn retain(self: *Self, resource: *Resource) void { 66 | _ = self; 67 | const node = getNode(resource); 68 | std.debug.assert(node.data.refcount > 0); 69 | node.data.refcount += 1; 70 | } 71 | 72 | /// Reduces the reference count by one and destroys the resource if necessary. 73 | pub fn release(self: *Self, context: Context, resource: *Resource) void { 74 | const node = getNode(resource); 75 | std.debug.assert(node.data.refcount > 0); 76 | node.data.refcount -= 1; 77 | if (node.data.refcount == 0) 78 | self.destroy(context, node); 79 | } 80 | 81 | /// Destroys the resource immediatly. Bypasses all reference counting 82 | fn destroy(self: *Self, context: Context, node: *Node) void { 83 | self.list.remove(node); 84 | 85 | destruct(context, &node.data.resource); 86 | node.* = undefined; 87 | 88 | // Just recycle the node into a free list and 89 | // reuse that memory later. 90 | self.free_list.append(node); 91 | } 92 | }; 93 | } 94 | -------------------------------------------------------------------------------- /src/rendering/stb_truetype.c: -------------------------------------------------------------------------------- 1 | // Include TTF module 2 | 3 | #include "../c_interface.h" 4 | 5 | // Configure stb_truetype to not depend on *any* libc functions or headers: 6 | 7 | #include 8 | 9 | #define STBTT_ifloor(x) zerog_ifloor(x) 10 | #define STBTT_iceil(x) zerog_iceil(x) 11 | #define STBTT_sqrt(x) zerog_sqrt(x) 12 | #define STBTT_pow(x, y) zerog_pow(x, y) 13 | #define STBTT_fmod(x, y) zerog_fmod(x, y) 14 | #define STBTT_cos(x) zerog_cos(x) 15 | #define STBTT_acos(x) zerog_acos(x) 16 | #define STBTT_fabs(x) zerog_fabs(x) 17 | #define STBTT_strlen(x) zerog_strlen(x) 18 | #define STBTT_memcpy(a, b, c) zerog_memcpy(a, b, c) 19 | #define STBTT_memset(a, b, c) zerog_memset(a, b, c) 20 | 21 | #define STBTT_malloc(_Size, _UserData) zerog_renderer2d_alloc(_UserData, _Size) 22 | #define STBTT_free(_Ptr, _UserData) zerog_renderer2d_free(_UserData, _Ptr) 23 | #define STBTT_assert(_Assertion) \ 24 | do { \ 25 | if ((_Assertion) == 0) \ 26 | zerog_panic("Assertion " #_Assertion " failed!"); \ 27 | } while (0) 28 | 29 | #define STB_TRUETYPE_IMPLEMENTATION 30 | #include 31 | -------------------------------------------------------------------------------- /src/rendering/z3d-format.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub const FileType = enum(u8) { static = 0, dynamic = 1, _ }; 4 | pub const magic_number = [4]u8{ 0xae, 0x32, 0x51, 0x1d }; 5 | 6 | pub const CommonHeader = extern struct { 7 | magic: [4]u8 = magic_number, 8 | 9 | version: u16 = std.mem.nativeToLittle(u16, 1), 10 | type: FileType, 11 | _pad0: u8 = undefined, 12 | }; 13 | 14 | pub const static_model = struct { 15 | comptime { 16 | if (@sizeOf(Header) != 24) @compileError("Header must have 24 byte!"); 17 | if (@sizeOf(Vertex) != 32) @compileError("Vertex must have 32 byte!"); 18 | if (@sizeOf(Index) != 2) @compileError("Index must have 2 byte!"); 19 | if (@sizeOf(Mesh) != 128) @compileError("Mesh must have 128 byte!"); 20 | } 21 | 22 | // size: 24 23 | pub const Header = extern struct { 24 | common: CommonHeader, 25 | vertex_count: u32, 26 | index_count: u32, 27 | mesh_count: u32, 28 | _pad1: u32 = undefined, 29 | }; 30 | 31 | // size: 32 32 | pub const Vertex = extern struct { 33 | x: f32, 34 | y: f32, 35 | z: f32, 36 | nx: f32, 37 | ny: f32, 38 | nz: f32, 39 | u: f32, 40 | v: f32, 41 | }; 42 | 43 | // size: 2 44 | pub const Index = u16; 45 | 46 | // size: 128 47 | pub const Mesh = extern struct { 48 | offset: u32, 49 | length: u32, 50 | texture_file: [120]u8, // NUL padded 51 | }; 52 | }; 53 | -------------------------------------------------------------------------------- /src/scintilla/code_editor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef CODE_EDITOR 4 | #define CODE_EDITOR 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | // Keep in sync with CodeEditor.zig 15 | 16 | #define NOTIFY_CHANGE (1U << 0) 17 | 18 | typedef struct ZigEditorInterface ZigEditorInterface; 19 | typedef struct ZigFont ZigFont; 20 | typedef struct ScintillaEditor ScintillaEditor; 21 | typedef struct ZigRect ZigRect; 22 | typedef struct ZigString ZigString; 23 | 24 | enum LogLevel { 25 | LOG_DEBUG, 26 | LOG_INFO, 27 | LOG_WARN, 28 | LOG_ERROR, 29 | }; 30 | typedef enum LogLevel LogLevel; 31 | 32 | // 0xAABBGGRR 33 | typedef uint32_t ZigColor; 34 | 35 | struct ZigRect { 36 | float x, y; 37 | float width, height; 38 | }; 39 | 40 | struct ZigString { 41 | char *ptr; 42 | size_t len; 43 | }; 44 | 45 | struct ZigEditorInterface { 46 | ZigFont *(*createFont)(ZigEditorInterface *app, char const *font_name, float size); 47 | void (*destroyFont)(ZigEditorInterface *app, ZigFont *font); 48 | 49 | float (*getFontAscent)(ZigEditorInterface *app, ZigFont *font); 50 | float (*getFontDescent)(ZigEditorInterface *app, ZigFont *font); 51 | float (*getFontLineGap)(ZigEditorInterface *app, ZigFont *font); 52 | float (*getFontCharWidth)(ZigEditorInterface *app, ZigFont *font, uint32_t c); 53 | 54 | // render commands 55 | float (*measureStringWidth)(ZigEditorInterface *app, ZigFont *font, char const *str, size_t length); 56 | void (*measureCharPositions)(ZigEditorInterface *app, ZigFont *font, char const *str, size_t length, float *positions); 57 | void (*drawString)(ZigEditorInterface *app, ZigRect const *rectangle, ZigFont *font, ZigColor color, char const *str, size_t length); 58 | void (*drawRectangle)(ZigEditorInterface *app, ZigRect const *rectangle, ZigColor color); 59 | void (*fillRectangle)(ZigEditorInterface *app, ZigRect const *rectangle, ZigColor color); 60 | void (*setClipRect)(ZigEditorInterface *app, ZigRect const *rectangle); 61 | 62 | void (*setClipboardContent)(ZigEditorInterface *app, char const *str, size_t length); 63 | size_t (*getClipboardContent)(ZigEditorInterface *app, char *str, size_t max_length); 64 | 65 | // notify commands 66 | void (*sendNotification)(ZigEditorInterface *app, uint32_t notification); 67 | }; 68 | 69 | void scintilla_init(); 70 | void scintilla_deinit(); 71 | 72 | ScintillaEditor *scintilla_create(ZigEditorInterface *); 73 | void scintilla_setText(ScintillaEditor *editor, char const *string, size_t length); 74 | ZigString scintilla_getText(ScintillaEditor *editor, void *allocator); 75 | void scintilla_tick(ScintillaEditor *editor); 76 | void scintilla_render(ScintillaEditor *editor); 77 | 78 | void scintilla_mouseMove(ScintillaEditor *editor, int x, int y); 79 | void scintilla_mouseDown(ScintillaEditor *editor, float time, int x, int y); 80 | void scintilla_mouseUp(ScintillaEditor *editor, float time, int x, int y); 81 | bool scintilla_keyDown(ScintillaEditor *editor, int zig_scancode, bool shift, bool ctrl, bool alt); 82 | void scintilla_enterString(ScintillaEditor *editor, char const *str, size_t len); 83 | void scintilla_setFocus(ScintillaEditor *editor, bool focused); 84 | 85 | void scintilla_setPosition(ScintillaEditor *editor, int x, int y, int w, int h); 86 | 87 | void scintilla_destroy(ScintillaEditor *editor); 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif // CODE_EDITOR 94 | -------------------------------------------------------------------------------- /src/ui-data/FiraSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui-data/FiraSans-Regular.ttf -------------------------------------------------------------------------------- /src/ui-data/SourceCodePro-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui-data/SourceCodePro-Regular.ttf -------------------------------------------------------------------------------- /src/ui-data/checkbox-blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui-data/checkbox-blank.png -------------------------------------------------------------------------------- /src/ui-data/checkbox-marked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui-data/checkbox-marked.png -------------------------------------------------------------------------------- /src/ui-data/radiobox-blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui-data/radiobox-blank.png -------------------------------------------------------------------------------- /src/ui-data/radiobox-marked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui-data/radiobox-marked.png -------------------------------------------------------------------------------- /src/ui/DockLayout.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const types = @import("../zero-graphics.zig"); 3 | 4 | const Rectangle = types.Rectangle; 5 | 6 | const Self = @This(); 7 | 8 | pub const DockSite = enum { 9 | top, 10 | left, 11 | bottom, 12 | right, 13 | }; 14 | 15 | rest_rectangle: Rectangle, 16 | 17 | pub fn init(base: Rectangle) Self { 18 | return Self{ 19 | .rest_rectangle = base, 20 | }; 21 | } 22 | 23 | pub fn get(self: *Self, site: DockSite, size: u15) Rectangle { 24 | switch (site) { 25 | .top => { 26 | const result = Rectangle{ 27 | .x = self.rest_rectangle.x, 28 | .y = self.rest_rectangle.y, 29 | .width = self.rest_rectangle.width, 30 | .height = size, 31 | }; 32 | self.rest_rectangle.y += size; 33 | self.rest_rectangle.height -= size; 34 | return result; 35 | }, 36 | .left => { 37 | const result = Rectangle{ 38 | .x = self.rest_rectangle.x, 39 | .y = self.rest_rectangle.y, 40 | .width = size, 41 | .height = self.rest_rectangle.height, 42 | }; 43 | self.rest_rectangle.x += size; 44 | self.rest_rectangle.width -= size; 45 | return result; 46 | }, 47 | .bottom => { 48 | self.rest_rectangle.height -= size; 49 | const result = Rectangle{ 50 | .x = self.rest_rectangle.x, 51 | .y = self.rest_rectangle.y + self.rest_rectangle.height, 52 | .width = self.rest_rectangle.width, 53 | .height = size, 54 | }; 55 | return result; 56 | }, 57 | .right => { 58 | self.rest_rectangle.width -= size; 59 | const result = Rectangle{ 60 | .x = self.rest_rectangle.x + self.rest_rectangle.width, 61 | .y = self.rest_rectangle.y, 62 | .width = size, 63 | .height = self.rest_rectangle.height, 64 | }; 65 | return result; 66 | }, 67 | } 68 | } 69 | 70 | pub fn getRest(self: Self) Rectangle { 71 | return self.rest_rectangle; 72 | } 73 | -------------------------------------------------------------------------------- /src/ui/HorizontalStackLayout.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const types = @import("../zero-graphics.zig"); 3 | 4 | const Rectangle = types.Rectangle; 5 | 6 | const Self = @This(); 7 | 8 | base_rectangle: Rectangle, 9 | current_offset: u15, 10 | 11 | pub fn init(base: Rectangle) Self { 12 | return Self{ 13 | .base_rectangle = base, 14 | .current_offset = 0, 15 | }; 16 | } 17 | 18 | pub fn get(self: *Self, width: u15) Rectangle { 19 | defer self.current_offset += width; 20 | return Rectangle{ 21 | .x = self.base_rectangle.x + self.current_offset, 22 | .y = self.base_rectangle.y, 23 | .width = width, 24 | .height = self.base_rectangle.height, 25 | }; 26 | } 27 | 28 | pub fn advance(self: *Self, margin: u15) void { 29 | _ = get(self, margin); 30 | } 31 | -------------------------------------------------------------------------------- /src/ui/VerticalStackLayout.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const types = @import("../zero-graphics.zig"); 3 | 4 | const Rectangle = types.Rectangle; 5 | 6 | const Self = @This(); 7 | 8 | base_rectangle: Rectangle, 9 | current_offset: u15, 10 | 11 | pub fn init(base: Rectangle) Self { 12 | return Self{ 13 | .base_rectangle = base, 14 | .current_offset = 0, 15 | }; 16 | } 17 | 18 | pub fn get(self: *Self, height: u15) Rectangle { 19 | defer self.current_offset += height; 20 | return Rectangle{ 21 | .x = self.base_rectangle.x, 22 | .y = self.base_rectangle.y + self.current_offset, 23 | .width = self.base_rectangle.width, 24 | .height = height, 25 | }; 26 | } 27 | 28 | pub fn advance(self: *Self, margin: u15) void { 29 | _ = get(self, margin); 30 | } 31 | -------------------------------------------------------------------------------- /src/ui/core/Builder.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const ui = @import("ui.zig"); 3 | 4 | const Builder = @This(); 5 | const Widget = ui.Widget; 6 | const Control = ui.controls.Control; 7 | const MemoryPool = ui.MemoryPool; 8 | const List = Widget.List; 9 | 10 | pool: MemoryPool(Widget), 11 | stack: std.ArrayList(*List), 12 | 13 | top_list: List = .{}, 14 | 15 | /// Starts the construction of a new widget hierarchy, will 16 | /// allocate all widgets inside a memory pool. 17 | pub fn begin(allocator: std.mem.Allocator) Builder { 18 | return Builder{ 19 | .pool = MemoryPool(Widget).init(allocator), 20 | .stack = std.ArrayList(*List).init(allocator), 21 | }; 22 | } 23 | 24 | /// Cancels the construction process and frees all memory. 25 | /// The builder is unusable after this. 26 | pub fn cancel(builder: *Builder) void { 27 | builder.pool.deinit(); 28 | builder.stack.deinit(); 29 | builder.* = undefined; 30 | } 31 | 32 | const OutValue = struct { 33 | memory: MemoryPool(Widget), 34 | view: ui.View, 35 | }; 36 | 37 | /// Finalizes the construction of the widget tree and returns 38 | /// the tree and a handle to the created memory. 39 | /// The builder is unusable after this. 40 | pub fn finish(builder: *Builder) OutValue { 41 | var out = OutValue{ 42 | .memory = builder.pool, 43 | .view = ui.View{ 44 | .widgets = builder.top_list, 45 | }, 46 | }; 47 | builder.stack.deinit(); 48 | builder.* = undefined; 49 | return out; 50 | } 51 | 52 | ////////////////////////////////////// 53 | 54 | /// Returns a handle to the last added widget. 55 | /// Asserts that a widget was already added. 56 | pub fn current(builder: *Builder) *Widget { 57 | const list = builder.insertionList(); 58 | return Widget.fromNode(if (list.last) |last| last else unreachable); 59 | } 60 | 61 | /// Enters the current widget. The new widgets 62 | /// created from now on will be added to the 63 | /// `current` widget. 64 | pub fn enter(builder: *Builder) !void { 65 | const list = builder.insertionList(); 66 | const last = Widget.fromNode(if (list.last) |last| last else unreachable); 67 | try builder.stack.append(&last.children); 68 | } 69 | 70 | /// Leaves the `parent()` widget. The new widgets 71 | /// created from now on will be added as siblings 72 | /// to `parent()`. 73 | /// Asserts that the builder is currently in a child scope. 74 | pub fn leave(builder: *Builder) void { 75 | _ = builder.stack.pop(); 76 | } 77 | 78 | /// Creates a new memory node, stores the passed control 79 | /// into a new widget, then appends the widget to the current 80 | /// tree level. 81 | /// Returns a pointer to the memoized widget. 82 | pub fn add(builder: *Builder, control: Control) !*Widget { 83 | const storage = try builder.pool.create(); 84 | errdefer builder.pool.destroy(storage); 85 | 86 | storage.* = Widget{ 87 | .control = control, 88 | }; 89 | builder.insertionList().append(&storage.siblings); 90 | 91 | return storage; 92 | } 93 | 94 | /// Returns the current list of widgets where insertion happens. 95 | fn insertionList(builder: *Builder) *List { 96 | const stack = builder.stack.items; 97 | return if (stack.len == 0) 98 | &builder.top_list 99 | else 100 | stack[stack.len - 1]; 101 | } 102 | -------------------------------------------------------------------------------- /src/ui/core/core_types.zig: -------------------------------------------------------------------------------- 1 | //! This file is meant to export some core types that might be provided by the surrounding 2 | //! environment. 3 | //! 4 | //! The default implementation is using the regular zero-graphics types, but those can be replaced 5 | //! by whatever types the user of this library things is appropiate. 6 | //! 7 | //! There are some comptime checks installed that make sure that the types meet the requirements. 8 | //! 9 | 10 | const std = @import("std"); 11 | const zg = @import("zero-graphics"); 12 | 13 | pub const Color: type = zg.Color; 14 | pub const Point: type = zg.Point; 15 | pub const Size: type = zg.Size; 16 | pub const Rectangle: type = zg.Rectangle; 17 | pub const MouseButton: type = zg.Input.MouseButton; 18 | pub const KeyCode: type = zg.Input.Scancode; 19 | 20 | pub const VerticalAlignment: type = zg.VerticalAlignment; 21 | pub const HorizontalAlignment: type = zg.HorzizontalAlignment; 22 | 23 | pub const KeyModifiers: type = zg.Input.Modifiers; 24 | 25 | comptime { 26 | std.debug.assert(@hasField(Point, "x")); 27 | std.debug.assert(@hasField(Point, "y")); 28 | 29 | std.debug.assert(@hasField(Size, "width")); 30 | std.debug.assert(@hasField(Size, "height")); 31 | 32 | std.debug.assert(@hasField(Rectangle, "x")); 33 | std.debug.assert(@hasField(Rectangle, "y")); 34 | std.debug.assert(@hasField(Rectangle, "width")); 35 | std.debug.assert(@hasField(Rectangle, "height")); 36 | 37 | std.debug.assert(@hasField(KeyCode, "escape")); 38 | std.debug.assert(@hasField(KeyCode, "tab")); 39 | std.debug.assert(@hasField(KeyCode, "space")); 40 | std.debug.assert(@hasField(KeyCode, "return")); 41 | 42 | std.debug.assert(@hasField(MouseButton, "primary")); 43 | std.debug.assert(@hasField(MouseButton, "secondary")); 44 | 45 | std.debug.assert(@hasField(VerticalAlignment, "top")); 46 | std.debug.assert(@hasField(VerticalAlignment, "center")); 47 | std.debug.assert(@hasField(VerticalAlignment, "bottom")); 48 | 49 | std.debug.assert(@hasField(HorizontalAlignment, "left")); 50 | std.debug.assert(@hasField(HorizontalAlignment, "center")); 51 | std.debug.assert(@hasField(HorizontalAlignment, "right")); 52 | 53 | std.debug.assert(@hasField(KeyModifiers, "ctrl")); 54 | std.debug.assert(@hasField(KeyModifiers, "alt")); 55 | std.debug.assert(@hasField(KeyModifiers, "shift")); 56 | std.debug.assert(@hasField(KeyModifiers, "gui")); 57 | } 58 | -------------------------------------------------------------------------------- /src/ui/core/events.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const ui = @import("ui.zig"); 3 | 4 | const Widget = ui.Widget; 5 | 6 | pub const Event = struct { 7 | //! An event represents something that happened inside a view in response 8 | //! to a user interaction. 9 | //! 10 | //! The most simple example here would be the action of the user clicking a 11 | //! button and emitting a `on_click` event. 12 | //! 13 | //! The event is then put into a queue inside the corresponding `View` and 14 | //! can be retrieved by the `View.pullEvent` function. 15 | 16 | /// The widget that issued the event. 17 | sender: *Widget, 18 | 19 | /// Additional data that can be used to handle an event appropiatly. 20 | data: Data, 21 | 22 | /// The user-provided event handler that lead to the emission of this event. 23 | /// Can be used to decide what action to perform. 24 | handler: EventHandler, 25 | 26 | pub const Data = union(enum) { 27 | none, 28 | 29 | }; 30 | 31 | pub fn format(self: Event, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { 32 | _ = fmt; 33 | _ = options; 34 | try writer.print("Event{{ .sender = {s}(0x{X}), .data = {?}, .handler = (id={}, data={?} }}", .{ 35 | @tagName(self.sender.control), 36 | @ptrToInt(self.sender), 37 | self.data, 38 | self.handler.id, 39 | self.handler.user_data, 40 | }); 41 | } 42 | }; 43 | 44 | pub const EventHandler = struct { 45 | //! An event handler is a user-created and managed structure that allows 46 | //! identification and attribution of events to their respective widget 47 | //! or intent. 48 | //! 49 | //! For the most simplest variant, event handlers would not be needed, as 50 | //! a user of the library could reconstruct the required context from a 51 | //! widget pointer alone, but this is included for performance and 52 | //! convenience reasons. 53 | 54 | /// User-assigned identifier that allows identification of this 55 | /// event handler. This should usually be converted from and to an 56 | /// enum for safety. 57 | id: u32, 58 | 59 | /// A user-assigned pointer that can provide additional context to a 60 | /// event, so the code receiving an event can access the required data 61 | /// easily. 62 | user_data: ?*anyopaque = null, 63 | }; 64 | -------------------------------------------------------------------------------- /src/ui/core/input.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const ui = @import("ui.zig"); 3 | 4 | const Point = ui.Point; 5 | const MouseButton = ui.MouseButton; 6 | const KeyCode = ui.KeyCode; 7 | 8 | pub const InputEvent = union(enum) { 9 | mouse_button_down: MouseButton, 10 | mouse_button_up: MouseButton, 11 | mouse_motion: Point, 12 | 13 | key_down: KeyInfo, 14 | key_up: KeyInfo, 15 | 16 | text_input: []const u8, 17 | }; 18 | 19 | pub const KeyInfo = struct { 20 | scancode: u16, 21 | key: KeyCode, 22 | modifiers: ui.KeyModifiers, 23 | }; 24 | -------------------------------------------------------------------------------- /src/ui/core/ui.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | const core_types = @import("core_types.zig"); 4 | 5 | pub const controls = @import("controls.zig"); 6 | pub const events = @import("events.zig"); 7 | pub const input = @import("input.zig"); 8 | 9 | pub const View = @import("View.zig"); 10 | pub const Widget = @import("Widget.zig"); 11 | 12 | pub const Event = events.Event; 13 | pub const EventHandler = events.EventHandler; 14 | 15 | pub const InputEvent = input.InputEvent; 16 | 17 | pub const Color = core_types.Color; 18 | pub const Point = core_types.Point; 19 | pub const Size = core_types.Size; 20 | pub const Rectangle = core_types.Rectangle; 21 | pub const MouseButton = core_types.MouseButton; 22 | pub const KeyCode = core_types.KeyCode; 23 | pub const VerticalAlignment = core_types.VerticalAlignment; 24 | pub const HorizontalAlignment = core_types.HorizontalAlignment; 25 | pub const KeyModifiers = core_types.KeyModifiers; 26 | 27 | pub const Builder = @import("Builder.zig"); 28 | 29 | pub const MemoryPool = @import("MemoryPool.zig").MemoryPool; 30 | pub const RingBuffer = @import("RingBuffer.zig").RingBuffer; 31 | 32 | pub const Visibility = enum { 33 | /// The item is fully visible 34 | visible, 35 | 36 | /// The item is visually not rendered and does not receive events, 37 | /// but will still take up space in the layout. 38 | hidden, 39 | 40 | /// The item is collapsed and will disappear entirely from the screen. 41 | /// Neither input, rendering nor layouting will see this node. 42 | collapsed, 43 | }; 44 | 45 | /// A on-screen rectangle. It has a position and size, but also constraints 46 | /// for the size, so a layout engine can use those to mutate position and size. 47 | pub const LayoutedRectangle = struct { 48 | position: Point, 49 | size: Size, 50 | 51 | min_size: Size = Size.new(0, 0), 52 | max_size: Size = Size.new(std.math.maxInt(u15), std.math.maxInt(u15)), 53 | }; 54 | 55 | /// An abstract font that can is implemented by the rendering backend. The UI system itself 56 | /// only stores a reference to the font, so anything can be stored in here. 57 | pub const Font = struct { 58 | vtable: *const VTable, 59 | ptr: *anyopaque, 60 | 61 | pub const VTable = struct { 62 | getLineHeightFn: *const fn (*anyopaque) u15, 63 | measureStringFn: *const fn (*anyopaque, text: []const u8) u15, 64 | }; 65 | 66 | pub fn getLineHeight(font: Font) u15 { 67 | return font.vtable.getLineHeightFn(font.ptr); 68 | } 69 | 70 | pub fn measureString(font: Font, string: []const u8) u15 { 71 | return font.vtable.measureStringFn(font.ptr, string); 72 | } 73 | }; 74 | 75 | /// An abstract graphics object that is implemented by the rendering backend. The UI system itself 76 | /// only stores a reference to the font, so anything can be stored in here. 77 | /// 78 | /// This can either be a pixel graphic or a vector graphic, the file format support is up to the 79 | /// rendering backend. 80 | pub const Image = struct { 81 | vtable: *const VTable, 82 | ptr: *anyopaque, 83 | 84 | pub const VTable = struct { 85 | getSizeFn: *const fn (*anyopaque) Size, 86 | }; 87 | 88 | pub fn getSize(image: Image) Size { 89 | return image.vtable.getSizeFn(image.ptr); 90 | } 91 | }; 92 | -------------------------------------------------------------------------------- /src/ui/standard-controls/Button.zig: -------------------------------------------------------------------------------- 1 | //! 2 | //! The button is a UI primitive that the user can click. 3 | //! A click usually triggers actions like *saving a file* or *sending a message*. 4 | //! 5 | 6 | const std = @import("std"); 7 | const ui = @import("ui"); 8 | 9 | const Button = @This(); 10 | 11 | on_click: ?ui.EventHandler = null, 12 | 13 | font: ?ui.Font = null, 14 | text: ?[]const u8 = null, 15 | 16 | pub fn canReceiveFocus(ctrl: *@This()) bool { 17 | _ = ctrl; 18 | return true; 19 | } 20 | 21 | pub fn isHitTestVisible(ctrl: *@This()) bool { 22 | _ = ctrl; 23 | return true; 24 | } 25 | 26 | pub fn sendInput(ctrl: *Button, widget: *ui.Widget, view: *ui.View, input: ui.Widget.Event) ui.Widget.InputHandling { 27 | switch (input) { 28 | .click => if (ctrl.on_click) |click_event_handler| { 29 | view.pushEvent(.{ 30 | .sender = widget, 31 | .data = .none, 32 | .handler = click_event_handler, 33 | }); 34 | return .ignore; 35 | }, 36 | else => {}, 37 | } 38 | return .process; 39 | } 40 | -------------------------------------------------------------------------------- /src/ui/standard-controls/Canvas.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/CheckBox.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const ui = @import("ui"); 3 | 4 | const CheckBox = @This(); 5 | 6 | on_checked_changed: ?ui.EventHandler = null, 7 | 8 | font: ?ui.Font = null, 9 | text: ?[]const u8 = null, 10 | 11 | checked: bool, 12 | 13 | pub fn canReceiveFocus(ctrl: CheckBox) bool { 14 | _ = ctrl; 15 | return true; 16 | } 17 | 18 | pub fn isHitTestVisible(ctrl: CheckBox) bool { 19 | _ = ctrl; 20 | return true; 21 | } 22 | -------------------------------------------------------------------------------- /src/ui/standard-controls/CodeEditor.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/ComboBox.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/ContextMenu.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/DockWindow.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/GroupBox.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return false; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/Label.zig: -------------------------------------------------------------------------------- 1 | //! 2 | //! A label is a simple control that shows a text on the user interface. 3 | //! It doesn't have much interaction besides rendering. 4 | //! 5 | 6 | const ui = @import("ui"); 7 | 8 | font: ?ui.Font = null, 9 | text: ?[]const u8 = null, 10 | 11 | vertical_alignment: ?ui.VerticalAlignment = null, 12 | horizontal_alignment: ?ui.HorizontalAlignment = null, 13 | 14 | pub fn canReceiveFocus(ctrl: *@This()) bool { 15 | _ = ctrl; 16 | return false; 17 | } 18 | 19 | pub fn isHitTestVisible(ctrl: *@This()) bool { 20 | _ = ctrl; 21 | return false; 22 | } 23 | -------------------------------------------------------------------------------- /src/ui/standard-controls/ListBox.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/MenuBar.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/NumericUpDown.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/Panel.zig: -------------------------------------------------------------------------------- 1 | //! The panel is a dead simple control to organize several widgets 2 | //! into a logical group. 3 | //! Panels are most prominent by showing a border around their contents. 4 | 5 | pub fn canReceiveFocus(ctrl: *@This()) bool { 6 | _ = ctrl; 7 | return false; 8 | } 9 | 10 | pub fn isHitTestVisible(ctrl: *@This()) bool { 11 | _ = ctrl; 12 | return true; 13 | } 14 | -------------------------------------------------------------------------------- /src/ui/standard-controls/Picture.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const ui = @import("ui"); 3 | 4 | image: ?ui.Image = null, 5 | size: ImageSize = .contain, 6 | tint: ?ui.Color = null, 7 | 8 | pub fn canReceiveFocus(ctrl: *@This()) bool { 9 | _ = ctrl; 10 | return false; 11 | } 12 | 13 | pub fn isHitTestVisible(ctrl: *@This()) bool { 14 | _ = ctrl; 15 | return true; 16 | } 17 | 18 | pub const ImageSize = enum { 19 | /// The image will be rendered aligned top-left without any scaling. Any excess is cut off. 20 | unscaled, 21 | 22 | /// The image will be rendered centered without any scaling. Any excess is cut off. 23 | centered, 24 | 25 | /// scales to fit, the image fills as much as possible of the widget without cutting borders. 26 | /// This is useful for picture viewers. 27 | zoom, 28 | 29 | /// scales to fill, 100% of the widget area is filled with the image without squishing the image. 30 | /// This is useful for backgrounds. 31 | cover, 32 | 33 | /// scales to fit if the image is larger than the widget, otherwise centered the image. 34 | /// This is useful for picture viewers. 35 | contain, 36 | 37 | /// scales to fill, the image is stretched to the aspect of the widget. 38 | /// This is useful for nice gradient backgrounds. 39 | stretch, 40 | }; 41 | -------------------------------------------------------------------------------- /src/ui/standard-controls/RadioButton.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const ui = @import("ui"); 3 | 4 | const RadioButton = @This(); 5 | 6 | /// A radio group stores which of several radio buttons is 7 | /// selected. 8 | /// This is done by using a common `selection` index, and 9 | /// each radio button has a property `selector` that defines 10 | /// on which index the button is considered *active*. 11 | pub const RadioGroup = struct { 12 | selection: u32, 13 | 14 | /// Is triggered, when a button changes the 15 | /// active selection. 16 | on_selection_changed: ?ui.EventHandler = null, 17 | }; 18 | 19 | on_click: ?ui.EventHandler = null, 20 | 21 | font: ?ui.Font = null, 22 | text: ?[]const u8 = null, 23 | 24 | group: *RadioGroup, 25 | 26 | /// Determines on which `group.selection` value the button 27 | /// is active. 28 | selector: u32, 29 | 30 | pub fn canReceiveFocus(ctrl: RadioButton) bool { 31 | _ = ctrl; 32 | return true; 33 | } 34 | 35 | pub fn isHitTestVisible(ctrl: RadioButton) bool { 36 | _ = ctrl; 37 | return true; 38 | } 39 | -------------------------------------------------------------------------------- /src/ui/standard-controls/RichTextEditor.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/ScrollBar.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/ScrollPanel.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/StatusBar.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return false; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/TabView.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/TextBox.zig: -------------------------------------------------------------------------------- 1 | //! 2 | //! Implementation of a single-line text editor 3 | //! 4 | 5 | const std = @import("std"); 6 | const TextEditor = @import("TextEditor"); 7 | const ui = @import("ui"); 8 | const TextBox = @This(); 9 | const logger = std.log.scoped(.TextBox); 10 | 11 | const Flags = packed struct { 12 | password: bool = false, 13 | read_only: bool = false, 14 | }; 15 | 16 | // public: 17 | flags: Flags = .{}, 18 | editor: TextEditor = undefined, 19 | font: ?ui.Font = null, 20 | 21 | // private: 22 | 23 | /// The scroll offset of the cursor. Shift of the text to the left. 24 | /// Should be changed by the renderer to scroll the text view left/right on overflow. 25 | scroll_offset: u15 = 0, 26 | 27 | pub fn init(ctrl: *TextBox, allocator: std.mem.Allocator) !void { 28 | ctrl.editor = try TextEditor.init(allocator, ""); 29 | } 30 | 31 | pub fn deinit(ctrl: *TextBox) void { 32 | ctrl.editor.deinit(); 33 | } 34 | 35 | pub fn canReceiveFocus(ctrl: *TextBox) bool { 36 | _ = ctrl; 37 | return true; 38 | } 39 | 40 | pub fn isHitTestVisible(ctrl: *TextBox) bool { 41 | _ = ctrl; 42 | return true; 43 | } 44 | 45 | pub fn setText(ctrl: *TextBox, string: []const u8) !void { 46 | try ctrl.editor.setText(string); 47 | } 48 | 49 | pub fn getText(ctrl: TextBox) []const u8 { 50 | return ctrl.editor.getText(); 51 | } 52 | 53 | pub fn getCursor(ctrl: TextBox) usize { 54 | return ctrl.editor.cursor; 55 | } 56 | 57 | pub fn sendInput(ctrl: *TextBox, widget: *ui.Widget, view: *ui.View, input: ui.Widget.Event) ui.Widget.InputHandling { 58 | _ = widget; 59 | _ = view; 60 | 61 | switch (input) { 62 | .mouse_button_down, 63 | .mouse_button_up, 64 | .mouse_motion, 65 | .mouse_enter, 66 | .mouse_leave, 67 | .click, 68 | .enter, 69 | .leave, 70 | => return .ignore, 71 | 72 | .key_down => |key_info| switch (key_info.key) { 73 | .left => ctrl.editor.moveCursor(.left, if (key_info.modifiers.ctrl) 74 | .word 75 | else 76 | .letter), 77 | .right => ctrl.editor.moveCursor(.right, if (key_info.modifiers.ctrl) 78 | .word 79 | else 80 | .letter), 81 | 82 | .home => ctrl.editor.moveCursor(.left, .line), 83 | .end => ctrl.editor.moveCursor(.right, .line), 84 | 85 | .backspace => ctrl.editor.delete(.left, if (key_info.modifiers.ctrl) 86 | .word 87 | else 88 | .letter), 89 | 90 | .delete => ctrl.editor.delete(.right, if (key_info.modifiers.ctrl) 91 | .word 92 | else 93 | .letter), 94 | 95 | else => return .process, 96 | }, 97 | 98 | .key_up => return .process, 99 | 100 | .text_input => |text| { 101 | ctrl.editor.insertText(text) catch |err| logger.err("Could not insert text: {s}", .{@errorName(err)}); 102 | }, 103 | } 104 | 105 | return .ignore; 106 | } 107 | 108 | pub const Modifiers = struct { 109 | shift: bool = false, 110 | ctrl: bool = false, 111 | alt: bool = false, 112 | super: bool = false, 113 | }; 114 | -------------------------------------------------------------------------------- /src/ui/standard-controls/ToolBar.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/ToolButton.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/TreeView.zig: -------------------------------------------------------------------------------- 1 | pub fn canReceiveFocus(ctrl: *@This()) bool { 2 | _ = ctrl; 3 | return true; 4 | } 5 | 6 | pub fn isHitTestVisible(ctrl: *@This()) bool { 7 | _ = ctrl; 8 | return true; 9 | } 10 | -------------------------------------------------------------------------------- /src/ui/standard-controls/standard-controls.zig: -------------------------------------------------------------------------------- 1 | pub const Label = @import("Label.zig"); 2 | pub const Button = @import("Button.zig"); 3 | pub const MenuBar = @import("MenuBar.zig"); 4 | pub const ToolBar = @import("ToolBar.zig"); 5 | pub const ToolButton = @import("ToolButton.zig"); 6 | pub const ScrollBar = @import("ScrollBar.zig"); 7 | pub const ScrollPanel = @import("ScrollPanel.zig"); 8 | pub const Panel = @import("Panel.zig"); 9 | pub const GroupBox = @import("GroupBox.zig"); 10 | pub const TextBox = @import("TextBox.zig"); 11 | pub const RichTextEditor = @import("RichTextEditor.zig"); 12 | pub const CodeEditor = @import("CodeEditor.zig"); 13 | pub const CheckBox = @import("CheckBox.zig"); 14 | pub const RadioButton = @import("RadioButton.zig"); 15 | pub const TabView = @import("TabView.zig"); 16 | pub const NumericUpDown = @import("NumericUpDown.zig"); 17 | pub const ComboBox = @import("ComboBox.zig"); 18 | pub const TreeView = @import("TreeView.zig"); 19 | pub const ListBox = @import("ListBox.zig"); 20 | pub const StatusBar = @import("StatusBar.zig"); 21 | pub const Picture = @import("Picture.zig"); 22 | pub const Canvas = @import("Canvas.zig"); 23 | pub const DockWindow = @import("DockWindow.zig"); 24 | -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-Black.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-BlackItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-BlackItalic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-Bold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-BoldItalic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-ExtraBold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-ExtraBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-ExtraBoldItalic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-ExtraLight.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-ExtraLightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-ExtraLightItalic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-Italic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-Light.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-LightItalic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-Medium.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-MediumItalic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-Regular.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-SemiBold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-SemiBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-SemiBoldItalic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-Thin.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSans-ThinItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSans-ThinItalic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSansMono-VariableFont_wdth,wght.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSansMono-VariableFont_wdth,wght.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSerif-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSerif-Bold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSerif-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSerif-BoldItalic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSerif-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSerif-Italic.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/NotoSerif-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/NotoSerif-Regular.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Black.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Bold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-ExtraBold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-ExtraLight.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Light.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Medium.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Regular.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-SemiBold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono/NotoSansMono-Thin.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Black.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Bold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-ExtraBold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-ExtraLight.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Light.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Medium.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Regular.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-SemiBold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_Condensed/NotoSansMono_Condensed-Thin.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Black.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Bold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-ExtraBold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-ExtraLight.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Light.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Medium.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Regular.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-SemiBold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_ExtraCondensed/NotoSansMono_ExtraCondensed-Thin.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Black.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Bold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-ExtraBold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-ExtraLight.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Light.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Medium.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Regular.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-SemiBold.ttf -------------------------------------------------------------------------------- /src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/src/ui/standard-renderer/data/fonts/static/NotoSansMono_SemiCondensed/NotoSansMono_SemiCondensed-Thin.ttf -------------------------------------------------------------------------------- /tools/blender-exporter.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | 3 | 4 | def write_some_data(context, filepath, use_some_setting): 5 | print("running write_some_data...") 6 | print(context, context.scene, context.scene.objects, context.selected_objects) 7 | f = open(filepath, 'w', encoding='utf-8') 8 | if use_some_setting: 9 | f.write("Hello with bones") 10 | else: 11 | f.write("Hello without bones") 12 | f.close() 13 | 14 | return {'FINISHED'} 15 | 16 | 17 | # ExportHelper is a helper class, defines filename and 18 | # invoke() function which calls the file selector. 19 | from bpy_extras.io_utils import ExportHelper 20 | from bpy.props import StringProperty, BoolProperty, EnumProperty 21 | from bpy.types import Operator 22 | 23 | 24 | class ExportZeroGraphicsModel(Operator, ExportHelper): 25 | """Exports a 3D model for the use with zero-graphics.""" 26 | bl_idname = "export_zero_graphics_3d.model" # important since its how bpy.ops.import_test.some_data is constructed 27 | bl_label = "Export model" 28 | 29 | # ExportHelper mixin class uses this 30 | filename_ext = ".z3d" 31 | 32 | filter_glob: StringProperty( 33 | default="*.z3d", 34 | options={'HIDDEN'}, 35 | maxlen=255, # Max internal buffer length, longer would be clamped. 36 | ) 37 | 38 | # List of operator properties, the attributes will be assigned 39 | # to the class instance from the operator settings before calling. 40 | include_bones: BoolProperty( 41 | name="Include Bones", 42 | description="If this is checked, the model will be a dynamic model with skinned vertices and a bone structure.", 43 | default=False, 44 | ) 45 | 46 | def execute(self, context): 47 | return write_some_data(context, self.filepath, self.include_bones) 48 | 49 | 50 | # Only needed if you want to add into a dynamic menu 51 | def menu_func_export(self, context): 52 | self.layout.operator(ExportZeroGraphicsModel.bl_idname, text="Export zero-graphics model") 53 | 54 | 55 | def register(): 56 | bpy.utils.register_class(ExportZeroGraphicsModel) 57 | bpy.types.TOPBAR_MT_file_export.append(menu_func_export) 58 | 59 | 60 | def unregister(): 61 | bpy.utils.unregister_class(ExportZeroGraphicsModel) 62 | bpy.types.TOPBAR_MT_file_export.remove(menu_func_export) 63 | 64 | 65 | if __name__ == "__main__": 66 | register() 67 | 68 | # test call 69 | bpy.ops.export_zero_graphics_3d.model('INVOKE_DEFAULT') 70 | -------------------------------------------------------------------------------- /tools/http-server.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const http = @import("apple_pie"); 3 | const file_server = http.FileServer; 4 | 5 | pub const io_mode = .evented; 6 | 7 | pub fn main() !u8 { 8 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; 9 | defer _ = gpa.deinit(); 10 | const allocator = gpa.allocator(); 11 | 12 | const args = try std.process.argsAlloc(allocator); 13 | defer std.process.argsFree(allocator, args); 14 | 15 | if (args.len != 2) { 16 | std.log.err("Missing argument: Application name!", .{}); 17 | return 1; 18 | } 19 | 20 | const application_name = args[1]; 21 | 22 | try file_server.init(allocator, .{ .dir_path = "." }); 23 | defer file_server.deinit(); 24 | 25 | std.log.info("Application is now served at http://127.0.0.1:8000/{s}.htm", .{application_name}); 26 | 27 | try http.listenAndServe( 28 | allocator, 29 | try std.net.Address.parseIp("127.0.0.1", 8000), 30 | {}, 31 | file_server.serve, 32 | ); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /tools/render-ztt-page.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const html = @import("html"); 3 | 4 | // {exe} target_file application_name display_name 5 | pub fn main() !void { 6 | const args = try std.process.argsAlloc(std.heap.page_allocator); 7 | if (args.len != 4) @panic("invalid number of arguments!"); 8 | 9 | var f = try std.fs.cwd().createFile(args[1], .{}); 10 | defer f.close(); 11 | 12 | try html.render(f.writer(), .{ 13 | .app_name = args[2], 14 | .display_name = args[3], 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /tools/zero-convert/api.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | struct MeshStream { 12 | void (*writeStaticHeader)(struct MeshStream *, size_t vertices, size_t indices, size_t ranges); 13 | void (*writeVertex)(struct MeshStream *, float x, float y, float z, float nx, float ny, float nz, float u, float v); 14 | void (*writeFace)(struct MeshStream *, uint16_t i0, uint16_t i1, uint16_t i2); 15 | void (*writeMeshRange)(struct MeshStream *, size_t offset, size_t count, char const *texture); 16 | }; 17 | 18 | enum FileType { 19 | dynamic_geometry = 0, 20 | static_geometry = 1, 21 | }; 22 | 23 | bool transformFile(char const *src_file_name, struct MeshStream *stream, enum FileType create_static_model); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif -------------------------------------------------------------------------------- /tools/zero-init/template/build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const Sdk = @import("vendor/zero-graphics/Sdk.zig"); 3 | 4 | pub fn build(b: *std.build.Builder) !void { 5 | const enable_android = b.option(bool, "enable-android", "Enables android build support. Requires the android sdk and ndk to be installed.") orelse false; 6 | 7 | const sdk = Sdk.init(b, enable_android); 8 | 9 | const mode = b.standardReleaseOptions(); 10 | const platform = sdk.standardPlatformOptions(); 11 | 12 | const app = sdk.createApplication("new_project", "src/main.zig"); 13 | app.setDisplayName("New Project"); 14 | app.setPackageName("com.example.new_project"); 15 | app.setBuildMode(mode); 16 | 17 | { 18 | const desktop_exe = app.compileFor(platform); 19 | desktop_exe.install(); 20 | 21 | const run_cmd = desktop_exe.run(); 22 | run_cmd.step.dependOn(b.getInstallStep()); 23 | if (b.args) |args| { 24 | run_cmd.addArgs(args); 25 | } 26 | 27 | const run_step = b.step("run", "Run the app"); 28 | run_step.dependOn(&run_cmd.step); 29 | } 30 | 31 | // Build wasm application 32 | { 33 | const wasm_build = app.compileFor(.web); 34 | wasm_build.install(); 35 | } 36 | 37 | if (enable_android) { 38 | const android_build = app.compileFor(.android); 39 | android_build.install(); 40 | 41 | b.step("init-keystore", "Initializes a fresh debug keystore.").dependOn(sdk.initializeKeystore()); 42 | 43 | const push = android_build.data.android.install(); 44 | 45 | const run = android_build.data.android.run(); 46 | run.dependOn(push); 47 | 48 | const push_step = b.step("install-app", "Push the app to the default ADB target"); 49 | push_step.dependOn(push); 50 | 51 | const run_step = b.step("run-app", "Runs the Android app on the default ADB target"); 52 | run_step.dependOn(run); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tools/zero-init/template/gitattributes: -------------------------------------------------------------------------------- 1 | *.zig text=auto eol=lf -------------------------------------------------------------------------------- /tools/zero-init/template/gitignore: -------------------------------------------------------------------------------- 1 | zig-cache/ 2 | zig-out/ 3 | *.tga 4 | .build_config/ 5 | hackzig/ 6 | -------------------------------------------------------------------------------- /tools/zero-init/template/src/main.zig: -------------------------------------------------------------------------------- 1 | //! This file must export the following functions: 2 | //! - `pub fn init(app: *Application, allocator: std.mem.Allocator) !void` 3 | //! - `pub fn update(app: *Application) !bool` 4 | //! - `pub fn render(app: *Application) !void` 5 | //! - `pub fn deinit(app: *Application) void` 6 | //! 7 | //! This file *can* export the following functions: 8 | //! - `pub fn setupGraphics(app: *Application) !void` 9 | //! - `pub fn resize(app: *Application, width: u15, height: u15) !void` 10 | //! - `pub fn teardownGraphics(app: *Application) void` 11 | //! 12 | 13 | const std = @import("std"); 14 | const builtin = @import("builtin"); 15 | const zero_graphics = @import("zero-graphics"); 16 | 17 | const logger = std.log.scoped(.demo); 18 | const gl = zero_graphics.gles; 19 | 20 | const core = zero_graphics.CoreApplication.get; 21 | 22 | const Application = @This(); 23 | 24 | pub fn init(app: *Application) !void { 25 | app.* = Application{}; 26 | // TODO: initialize your application logic here! 27 | } 28 | 29 | pub fn deinit(app: *Application) void { 30 | // TODO: shut down your application here 31 | app.* = undefined; 32 | } 33 | 34 | pub fn update(app: *Application) !bool { 35 | 36 | // TODO: process input events here: 37 | while (core().input.fetch()) |event| { 38 | switch (event) { 39 | .quit => return false, 40 | .pointer_motion => {}, 41 | .pointer_press => {}, 42 | .pointer_release => {}, 43 | .text_input => {}, 44 | .key_down => {}, 45 | .key_up => {}, 46 | } 47 | } 48 | 49 | _ = app; 50 | 51 | return true; 52 | } 53 | 54 | pub fn render(app: *Application) !void { 55 | gl.clearColor(0.3, 0.3, 0.3, 1.0); 56 | gl.clearDepthf(1.0); 57 | gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 58 | 59 | // Render your application here 60 | _ = app; 61 | } 62 | -------------------------------------------------------------------------------- /vendor/scintilla/cocoa/InfoBar.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Scintilla source code edit control 4 | * InfoBar.h - Implements special info bar with zoom info, caret position etc. to be used with 5 | * ScintillaView. 6 | * 7 | * Mike Lischke 8 | * 9 | * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 10 | * This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt). 11 | */ 12 | 13 | #import 14 | #import "InfoBarCommunicator.h" 15 | 16 | /** 17 | * Extended text cell for vertically aligned text. 18 | */ 19 | @interface VerticallyCenteredTextFieldCell : NSTextFieldCell 20 | { 21 | BOOL mIsEditingOrSelecting; 22 | } 23 | 24 | @end 25 | 26 | @interface InfoBar : NSView 27 | { 28 | @private 29 | NSImage* mBackground; 30 | IBDisplay mDisplayMask; 31 | 32 | float mScaleFactor; 33 | NSPopUpButton* mZoomPopup; 34 | 35 | int mCurrentCaretX; 36 | int mCurrentCaretY; 37 | NSTextField* mCaretPositionLabel; 38 | NSTextField* mStatusTextLabel; 39 | 40 | id mCallback; 41 | } 42 | 43 | - (void) notify: (NotificationType) type message: (NSString*) message location: (NSPoint) location 44 | value: (float) value; 45 | - (void) setCallback: (id ) callback; 46 | 47 | - (void) createItems; 48 | - (void) positionSubViews; 49 | - (void) setDisplay: (IBDisplay) display; 50 | - (void) zoomItemAction: (id) sender; 51 | - (void) setScaleFactor: (float) newScaleFactor adjustPopup: (BOOL) flag; 52 | - (void) setCaretPosition: (NSPoint) position; 53 | - (void) sizeToFit; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /vendor/scintilla/cocoa/InfoBarCommunicator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * InfoBarCommunicator.h - Definitions of a communication protocol and other data types used for 3 | * the info bar implementation. 4 | * 5 | * Mike Lischke 6 | * 7 | * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 8 | * This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt). 9 | */ 10 | 11 | typedef NS_OPTIONS(NSUInteger, IBDisplay) { 12 | IBShowZoom = 0x01, 13 | IBShowCaretPosition = 0x02, 14 | IBShowStatusText = 0x04, 15 | IBShowAll = 0xFF 16 | }; 17 | 18 | /** 19 | * The info bar communicator protocol is used for communication between ScintillaView and its 20 | * information bar component. Using this protocol decouples any potential info target from the main 21 | * ScintillaView implementation. The protocol is used two-way. 22 | */ 23 | 24 | typedef NS_ENUM(NSInteger, NotificationType) { 25 | IBNZoomChanged, // The user selected another zoom value. 26 | IBNCaretChanged, // The caret in the editor changed. 27 | IBNStatusChanged, // The application set a new status message. 28 | }; 29 | 30 | @protocol InfoBarCommunicator 31 | - (void) notify: (NotificationType) type message: (NSString*) message location: (NSPoint) location 32 | value: (float) value; 33 | - (void) setCallback: (id ) callback; 34 | @end 35 | 36 | -------------------------------------------------------------------------------- /vendor/scintilla/cocoa/QuartzTextLayout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * QuartzTextLayout.h 3 | * 4 | * Original Code by Evan Jones on Wed Oct 02 2002. 5 | * Contributors: 6 | * Shane Caraveo, ActiveState 7 | * Bernd Paradies, Adobe 8 | * 9 | */ 10 | 11 | #ifndef _QUARTZ_TEXT_LAYOUT_H 12 | #define _QUARTZ_TEXT_LAYOUT_H 13 | 14 | #include 15 | 16 | #include "QuartzTextStyle.h" 17 | 18 | 19 | class QuartzTextLayout 20 | { 21 | public: 22 | /** Create a text layout for drawing on the specified context. */ 23 | explicit QuartzTextLayout( CGContextRef context ) 24 | { 25 | mString = NULL; 26 | mLine = NULL; 27 | stringLength = 0; 28 | setContext(context); 29 | } 30 | 31 | ~QuartzTextLayout() 32 | { 33 | if ( mString != NULL ) 34 | { 35 | CFRelease(mString); 36 | mString = NULL; 37 | } 38 | if ( mLine != NULL ) 39 | { 40 | CFRelease(mLine); 41 | mLine = NULL; 42 | } 43 | } 44 | 45 | inline void setText( const UInt8* buffer, size_t byteLength, CFStringEncoding encoding, const QuartzTextStyle& r ) 46 | { 47 | CFStringRef str = CFStringCreateWithBytes( NULL, buffer, byteLength, encoding, false ); 48 | if (!str) 49 | return; 50 | 51 | stringLength = CFStringGetLength(str); 52 | 53 | CFMutableDictionaryRef stringAttribs = r.getCTStyle(); 54 | 55 | if (mString != NULL) 56 | CFRelease(mString); 57 | mString = ::CFAttributedStringCreate(NULL, str, stringAttribs); 58 | 59 | if (mLine != NULL) 60 | CFRelease(mLine); 61 | mLine = ::CTLineCreateWithAttributedString(mString); 62 | 63 | CFRelease( str ); 64 | } 65 | 66 | /** Draw the text layout into the current CGContext at the specified position. 67 | * @param x The x axis position to draw the baseline in the current CGContext. 68 | * @param y The y axis position to draw the baseline in the current CGContext. */ 69 | void draw( float x, float y ) 70 | { 71 | if (mLine == NULL) 72 | return; 73 | 74 | ::CGContextSetTextMatrix(gc, CGAffineTransformMakeScale(1.0, -1.0)); 75 | 76 | // Set the text drawing position. 77 | ::CGContextSetTextPosition(gc, x, y); 78 | 79 | // And finally, draw! 80 | ::CTLineDraw(mLine, gc); 81 | } 82 | 83 | float MeasureStringWidth() 84 | { 85 | if (mLine == NULL) 86 | return 0.0f; 87 | 88 | return ::CTLineGetTypographicBounds(mLine, NULL, NULL, NULL); 89 | } 90 | 91 | CTLineRef getCTLine() { 92 | return mLine; 93 | } 94 | 95 | CFIndex getStringLength() { 96 | return stringLength; 97 | } 98 | 99 | inline void setContext (CGContextRef context) 100 | { 101 | gc = context; 102 | } 103 | 104 | private: 105 | CGContextRef gc; 106 | CFAttributedStringRef mString; 107 | CTLineRef mLine; 108 | CFIndex stringLength; 109 | }; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /vendor/scintilla/cocoa/QuartzTextStyle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * QuartzTextStyle.h 3 | * 4 | * Created by Evan Jones on Wed Oct 02 2002. 5 | * 6 | */ 7 | 8 | #ifndef _QUARTZ_TEXT_STYLE_H 9 | #define _QUARTZ_TEXT_STYLE_H 10 | 11 | #include "QuartzTextStyleAttribute.h" 12 | 13 | class QuartzTextStyle 14 | { 15 | public: 16 | QuartzTextStyle() 17 | { 18 | fontRef = NULL; 19 | styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, 20 | &kCFTypeDictionaryKeyCallBacks, 21 | &kCFTypeDictionaryValueCallBacks); 22 | 23 | characterSet = 0; 24 | } 25 | 26 | QuartzTextStyle(const QuartzTextStyle &other) 27 | { 28 | // Does not copy font colour attribute 29 | fontRef = static_cast(CFRetain(other.fontRef)); 30 | styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, 31 | &kCFTypeDictionaryKeyCallBacks, 32 | &kCFTypeDictionaryValueCallBacks); 33 | CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef); 34 | characterSet = other.characterSet; 35 | } 36 | 37 | ~QuartzTextStyle() 38 | { 39 | if (styleDict != NULL) 40 | { 41 | CFRelease(styleDict); 42 | styleDict = NULL; 43 | } 44 | 45 | if (fontRef) 46 | { 47 | CFRelease(fontRef); 48 | fontRef = NULL; 49 | } 50 | } 51 | 52 | CFMutableDictionaryRef getCTStyle() const 53 | { 54 | return styleDict; 55 | } 56 | 57 | void setCTStyleColor(CGColor *inColor) 58 | { 59 | CFDictionarySetValue(styleDict, kCTForegroundColorAttributeName, inColor); 60 | } 61 | 62 | float getAscent() const 63 | { 64 | return ::CTFontGetAscent(fontRef); 65 | } 66 | 67 | float getDescent() const 68 | { 69 | return ::CTFontGetDescent(fontRef); 70 | } 71 | 72 | float getLeading() const 73 | { 74 | return ::CTFontGetLeading(fontRef); 75 | } 76 | 77 | void setFontRef(CTFontRef inRef, int characterSet_) 78 | { 79 | fontRef = inRef; 80 | characterSet = characterSet_; 81 | 82 | if (styleDict != NULL) 83 | CFRelease(styleDict); 84 | 85 | styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, 86 | &kCFTypeDictionaryKeyCallBacks, 87 | &kCFTypeDictionaryValueCallBacks); 88 | 89 | CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef); 90 | } 91 | 92 | CTFontRef getFontRef() 93 | { 94 | return fontRef; 95 | } 96 | 97 | int getCharacterSet() 98 | { 99 | return characterSet; 100 | } 101 | 102 | private: 103 | CFMutableDictionaryRef styleDict; 104 | CTFontRef fontRef; 105 | int characterSet; 106 | }; 107 | 108 | #endif 109 | 110 | -------------------------------------------------------------------------------- /vendor/scintilla/cocoa/QuartzTextStyleAttribute.h: -------------------------------------------------------------------------------- 1 | /** 2 | * QuartzTextStyleAttribute.h 3 | * 4 | * Original Code by Evan Jones on Wed Oct 02 2002. 5 | * Contributors: 6 | * Shane Caraveo, ActiveState 7 | * Bernd Paradies, Adobe 8 | * 9 | */ 10 | 11 | 12 | #ifndef _QUARTZ_TEXT_STYLE_ATTRIBUTE_H 13 | #define _QUARTZ_TEXT_STYLE_ATTRIBUTE_H 14 | 15 | class QuartzFont 16 | { 17 | public: 18 | /** Create a font style from a name. */ 19 | QuartzFont( const char* name, size_t length, float size, int weight, bool italic ) 20 | { 21 | assert( name != NULL && length > 0 && name[length] == '\0' ); 22 | 23 | CFStringRef fontName = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingMacRoman); 24 | assert(fontName != NULL); 25 | bool bold = weight > SC_WEIGHT_NORMAL; 26 | 27 | if (bold || italic) 28 | { 29 | CTFontSymbolicTraits desiredTrait = 0; 30 | CTFontSymbolicTraits traitMask = 0; 31 | 32 | // if bold was specified, add the trait 33 | if (bold) { 34 | desiredTrait |= kCTFontBoldTrait; 35 | traitMask |= kCTFontBoldTrait; 36 | } 37 | 38 | // if italic was specified, add the trait 39 | if (italic) { 40 | desiredTrait |= kCTFontItalicTrait; 41 | traitMask |= kCTFontItalicTrait; 42 | } 43 | 44 | // create a font and then a copy of it with the sym traits 45 | CTFontRef iFont = ::CTFontCreateWithName(fontName, size, NULL); 46 | fontid = ::CTFontCreateCopyWithSymbolicTraits(iFont, size, NULL, desiredTrait, traitMask); 47 | if (fontid) 48 | { 49 | CFRelease(iFont); 50 | } 51 | else 52 | { 53 | // Traits failed so use base font 54 | fontid = iFont; 55 | } 56 | } 57 | else 58 | { 59 | // create the font, no traits 60 | fontid = ::CTFontCreateWithName(fontName, size, NULL); 61 | } 62 | 63 | if (!fontid) 64 | { 65 | // Failed to create requested font so use font always present 66 | fontid = ::CTFontCreateWithName((CFStringRef)@"Monaco", size, NULL); 67 | } 68 | 69 | CFRelease(fontName); 70 | } 71 | 72 | CTFontRef getFontID() 73 | { 74 | return fontid; 75 | } 76 | 77 | private: 78 | CTFontRef fontid; 79 | }; 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /vendor/scintilla/cocoa/ScintillaTest/AppController.h: -------------------------------------------------------------------------------- 1 | /** 2 | * AppController.h 3 | * SciTest 4 | * 5 | * Created by Mike Lischke on 01.04.09. 6 | * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 7 | * This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt). 8 | */ 9 | 10 | #import 11 | 12 | #import "Scintilla/ScintillaView.h" 13 | #import "Scintilla/InfoBar.h" 14 | 15 | @interface AppController : NSObject { 16 | IBOutlet NSBox *mEditHost; 17 | ScintillaView* mEditor; 18 | } 19 | 20 | - (void) awakeFromNib; 21 | - (void) setupEditor; 22 | - (IBAction) searchText: (id) sender; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /vendor/scintilla/gtk/Converter.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | // Converter.h - Encapsulation of iconv 3 | // Copyright 2004 by Neil Hodgson 4 | // The License.txt file describes the conditions under which this software may be distributed. 5 | 6 | #ifndef CONVERTER_H 7 | #define CONVERTER_H 8 | 9 | #ifdef SCI_NAMESPACE 10 | namespace Scintilla { 11 | #endif 12 | 13 | typedef GIConv ConverterHandle; 14 | const ConverterHandle iconvhBad = (ConverterHandle)(-1); 15 | // Since various versions of iconv can not agree on whether the src argument 16 | // is char ** or const char ** provide a templatised adaptor. 17 | template 18 | size_t iconv_adaptor(size_t(*f_iconv)(ConverterHandle, T, size_t *, char **, size_t *), 19 | ConverterHandle cd, char** src, size_t *srcleft, 20 | char **dst, size_t *dstleft) { 21 | return f_iconv(cd, (T)src, srcleft, dst, dstleft); 22 | } 23 | /** 24 | * Encapsulate iconv safely and avoid iconv_adaptor complexity in client code. 25 | */ 26 | class Converter { 27 | ConverterHandle iconvh; 28 | void OpenHandle(const char *fullDestination, const char *charSetSource) { 29 | iconvh = g_iconv_open(fullDestination, charSetSource); 30 | } 31 | bool Succeeded() const { 32 | return iconvh != iconvhBad; 33 | } 34 | public: 35 | Converter() { 36 | iconvh = iconvhBad; 37 | } 38 | Converter(const char *charSetDestination, const char *charSetSource, bool transliterations) { 39 | iconvh = iconvhBad; 40 | Open(charSetDestination, charSetSource, transliterations); 41 | } 42 | ~Converter() { 43 | Close(); 44 | } 45 | operator bool() const { 46 | return Succeeded(); 47 | } 48 | void Open(const char *charSetDestination, const char *charSetSource, bool transliterations=true) { 49 | Close(); 50 | if (*charSetSource) { 51 | // Try allowing approximate transliterations 52 | if (transliterations) { 53 | char fullDest[200]; 54 | g_strlcpy(fullDest, charSetDestination, sizeof(fullDest)); 55 | g_strlcat(fullDest, "//TRANSLIT", sizeof(fullDest)); 56 | OpenHandle(fullDest, charSetSource); 57 | } 58 | if (!Succeeded()) { 59 | // Transliterations failed so try basic name 60 | OpenHandle(charSetDestination, charSetSource); 61 | } 62 | } 63 | } 64 | void Close() { 65 | if (Succeeded()) { 66 | g_iconv_close(iconvh); 67 | iconvh = iconvhBad; 68 | } 69 | } 70 | size_t Convert(char** src, size_t *srcleft, char **dst, size_t *dstleft) const { 71 | if (!Succeeded()) { 72 | return (size_t)(-1); 73 | } else { 74 | return iconv_adaptor(g_iconv, iconvh, src, srcleft, dst, dstleft); 75 | } 76 | } 77 | }; 78 | 79 | #ifdef SCI_NAMESPACE 80 | } 81 | #endif 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /vendor/scintilla/gtk/scintilla-marshal.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __scintilla_marshal_MARSHAL_H__ 3 | #define __scintilla_marshal_MARSHAL_H__ 4 | 5 | #include 6 | 7 | G_BEGIN_DECLS 8 | 9 | /* NONE:INT,POINTER (scintilla-marshal.list:1) */ 10 | extern void scintilla_marshal_VOID__INT_POINTER (GClosure *closure, 11 | GValue *return_value, 12 | guint n_param_values, 13 | const GValue *param_values, 14 | gpointer invocation_hint, 15 | gpointer marshal_data); 16 | #define scintilla_marshal_NONE__INT_POINTER scintilla_marshal_VOID__INT_POINTER 17 | 18 | G_END_DECLS 19 | 20 | #endif /* __scintilla_marshal_MARSHAL_H__ */ 21 | 22 | -------------------------------------------------------------------------------- /vendor/scintilla/include/ScintillaWidget.h: -------------------------------------------------------------------------------- 1 | /* Scintilla source code edit control */ 2 | /** @file ScintillaWidget.h 3 | ** Definition of Scintilla widget for GTK+. 4 | ** Only needed by GTK+ code but is harmless on other platforms. 5 | **/ 6 | /* Copyright 1998-2001 by Neil Hodgson 7 | * The License.txt file describes the conditions under which this software may be distributed. */ 8 | 9 | #ifndef SCINTILLAWIDGET_H 10 | #define SCINTILLAWIDGET_H 11 | 12 | #if defined(GTK) 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #define SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, scintilla_get_type (), ScintillaObject) 19 | #define SCINTILLA_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, scintilla_get_type (), ScintillaClass) 20 | #define IS_SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, scintilla_get_type ()) 21 | 22 | typedef struct _ScintillaObject ScintillaObject; 23 | typedef struct _ScintillaClass ScintillaClass; 24 | 25 | struct _ScintillaObject { 26 | GtkContainer cont; 27 | void *pscin; 28 | }; 29 | 30 | struct _ScintillaClass { 31 | GtkContainerClass parent_class; 32 | 33 | void (* command) (ScintillaObject *ttt); 34 | void (* notify) (ScintillaObject *ttt); 35 | }; 36 | 37 | GType scintilla_get_type (void); 38 | GtkWidget* scintilla_new (void); 39 | void scintilla_set_id (ScintillaObject *sci, uptr_t id); 40 | sptr_t scintilla_send_message (ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam); 41 | void scintilla_release_resources(void); 42 | 43 | #define SCINTILLA_NOTIFY "sci-notify" 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /vendor/scintilla/lexers/LexCSS.cxx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/vendor/scintilla/lexers/LexCSS.cxx -------------------------------------------------------------------------------- /vendor/scintilla/lexers/LexErlang.cxx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/vendor/scintilla/lexers/LexErlang.cxx -------------------------------------------------------------------------------- /vendor/scintilla/lexers/LexMMIXAL.cxx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/vendor/scintilla/lexers/LexMMIXAL.cxx -------------------------------------------------------------------------------- /vendor/scintilla/lexers/LexMatlab.cxx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikskuh/zero-graphics/584f452de5aa28a4a24c978b607ed0e4f0a4ebe6/vendor/scintilla/lexers/LexMatlab.cxx -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/Accessor.cxx: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file KeyWords.cxx 3 | ** Colourise for particular languages. 4 | **/ 5 | // Copyright 1998-2002 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "ILexer.h" 16 | #include "Scintilla.h" 17 | #include "SciLexer.h" 18 | 19 | #include "PropSetSimple.h" 20 | #include "WordList.h" 21 | #include "LexAccessor.h" 22 | #include "Accessor.h" 23 | 24 | #ifdef SCI_NAMESPACE 25 | using namespace Scintilla; 26 | #endif 27 | 28 | Accessor::Accessor(IDocument *pAccess_, PropSetSimple *pprops_) : LexAccessor(pAccess_), pprops(pprops_) { 29 | } 30 | 31 | int Accessor::GetPropertyInt(const char *key, int defaultValue) const { 32 | return pprops->GetInt(key, defaultValue); 33 | } 34 | 35 | int Accessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) { 36 | int end = Length(); 37 | int spaceFlags = 0; 38 | 39 | // Determines the indentation level of the current line and also checks for consistent 40 | // indentation compared to the previous line. 41 | // Indentation is judged consistent when the indentation whitespace of each line lines 42 | // the same or the indentation of one line is a prefix of the other. 43 | 44 | int pos = LineStart(line); 45 | char ch = (*this)[pos]; 46 | int indent = 0; 47 | bool inPrevPrefix = line > 0; 48 | int posPrev = inPrevPrefix ? LineStart(line-1) : 0; 49 | while ((ch == ' ' || ch == '\t') && (pos < end)) { 50 | if (inPrevPrefix) { 51 | char chPrev = (*this)[posPrev++]; 52 | if (chPrev == ' ' || chPrev == '\t') { 53 | if (chPrev != ch) 54 | spaceFlags |= wsInconsistent; 55 | } else { 56 | inPrevPrefix = false; 57 | } 58 | } 59 | if (ch == ' ') { 60 | spaceFlags |= wsSpace; 61 | indent++; 62 | } else { // Tab 63 | spaceFlags |= wsTab; 64 | if (spaceFlags & wsSpace) 65 | spaceFlags |= wsSpaceTab; 66 | indent = (indent / 8 + 1) * 8; 67 | } 68 | ch = (*this)[++pos]; 69 | } 70 | 71 | *flags = spaceFlags; 72 | indent += SC_FOLDLEVELBASE; 73 | // if completely empty line or the start of a comment... 74 | if ((LineStart(line) == Length()) || (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') || 75 | (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos))) 76 | return indent | SC_FOLDLEVELWHITEFLAG; 77 | else 78 | return indent; 79 | } 80 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/Accessor.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file Accessor.h 3 | ** Interfaces between Scintilla and lexers. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef ACCESSOR_H 9 | #define ACCESSOR_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | enum { wsSpace=1, wsTab=2, wsSpaceTab=4, wsInconsistent=8 }; 16 | 17 | class Accessor; 18 | class WordList; 19 | class PropSetSimple; 20 | 21 | typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len); 22 | 23 | class Accessor : public LexAccessor { 24 | public: 25 | PropSetSimple *pprops; 26 | Accessor(IDocument *pAccess_, PropSetSimple *pprops_); 27 | int GetPropertyInt(const char *, int defaultValue=0) const; 28 | int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0); 29 | }; 30 | 31 | #ifdef SCI_NAMESPACE 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/CharacterCategory.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file CharacterCategory.h 3 | ** Returns the Unicode general category of a character. 4 | **/ 5 | // Copyright 2013 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef CHARACTERCATEGORY_H 9 | #define CHARACTERCATEGORY_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | enum CharacterCategory { 16 | ccLu, ccLl, ccLt, ccLm, ccLo, 17 | ccMn, ccMc, ccMe, 18 | ccNd, ccNl, ccNo, 19 | ccPc, ccPd, ccPs, ccPe, ccPi, ccPf, ccPo, 20 | ccSm, ccSc, ccSk, ccSo, 21 | ccZs, ccZl, ccZp, 22 | ccCc, ccCf, ccCs, ccCo, ccCn 23 | }; 24 | 25 | CharacterCategory CategoriseCharacter(int character); 26 | 27 | #ifdef SCI_NAMESPACE 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/CharacterSet.cxx: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file CharacterSet.cxx 3 | ** Simple case functions for ASCII. 4 | ** Lexer infrastructure. 5 | **/ 6 | // Copyright 1998-2010 by Neil Hodgson 7 | // The License.txt file describes the conditions under which this software may be distributed. 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "CharacterSet.h" 16 | 17 | #ifdef SCI_NAMESPACE 18 | using namespace Scintilla; 19 | #endif 20 | 21 | #ifdef SCI_NAMESPACE 22 | namespace Scintilla { 23 | #endif 24 | 25 | int CompareCaseInsensitive(const char *a, const char *b) { 26 | while (*a && *b) { 27 | if (*a != *b) { 28 | char upperA = MakeUpperCase(*a); 29 | char upperB = MakeUpperCase(*b); 30 | if (upperA != upperB) 31 | return upperA - upperB; 32 | } 33 | a++; 34 | b++; 35 | } 36 | // Either *a or *b is nul 37 | return *a - *b; 38 | } 39 | 40 | int CompareNCaseInsensitive(const char *a, const char *b, size_t len) { 41 | while (*a && *b && len) { 42 | if (*a != *b) { 43 | char upperA = MakeUpperCase(*a); 44 | char upperB = MakeUpperCase(*b); 45 | if (upperA != upperB) 46 | return upperA - upperB; 47 | } 48 | a++; 49 | b++; 50 | len--; 51 | } 52 | if (len == 0) 53 | return 0; 54 | else 55 | // Either *a or *b is nul 56 | return *a - *b; 57 | } 58 | 59 | #ifdef SCI_NAMESPACE 60 | } 61 | #endif 62 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/LexerBase.cxx: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file LexerBase.cxx 3 | ** A simple lexer with no state. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "ILexer.h" 16 | #include "Scintilla.h" 17 | #include "SciLexer.h" 18 | 19 | #include "PropSetSimple.h" 20 | #include "WordList.h" 21 | #include "LexAccessor.h" 22 | #include "Accessor.h" 23 | #include "LexerModule.h" 24 | #include "LexerBase.h" 25 | 26 | #ifdef SCI_NAMESPACE 27 | using namespace Scintilla; 28 | #endif 29 | 30 | LexerBase::LexerBase() { 31 | for (int wl = 0; wl < numWordLists; wl++) 32 | keyWordLists[wl] = new WordList; 33 | keyWordLists[numWordLists] = 0; 34 | } 35 | 36 | LexerBase::~LexerBase() { 37 | for (int wl = 0; wl < numWordLists; wl++) { 38 | delete keyWordLists[wl]; 39 | keyWordLists[wl] = 0; 40 | } 41 | keyWordLists[numWordLists] = 0; 42 | } 43 | 44 | void SCI_METHOD LexerBase::Release() { 45 | delete this; 46 | } 47 | 48 | int SCI_METHOD LexerBase::Version() const { 49 | return lvOriginal; 50 | } 51 | 52 | const char * SCI_METHOD LexerBase::PropertyNames() { 53 | return ""; 54 | } 55 | 56 | int SCI_METHOD LexerBase::PropertyType(const char *) { 57 | return SC_TYPE_BOOLEAN; 58 | } 59 | 60 | const char * SCI_METHOD LexerBase::DescribeProperty(const char *) { 61 | return ""; 62 | } 63 | 64 | int SCI_METHOD LexerBase::PropertySet(const char *key, const char *val) { 65 | const char *valOld = props.Get(key); 66 | if (strcmp(val, valOld) != 0) { 67 | props.Set(key, val); 68 | return 0; 69 | } else { 70 | return -1; 71 | } 72 | } 73 | 74 | const char * SCI_METHOD LexerBase::DescribeWordListSets() { 75 | return ""; 76 | } 77 | 78 | int SCI_METHOD LexerBase::WordListSet(int n, const char *wl) { 79 | if (n < numWordLists) { 80 | WordList wlNew; 81 | wlNew.Set(wl); 82 | if (*keyWordLists[n] != wlNew) { 83 | keyWordLists[n]->Set(wl); 84 | return 0; 85 | } 86 | } 87 | return -1; 88 | } 89 | 90 | void * SCI_METHOD LexerBase::PrivateCall(int, void *) { 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/LexerBase.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file LexerBase.h 3 | ** A simple lexer with no state. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef LEXERBASE_H 9 | #define LEXERBASE_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | // A simple lexer with no state 16 | class LexerBase : public ILexer { 17 | protected: 18 | PropSetSimple props; 19 | enum {numWordLists=KEYWORDSET_MAX+1}; 20 | WordList *keyWordLists[numWordLists+1]; 21 | public: 22 | LexerBase(); 23 | virtual ~LexerBase(); 24 | void SCI_METHOD Release(); 25 | int SCI_METHOD Version() const; 26 | const char * SCI_METHOD PropertyNames(); 27 | int SCI_METHOD PropertyType(const char *name); 28 | const char * SCI_METHOD DescribeProperty(const char *name); 29 | int SCI_METHOD PropertySet(const char *key, const char *val); 30 | const char * SCI_METHOD DescribeWordListSets(); 31 | int SCI_METHOD WordListSet(int n, const char *wl); 32 | void SCI_METHOD Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess) = 0; 33 | void SCI_METHOD Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess) = 0; 34 | void * SCI_METHOD PrivateCall(int operation, void *pointer); 35 | }; 36 | 37 | #ifdef SCI_NAMESPACE 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/LexerModule.cxx: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file LexerModule.cxx 3 | ** Colourise for particular languages. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "ILexer.h" 18 | #include "Scintilla.h" 19 | #include "SciLexer.h" 20 | 21 | #include "PropSetSimple.h" 22 | #include "WordList.h" 23 | #include "LexAccessor.h" 24 | #include "Accessor.h" 25 | #include "LexerModule.h" 26 | #include "LexerBase.h" 27 | #include "LexerSimple.h" 28 | 29 | #ifdef SCI_NAMESPACE 30 | using namespace Scintilla; 31 | #endif 32 | 33 | LexerModule::LexerModule(int language_, 34 | LexerFunction fnLexer_, 35 | const char *languageName_, 36 | LexerFunction fnFolder_, 37 | const char *const wordListDescriptions_[]) : 38 | language(language_), 39 | fnLexer(fnLexer_), 40 | fnFolder(fnFolder_), 41 | fnFactory(0), 42 | wordListDescriptions(wordListDescriptions_), 43 | languageName(languageName_) { 44 | } 45 | 46 | LexerModule::LexerModule(int language_, 47 | LexerFactoryFunction fnFactory_, 48 | const char *languageName_, 49 | const char * const wordListDescriptions_[]) : 50 | language(language_), 51 | fnLexer(0), 52 | fnFolder(0), 53 | fnFactory(fnFactory_), 54 | wordListDescriptions(wordListDescriptions_), 55 | languageName(languageName_) { 56 | } 57 | 58 | int LexerModule::GetNumWordLists() const { 59 | if (wordListDescriptions == NULL) { 60 | return -1; 61 | } else { 62 | int numWordLists = 0; 63 | 64 | while (wordListDescriptions[numWordLists]) { 65 | ++numWordLists; 66 | } 67 | 68 | return numWordLists; 69 | } 70 | } 71 | 72 | const char *LexerModule::GetWordListDescription(int index) const { 73 | assert(index < GetNumWordLists()); 74 | if (!wordListDescriptions || (index >= GetNumWordLists())) { 75 | return ""; 76 | } else { 77 | return wordListDescriptions[index]; 78 | } 79 | } 80 | 81 | ILexer *LexerModule::Create() const { 82 | if (fnFactory) 83 | return fnFactory(); 84 | else 85 | return new LexerSimple(this); 86 | } 87 | 88 | void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle, 89 | WordList *keywordlists[], Accessor &styler) const { 90 | if (fnLexer) 91 | fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler); 92 | } 93 | 94 | void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle, 95 | WordList *keywordlists[], Accessor &styler) const { 96 | if (fnFolder) { 97 | int lineCurrent = styler.GetLine(startPos); 98 | // Move back one line in case deletion wrecked current line fold state 99 | if (lineCurrent > 0) { 100 | lineCurrent--; 101 | int newStartPos = styler.LineStart(lineCurrent); 102 | lengthDoc += startPos - newStartPos; 103 | startPos = newStartPos; 104 | initStyle = 0; 105 | if (startPos > 0) { 106 | initStyle = styler.StyleAt(startPos - 1); 107 | } 108 | } 109 | fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/LexerModule.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file LexerModule.h 3 | ** Colourise for particular languages. 4 | **/ 5 | // Copyright 1998-2001 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef LEXERMODULE_H 9 | #define LEXERMODULE_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | class Accessor; 16 | class WordList; 17 | 18 | typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle, 19 | WordList *keywordlists[], Accessor &styler); 20 | typedef ILexer *(*LexerFactoryFunction)(); 21 | 22 | /** 23 | * A LexerModule is responsible for lexing and folding a particular language. 24 | * The class maintains a list of LexerModules which can be searched to find a 25 | * module appropriate to a particular language. 26 | */ 27 | class LexerModule { 28 | protected: 29 | int language; 30 | LexerFunction fnLexer; 31 | LexerFunction fnFolder; 32 | LexerFactoryFunction fnFactory; 33 | const char * const * wordListDescriptions; 34 | 35 | public: 36 | const char *languageName; 37 | LexerModule(int language_, 38 | LexerFunction fnLexer_, 39 | const char *languageName_=0, 40 | LexerFunction fnFolder_=0, 41 | const char * const wordListDescriptions_[] = NULL); 42 | LexerModule(int language_, 43 | LexerFactoryFunction fnFactory_, 44 | const char *languageName_, 45 | const char * const wordListDescriptions_[] = NULL); 46 | virtual ~LexerModule() { 47 | } 48 | int GetLanguage() const { return language; } 49 | 50 | // -1 is returned if no WordList information is available 51 | int GetNumWordLists() const; 52 | const char *GetWordListDescription(int index) const; 53 | 54 | ILexer *Create() const; 55 | 56 | virtual void Lex(unsigned int startPos, int length, int initStyle, 57 | WordList *keywordlists[], Accessor &styler) const; 58 | virtual void Fold(unsigned int startPos, int length, int initStyle, 59 | WordList *keywordlists[], Accessor &styler) const; 60 | 61 | friend class Catalogue; 62 | }; 63 | 64 | inline int Maximum(int a, int b) { 65 | return (a > b) ? a : b; 66 | } 67 | 68 | // Shut up annoying Visual C++ warnings: 69 | #ifdef _MSC_VER 70 | #pragma warning(disable: 4244 4309 4456 4457) 71 | #endif 72 | 73 | // Turn off shadow warnings for lexers as may be maintained by others 74 | #if defined(__GNUC__) 75 | #pragma GCC diagnostic ignored "-Wshadow" 76 | #endif 77 | 78 | #ifdef SCI_NAMESPACE 79 | } 80 | #endif 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/LexerNoExceptions.cxx: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file LexerNoExceptions.cxx 3 | ** A simple lexer with no state which does not throw exceptions so can be used in an external lexer. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "ILexer.h" 16 | #include "Scintilla.h" 17 | #include "SciLexer.h" 18 | 19 | #include "PropSetSimple.h" 20 | #include "WordList.h" 21 | #include "LexAccessor.h" 22 | #include "Accessor.h" 23 | #include "LexerModule.h" 24 | #include "LexerBase.h" 25 | #include "LexerNoExceptions.h" 26 | 27 | #ifdef SCI_NAMESPACE 28 | using namespace Scintilla; 29 | #endif 30 | 31 | int SCI_METHOD LexerNoExceptions::PropertySet(const char *key, const char *val) { 32 | try { 33 | return LexerBase::PropertySet(key, val); 34 | } catch (...) { 35 | // Should not throw into caller as may be compiled with different compiler or options 36 | } 37 | return -1; 38 | } 39 | 40 | int SCI_METHOD LexerNoExceptions::WordListSet(int n, const char *wl) { 41 | try { 42 | return LexerBase::WordListSet(n, wl); 43 | } catch (...) { 44 | // Should not throw into caller as may be compiled with different compiler or options 45 | } 46 | return -1; 47 | } 48 | 49 | void SCI_METHOD LexerNoExceptions::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { 50 | try { 51 | Accessor astyler(pAccess, &props); 52 | Lexer(startPos, length, initStyle, pAccess, astyler); 53 | astyler.Flush(); 54 | } catch (...) { 55 | // Should not throw into caller as may be compiled with different compiler or options 56 | pAccess->SetErrorStatus(SC_STATUS_FAILURE); 57 | } 58 | } 59 | void SCI_METHOD LexerNoExceptions::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { 60 | try { 61 | Accessor astyler(pAccess, &props); 62 | Folder(startPos, length, initStyle, pAccess, astyler); 63 | astyler.Flush(); 64 | } catch (...) { 65 | // Should not throw into caller as may be compiled with different compiler or options 66 | pAccess->SetErrorStatus(SC_STATUS_FAILURE); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/LexerNoExceptions.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file LexerNoExceptions.h 3 | ** A simple lexer with no state. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef LEXERNOEXCEPTIONS_H 9 | #define LEXERNOEXCEPTIONS_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | // A simple lexer with no state 16 | class LexerNoExceptions : public LexerBase { 17 | public: 18 | // TODO Also need to prevent exceptions in constructor and destructor 19 | int SCI_METHOD PropertySet(const char *key, const char *val); 20 | int SCI_METHOD WordListSet(int n, const char *wl); 21 | void SCI_METHOD Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess); 22 | void SCI_METHOD Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *); 23 | 24 | virtual void Lexer(unsigned int startPos, int length, int initStyle, IDocument *pAccess, Accessor &styler) = 0; 25 | virtual void Folder(unsigned int startPos, int length, int initStyle, IDocument *pAccess, Accessor &styler) = 0; 26 | }; 27 | 28 | #ifdef SCI_NAMESPACE 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/LexerSimple.cxx: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file LexerSimple.cxx 3 | ** A simple lexer with no state. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "ILexer.h" 18 | #include "Scintilla.h" 19 | #include "SciLexer.h" 20 | 21 | #include "PropSetSimple.h" 22 | #include "WordList.h" 23 | #include "LexAccessor.h" 24 | #include "Accessor.h" 25 | #include "LexerModule.h" 26 | #include "LexerBase.h" 27 | #include "LexerSimple.h" 28 | 29 | #ifdef SCI_NAMESPACE 30 | using namespace Scintilla; 31 | #endif 32 | 33 | LexerSimple::LexerSimple(const LexerModule *module_) : module(module_) { 34 | for (int wl = 0; wl < module->GetNumWordLists(); wl++) { 35 | if (!wordLists.empty()) 36 | wordLists += "\n"; 37 | wordLists += module->GetWordListDescription(wl); 38 | } 39 | } 40 | 41 | const char * SCI_METHOD LexerSimple::DescribeWordListSets() { 42 | return wordLists.c_str(); 43 | } 44 | 45 | void SCI_METHOD LexerSimple::Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess) { 46 | Accessor astyler(pAccess, &props); 47 | module->Lex(startPos, lengthDoc, initStyle, keyWordLists, astyler); 48 | astyler.Flush(); 49 | } 50 | 51 | void SCI_METHOD LexerSimple::Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess) { 52 | if (props.GetInt("fold")) { 53 | Accessor astyler(pAccess, &props); 54 | module->Fold(startPos, lengthDoc, initStyle, keyWordLists, astyler); 55 | astyler.Flush(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/LexerSimple.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file LexerSimple.h 3 | ** A simple lexer with no state. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef LEXERSIMPLE_H 9 | #define LEXERSIMPLE_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | // A simple lexer with no state 16 | class LexerSimple : public LexerBase { 17 | const LexerModule *module; 18 | std::string wordLists; 19 | public: 20 | explicit LexerSimple(const LexerModule *module_); 21 | const char * SCI_METHOD DescribeWordListSets(); 22 | void SCI_METHOD Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess); 23 | void SCI_METHOD Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess); 24 | }; 25 | 26 | #ifdef SCI_NAMESPACE 27 | } 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/PropSetSimple.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file PropSetSimple.h 3 | ** A basic string to string map. 4 | **/ 5 | // Copyright 1998-2009 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef PROPSETSIMPLE_H 9 | #define PROPSETSIMPLE_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | class PropSetSimple { 16 | void *impl; 17 | void Set(const char *keyVal); 18 | public: 19 | PropSetSimple(); 20 | virtual ~PropSetSimple(); 21 | void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1); 22 | void SetMultiple(const char *); 23 | const char *Get(const char *key) const; 24 | int GetExpanded(const char *key, char *result) const; 25 | int GetInt(const char *key, int defaultValue=0) const; 26 | }; 27 | 28 | #ifdef SCI_NAMESPACE 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/SparseState.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file SparseState.h 3 | ** Hold lexer state that may change rarely. 4 | ** This is often per-line state such as whether a particular type of section has been entered. 5 | ** A state continues until it is changed. 6 | **/ 7 | // Copyright 2011 by Neil Hodgson 8 | // The License.txt file describes the conditions under which this software may be distributed. 9 | 10 | #ifndef SPARSESTATE_H 11 | #define SPARSESTATE_H 12 | 13 | #ifdef SCI_NAMESPACE 14 | namespace Scintilla { 15 | #endif 16 | 17 | template 18 | class SparseState { 19 | struct State { 20 | int position; 21 | T value; 22 | State(int position_, T value_) : position(position_), value(value_) { 23 | } 24 | inline bool operator<(const State &other) const { 25 | return position < other.position; 26 | } 27 | inline bool operator==(const State &other) const { 28 | return (position == other.position) && (value == other.value); 29 | } 30 | }; 31 | int positionFirst; 32 | typedef std::vector stateVector; 33 | stateVector states; 34 | 35 | typename stateVector::iterator Find(int position) { 36 | State searchValue(position, T()); 37 | return std::lower_bound(states.begin(), states.end(), searchValue); 38 | } 39 | 40 | public: 41 | explicit SparseState(int positionFirst_=-1) { 42 | positionFirst = positionFirst_; 43 | } 44 | void Set(int position, T value) { 45 | Delete(position); 46 | if (states.empty() || (value != states[states.size()-1].value)) { 47 | states.push_back(State(position, value)); 48 | } 49 | } 50 | T ValueAt(int position) { 51 | if (states.empty()) 52 | return T(); 53 | if (position < states[0].position) 54 | return T(); 55 | typename stateVector::iterator low = Find(position); 56 | if (low == states.end()) { 57 | return states[states.size()-1].value; 58 | } else { 59 | if (low->position > position) { 60 | --low; 61 | } 62 | return low->value; 63 | } 64 | } 65 | bool Delete(int position) { 66 | typename stateVector::iterator low = Find(position); 67 | if (low != states.end()) { 68 | states.erase(low, states.end()); 69 | return true; 70 | } 71 | return false; 72 | } 73 | size_t size() const { 74 | return states.size(); 75 | } 76 | 77 | // Returns true if Merge caused a significant change 78 | bool Merge(const SparseState &other, int ignoreAfter) { 79 | // Changes caused beyond ignoreAfter are not significant 80 | Delete(ignoreAfter+1); 81 | 82 | bool different = true; 83 | bool changed = false; 84 | typename stateVector::iterator low = Find(other.positionFirst); 85 | if (static_cast(states.end() - low) == other.states.size()) { 86 | // Same number in other as after positionFirst in this 87 | different = !std::equal(low, states.end(), other.states.begin()); 88 | } 89 | if (different) { 90 | if (low != states.end()) { 91 | states.erase(low, states.end()); 92 | changed = true; 93 | } 94 | typename stateVector::const_iterator startOther = other.states.begin(); 95 | if (!states.empty() && !other.states.empty() && states.back().value == startOther->value) 96 | ++startOther; 97 | if (startOther != other.states.end()) { 98 | states.insert(states.end(), startOther, other.states.end()); 99 | changed = true; 100 | } 101 | } 102 | return changed; 103 | } 104 | }; 105 | 106 | #ifdef SCI_NAMESPACE 107 | } 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/StringCopy.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file StringCopy.h 3 | ** Safe string copy function which always NUL terminates. 4 | ** ELEMENTS macro for determining array sizes. 5 | **/ 6 | // Copyright 2013 by Neil Hodgson 7 | // The License.txt file describes the conditions under which this software may be distributed. 8 | 9 | #ifndef STRINGCOPY_H 10 | #define STRINGCOPY_H 11 | 12 | #ifdef SCI_NAMESPACE 13 | namespace Scintilla { 14 | #endif 15 | 16 | // Safer version of string copy functions like strcpy, wcsncpy, etc. 17 | // Instantiate over fixed length strings of both char and wchar_t. 18 | // May truncate if source doesn't fit into dest with room for NUL. 19 | 20 | template 21 | void StringCopy(T (&dest)[count], const T* source) { 22 | for (size_t i=0; i 6 | // This file is in the public domain. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "ILexer.h" 15 | 16 | #include "LexAccessor.h" 17 | #include "Accessor.h" 18 | #include "StyleContext.h" 19 | 20 | #ifdef SCI_NAMESPACE 21 | using namespace Scintilla; 22 | #endif 23 | 24 | static void getRange(unsigned int start, 25 | unsigned int end, 26 | LexAccessor &styler, 27 | char *s, 28 | unsigned int len) { 29 | unsigned int i = 0; 30 | while ((i < end - start + 1) && (i < len-1)) { 31 | s[i] = styler[start + i]; 32 | i++; 33 | } 34 | s[i] = '\0'; 35 | } 36 | 37 | void StyleContext::GetCurrent(char *s, unsigned int len) { 38 | getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len); 39 | } 40 | 41 | static void getRangeLowered(unsigned int start, 42 | unsigned int end, 43 | LexAccessor &styler, 44 | char *s, 45 | unsigned int len) { 46 | unsigned int i = 0; 47 | while ((i < end - start + 1) && (i < len-1)) { 48 | s[i] = static_cast(tolower(styler[start + i])); 49 | i++; 50 | } 51 | s[i] = '\0'; 52 | } 53 | 54 | void StyleContext::GetCurrentLowered(char *s, unsigned int len) { 55 | getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len); 56 | } 57 | -------------------------------------------------------------------------------- /vendor/scintilla/lexlib/WordList.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file WordList.h 3 | ** Hold a list of words. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef WORDLIST_H 9 | #define WORDLIST_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | /** 16 | */ 17 | class WordList { 18 | // Each word contains at least one character - a empty word acts as sentinel at the end. 19 | char **words; 20 | char *list; 21 | int len; 22 | bool onlyLineEnds; ///< Delimited by any white space or only line ends 23 | int starts[256]; 24 | public: 25 | explicit WordList(bool onlyLineEnds_ = false); 26 | ~WordList(); 27 | operator bool() const; 28 | bool operator!=(const WordList &other) const; 29 | int Length() const; 30 | void Clear(); 31 | void Set(const char *s); 32 | bool InList(const char *s) const; 33 | bool InListAbbreviated(const char *s, const char marker) const; 34 | const char *WordAt(int n) const; 35 | }; 36 | 37 | #ifdef SCI_NAMESPACE 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /vendor/scintilla/qt/ScintillaEdit/ScintillaDocument.h: -------------------------------------------------------------------------------- 1 | // ScintillaDocument.h 2 | // Wrapper for Scintilla document object so it can be manipulated independently. 3 | // Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware 4 | 5 | #ifndef SCINTILLADOCUMENT_H 6 | #define SCINTILLADOCUMENT_H 7 | 8 | #include 9 | 10 | class WatcherHelper; 11 | 12 | #ifdef SCI_NAMESPACE 13 | namespace Scintilla { 14 | #endif 15 | 16 | #ifndef EXPORT_IMPORT_API 17 | #ifdef WIN32 18 | #ifdef MAKING_LIBRARY 19 | #define EXPORT_IMPORT_API __declspec(dllexport) 20 | #else 21 | // Defining dllimport upsets moc 22 | #define EXPORT_IMPORT_API __declspec(dllimport) 23 | //#define EXPORT_IMPORT_API 24 | #endif 25 | #else 26 | #define EXPORT_IMPORT_API 27 | #endif 28 | #endif 29 | 30 | class EXPORT_IMPORT_API ScintillaDocument : public QObject 31 | { 32 | Q_OBJECT 33 | 34 | void *pdoc; 35 | WatcherHelper *docWatcher; 36 | 37 | public: 38 | explicit ScintillaDocument(QObject *parent = 0, void *pdoc_=0); 39 | virtual ~ScintillaDocument(); 40 | void *pointer(); 41 | 42 | int line_from_position(int pos); 43 | bool is_cr_lf(int pos); 44 | bool delete_chars(int pos, int len); 45 | int undo(); 46 | int redo(); 47 | bool can_undo(); 48 | bool can_redo(); 49 | void delete_undo_history(); 50 | bool set_undo_collection(bool collect_undo); 51 | bool is_collecting_undo(); 52 | void begin_undo_action(); 53 | void end_undo_action(); 54 | void set_save_point(); 55 | bool is_save_point(); 56 | void set_read_only(bool read_only); 57 | bool is_read_only(); 58 | void insert_string(int position, QByteArray &str); 59 | QByteArray get_char_range(int position, int length); 60 | char style_at(int position); 61 | int line_start(int lineno); 62 | int line_end(int lineno); 63 | int line_end_position(int pos); 64 | int length(); 65 | int lines_total(); 66 | void start_styling(int position, char flags); 67 | bool set_style_for(int length, char style); 68 | int get_end_styled(); 69 | void ensure_styled_to(int position); 70 | void set_current_indicator(int indic); 71 | void decoration_fill_range(int position, int value, int fillLength); 72 | int decorations_value_at(int indic, int position); 73 | int decorations_start(int indic, int position); 74 | int decorations_end(int indic, int position); 75 | int get_code_page(); 76 | void set_code_page(int code_page); 77 | int get_eol_mode(); 78 | void set_eol_mode(int eol_mode); 79 | int move_position_outside_char(int pos, int move_dir, bool check_line_end); 80 | 81 | int get_character(int pos); // Calls GetCharacterAndWidth(pos, NULL) 82 | 83 | private: 84 | void emit_modify_attempt(); 85 | void emit_save_point(bool atSavePoint); 86 | void emit_modified(int position, int modification_type, const QByteArray& text, int length, 87 | int linesAdded, int line, int foldLevelNow, int foldLevelPrev); 88 | void emit_style_needed(int pos); 89 | void emit_lexer_changed(); 90 | void emit_error_occurred(int status); 91 | 92 | signals: 93 | void modify_attempt(); 94 | void save_point(bool atSavePoint); 95 | void modified(int position, int modification_type, const QByteArray& text, int length, 96 | int linesAdded, int line, int foldLevelNow, int foldLevelPrev); 97 | void style_needed(int pos); 98 | void lexer_changed(); 99 | void error_occurred(int status); 100 | 101 | friend class ::WatcherHelper; 102 | 103 | }; 104 | 105 | #ifdef SCI_NAMESPACE 106 | } 107 | #endif 108 | 109 | #endif // SCINTILLADOCUMENT_H 110 | -------------------------------------------------------------------------------- /vendor/scintilla/qt/ScintillaEditPy/global.h: -------------------------------------------------------------------------------- 1 | #include "pyside_global.h" 2 | 3 | #include "ScintillaEditBase.h" 4 | #include "ScintillaEdit.h" 5 | -------------------------------------------------------------------------------- /vendor/scintilla/src/AutoComplete.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file AutoComplete.h 3 | ** Defines the auto completion list box. 4 | **/ 5 | // Copyright 1998-2003 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef AUTOCOMPLETE_H 9 | #define AUTOCOMPLETE_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | /** 16 | */ 17 | class AutoComplete { 18 | bool active; 19 | std::string stopChars; 20 | std::string fillUpChars; 21 | char separator; 22 | char typesep; // Type seperator 23 | enum { maxItemLen=1000 }; 24 | std::vector sortMatrix; 25 | 26 | public: 27 | 28 | bool ignoreCase; 29 | bool chooseSingle; 30 | ListBox *lb; 31 | int posStart; 32 | int startLen; 33 | /// Should autocompletion be canceled if editor's currentPos <= startPos? 34 | bool cancelAtStartPos; 35 | bool autoHide; 36 | bool dropRestOfWord; 37 | unsigned int ignoreCaseBehaviour; 38 | int widthLBDefault; 39 | int heightLBDefault; 40 | /** SC_ORDER_PRESORTED: Assume the list is presorted; selection will fail if it is not alphabetical
41 | * SC_ORDER_PERFORMSORT: Sort the list alphabetically; start up performance cost for sorting
42 | * SC_ORDER_CUSTOM: Handle non-alphabetical entries; start up performance cost for generating a sorted lookup table 43 | */ 44 | int autoSort; 45 | 46 | AutoComplete(); 47 | ~AutoComplete(); 48 | 49 | /// Is the auto completion list displayed? 50 | bool Active() const; 51 | 52 | /// Display the auto completion list positioned to be near a character position 53 | void Start(Window &parent, int ctrlID, int position, Point location, 54 | int startLen_, int lineHeight, bool unicodeMode, int technology); 55 | 56 | /// The stop chars are characters which, when typed, cause the auto completion list to disappear 57 | void SetStopChars(const char *stopChars_); 58 | bool IsStopChar(char ch); 59 | 60 | /// The fillup chars are characters which, when typed, fill up the selected word 61 | void SetFillUpChars(const char *fillUpChars_); 62 | bool IsFillUpChar(char ch); 63 | 64 | /// The separator character is used when interpreting the list in SetList 65 | void SetSeparator(char separator_); 66 | char GetSeparator() const; 67 | 68 | /// The typesep character is used for separating the word from the type 69 | void SetTypesep(char separator_); 70 | char GetTypesep() const; 71 | 72 | /// The list string contains a sequence of words separated by the separator character 73 | void SetList(const char *list); 74 | 75 | /// Return the position of the currently selected list item 76 | int GetSelection() const; 77 | 78 | /// Return the value of an item in the list 79 | std::string GetValue(int item) const; 80 | 81 | void Show(bool show); 82 | void Cancel(); 83 | 84 | /// Move the current list element by delta, scrolling appropriately 85 | void Move(int delta); 86 | 87 | /// Select a list element that starts with word as the current element 88 | void Select(const char *word); 89 | }; 90 | 91 | #ifdef SCI_NAMESPACE 92 | } 93 | #endif 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /vendor/scintilla/src/CallTip.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file CallTip.h 3 | ** Interface to the call tip control. 4 | **/ 5 | // Copyright 1998-2001 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef CALLTIP_H 9 | #define CALLTIP_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | /** 16 | */ 17 | class CallTip { 18 | int startHighlight; // character offset to start and... 19 | int endHighlight; // ...end of highlighted text 20 | std::string val; 21 | Font font; 22 | PRectangle rectUp; // rectangle of last up angle in the tip 23 | PRectangle rectDown; // rectangle of last down arrow in the tip 24 | int lineHeight; // vertical line spacing 25 | int offsetMain; // The alignment point of the call tip 26 | int tabSize; // Tab size in pixels, <=0 no TAB expand 27 | bool useStyleCallTip; // if true, STYLE_CALLTIP should be used 28 | bool above; // if true, display calltip above text 29 | 30 | // Private so CallTip objects can not be copied 31 | CallTip(const CallTip &); 32 | CallTip &operator=(const CallTip &); 33 | void DrawChunk(Surface *surface, int &x, const char *s, 34 | int posStart, int posEnd, int ytext, PRectangle rcClient, 35 | bool highlight, bool draw); 36 | int PaintContents(Surface *surfaceWindow, bool draw); 37 | bool IsTabCharacter(char c) const; 38 | int NextTabPos(int x) const; 39 | 40 | public: 41 | Window wCallTip; 42 | Window wDraw; 43 | bool inCallTipMode; 44 | int posStartCallTip; 45 | ColourDesired colourBG; 46 | ColourDesired colourUnSel; 47 | ColourDesired colourSel; 48 | ColourDesired colourShade; 49 | ColourDesired colourLight; 50 | int codePage; 51 | int clickPlace; 52 | 53 | int insetX; // text inset in x from calltip border 54 | int widthArrow; 55 | int borderHeight; 56 | int verticalOffset; // pixel offset up or down of the calltip with respect to the line 57 | 58 | CallTip(); 59 | ~CallTip(); 60 | 61 | void PaintCT(Surface *surfaceWindow); 62 | 63 | void MouseClick(Point pt); 64 | 65 | /// Setup the calltip and return a rectangle of the area required. 66 | PRectangle CallTipStart(int pos, Point pt, int textHeight, const char *defn, 67 | const char *faceName, int size, int codePage_, 68 | int characterSet, int technology, Window &wParent); 69 | 70 | void CallTipCancel(); 71 | 72 | /// Set a range of characters to be displayed in a highlight style. 73 | /// Commonly used to highlight the current parameter. 74 | void SetHighlight(int start, int end); 75 | 76 | /// Set the tab size in pixels for the call tip. 0 or -ve means no tab expand. 77 | void SetTabSize(int tabSz); 78 | 79 | /// Set calltip position. 80 | void SetPosition(bool aboveText); 81 | 82 | /// Used to determine which STYLE_xxxx to use for call tip information 83 | bool UseStyleCallTip() const { return useStyleCallTip;} 84 | 85 | // Modify foreground and background colours 86 | void SetForeBack(const ColourDesired &fore, const ColourDesired &back); 87 | }; 88 | 89 | #ifdef SCI_NAMESPACE 90 | } 91 | #endif 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /vendor/scintilla/src/CaseConvert.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | // Encoding: UTF-8 3 | /** @file CaseConvert.h 4 | ** Performs Unicode case conversions. 5 | ** Does not handle locale-sensitive case conversion. 6 | **/ 7 | // Copyright 2013 by Neil Hodgson 8 | // The License.txt file describes the conditions under which this software may be distributed. 9 | 10 | #ifndef CASECONVERT_H 11 | #define CASECONVERT_H 12 | 13 | #ifdef SCI_NAMESPACE 14 | namespace Scintilla { 15 | #endif 16 | 17 | enum CaseConversion { 18 | CaseConversionFold, 19 | CaseConversionUpper, 20 | CaseConversionLower 21 | }; 22 | 23 | class ICaseConverter { 24 | public: 25 | virtual size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) = 0; 26 | }; 27 | 28 | ICaseConverter *ConverterFor(enum CaseConversion conversion); 29 | 30 | // Returns a UTF-8 string. Empty when no conversion 31 | const char *CaseConvert(int character, enum CaseConversion conversion); 32 | 33 | // When performing CaseConvertString, the converted value may be up to 3 times longer than the input. 34 | // Ligatures are often decomposed into multiple characters and long cases include: 35 | // ΐ "\xce\x90" folds to ΐ "\xce\xb9\xcc\x88\xcc\x81" 36 | const int maxExpansionCaseConversion=3; 37 | 38 | // Converts a mixed case string using a particular conversion. 39 | // Result may be a different length to input and the length is the return value. 40 | // If there is not enough space then 0 is returned. 41 | size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed, enum CaseConversion conversion); 42 | 43 | #ifdef SCI_NAMESPACE 44 | } 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /vendor/scintilla/src/CaseFolder.cxx: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file CaseFolder.cxx 3 | ** Classes for case folding. 4 | **/ 5 | // Copyright 1998-2013 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #include 9 | #include 10 | 11 | #include "CaseFolder.h" 12 | #include "CaseConvert.h" 13 | #include "UniConversion.h" 14 | 15 | #ifdef SCI_NAMESPACE 16 | using namespace Scintilla; 17 | #endif 18 | 19 | CaseFolder::~CaseFolder() { 20 | } 21 | 22 | CaseFolderTable::CaseFolderTable() { 23 | for (size_t iChar=0; iChar(iChar); 25 | } 26 | } 27 | 28 | CaseFolderTable::~CaseFolderTable() { 29 | } 30 | 31 | size_t CaseFolderTable::Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) { 32 | if (lenMixed > sizeFolded) { 33 | return 0; 34 | } else { 35 | for (size_t i=0; i(mixed[i])]; 37 | } 38 | return lenMixed; 39 | } 40 | } 41 | 42 | void CaseFolderTable::SetTranslation(char ch, char chTranslation) { 43 | mapping[static_cast(ch)] = chTranslation; 44 | } 45 | 46 | void CaseFolderTable::StandardASCII() { 47 | for (size_t iChar=0; iChar= 'A' && iChar <= 'Z') { 49 | mapping[iChar] = static_cast(iChar - 'A' + 'a'); 50 | } else { 51 | mapping[iChar] = static_cast(iChar); 52 | } 53 | } 54 | } 55 | 56 | CaseFolderUnicode::CaseFolderUnicode() { 57 | StandardASCII(); 58 | converter = ConverterFor(CaseConversionFold); 59 | } 60 | 61 | size_t CaseFolderUnicode::Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) { 62 | if ((lenMixed == 1) && (sizeFolded > 0)) { 63 | folded[0] = mapping[static_cast(mixed[0])]; 64 | return 1; 65 | } else { 66 | return converter->CaseConvertString(folded, sizeFolded, mixed, lenMixed); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /vendor/scintilla/src/CaseFolder.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file CaseFolder.h 3 | ** Classes for case folding. 4 | **/ 5 | // Copyright 1998-2013 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef CASEFOLDER_H 9 | #define CASEFOLDER_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | class CaseFolder { 16 | public: 17 | virtual ~CaseFolder(); 18 | virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) = 0; 19 | }; 20 | 21 | class CaseFolderTable : public CaseFolder { 22 | protected: 23 | char mapping[256]; 24 | public: 25 | CaseFolderTable(); 26 | virtual ~CaseFolderTable(); 27 | virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed); 28 | void SetTranslation(char ch, char chTranslation); 29 | void StandardASCII(); 30 | }; 31 | 32 | class ICaseConverter; 33 | 34 | class CaseFolderUnicode : public CaseFolderTable { 35 | ICaseConverter *converter; 36 | public: 37 | CaseFolderUnicode(); 38 | virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed); 39 | }; 40 | 41 | #ifdef SCI_NAMESPACE 42 | } 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /vendor/scintilla/src/Catalogue.cxx: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file Catalogue.cxx 3 | ** Colourise for particular languages. 4 | **/ 5 | // Copyright 1998-2002 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "ILexer.h" 18 | #include "Scintilla.h" 19 | #include "SciLexer.h" 20 | 21 | #include "LexerModule.h" 22 | #include "Catalogue.h" 23 | 24 | #ifdef SCI_NAMESPACE 25 | using namespace Scintilla; 26 | #endif 27 | 28 | static std::vector lexerCatalogue; 29 | static int nextLanguage = SCLEX_AUTOMATIC+1; 30 | 31 | const LexerModule *Catalogue::Find(int language) { 32 | Scintilla_LinkLexers(); 33 | for (std::vector::iterator it=lexerCatalogue.begin(); 34 | it != lexerCatalogue.end(); ++it) { 35 | if ((*it)->GetLanguage() == language) { 36 | return *it; 37 | } 38 | } 39 | return 0; 40 | } 41 | 42 | const LexerModule *Catalogue::Find(const char *languageName) { 43 | Scintilla_LinkLexers(); 44 | if (languageName) { 45 | for (std::vector::iterator it=lexerCatalogue.begin(); 46 | it != lexerCatalogue.end(); ++it) { 47 | if ((*it)->languageName && (0 == strcmp((*it)->languageName, languageName))) { 48 | return *it; 49 | } 50 | } 51 | } 52 | return 0; 53 | } 54 | 55 | void Catalogue::AddLexerModule(LexerModule *plm) { 56 | if (plm->GetLanguage() == SCLEX_AUTOMATIC) { 57 | plm->language = nextLanguage; 58 | nextLanguage++; 59 | } 60 | lexerCatalogue.push_back(plm); 61 | } 62 | 63 | // To add or remove a lexer, add or remove its file and run LexGen.py. 64 | 65 | // Force a reference to all of the Scintilla lexers so that the linker will 66 | // not remove the code of the lexers. 67 | int Scintilla_LinkLexers() { 68 | 69 | static int initialised = 0; 70 | if (initialised) 71 | return 0; 72 | initialised = 1; 73 | 74 | // Shorten the code that declares a lexer and ensures it is linked in by calling a method. 75 | #define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer); 76 | 77 | //++Autogenerated -- run scripts/LexGen.py to regenerate 78 | //**\(\tLINK_LEXER(\*);\n\) 79 | LINK_LEXER(lmCPP); 80 | LINK_LEXER(lmCPPNoCase); 81 | 82 | //--Autogenerated -- end of automatically generated section 83 | 84 | return 1; 85 | } 86 | -------------------------------------------------------------------------------- /vendor/scintilla/src/Catalogue.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file Catalogue.h 3 | ** Lexer infrastructure. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef CATALOGUE_H 9 | #define CATALOGUE_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | class Catalogue { 16 | public: 17 | static const LexerModule *Find(int language); 18 | static const LexerModule *Find(const char *languageName); 19 | static void AddLexerModule(LexerModule *plm); 20 | }; 21 | 22 | #ifdef SCI_NAMESPACE 23 | } 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /vendor/scintilla/src/CharClassify.cxx: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file CharClassify.cxx 3 | ** Character classifications used by Document and RESearch. 4 | **/ 5 | // Copyright 2006 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #include 9 | #include 10 | 11 | #include "CharClassify.h" 12 | 13 | #ifdef SCI_NAMESPACE 14 | using namespace Scintilla; 15 | #endif 16 | 17 | CharClassify::CharClassify() { 18 | SetDefaultCharClasses(true); 19 | } 20 | 21 | void CharClassify::SetDefaultCharClasses(bool includeWordClass) { 22 | // Initialize all char classes to default values 23 | for (int ch = 0; ch < 256; ch++) { 24 | if (ch == '\r' || ch == '\n') 25 | charClass[ch] = ccNewLine; 26 | else if (ch < 0x20 || ch == ' ') 27 | charClass[ch] = ccSpace; 28 | else if (includeWordClass && (ch >= 0x80 || isalnum(ch) || ch == '_')) 29 | charClass[ch] = ccWord; 30 | else 31 | charClass[ch] = ccPunctuation; 32 | } 33 | } 34 | 35 | void CharClassify::SetCharClasses(const unsigned char *chars, cc newCharClass) { 36 | // Apply the newCharClass to the specifed chars 37 | if (chars) { 38 | while (*chars) { 39 | charClass[*chars] = static_cast(newCharClass); 40 | chars++; 41 | } 42 | } 43 | } 44 | 45 | int CharClassify::GetCharsOfClass(cc characterClass, unsigned char *buffer) { 46 | // Get characters belonging to the given char class; return the number 47 | // of characters (if the buffer is NULL, don't write to it). 48 | int count = 0; 49 | for (int ch = maxChar - 1; ch >= 0; --ch) { 50 | if (charClass[ch] == characterClass) { 51 | ++count; 52 | if (buffer) { 53 | *buffer = static_cast(ch); 54 | buffer++; 55 | } 56 | } 57 | } 58 | return count; 59 | } 60 | -------------------------------------------------------------------------------- /vendor/scintilla/src/CharClassify.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file CharClassify.h 3 | ** Character classifications used by Document and RESearch. 4 | **/ 5 | // Copyright 2006-2009 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef CHARCLASSIFY_H 9 | #define CHARCLASSIFY_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | class CharClassify { 16 | public: 17 | CharClassify(); 18 | 19 | enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation }; 20 | void SetDefaultCharClasses(bool includeWordClass); 21 | void SetCharClasses(const unsigned char *chars, cc newCharClass); 22 | int GetCharsOfClass(cc charClass, unsigned char *buffer); 23 | cc GetClass(unsigned char ch) const { return static_cast(charClass[ch]);} 24 | bool IsWord(unsigned char ch) const { return static_cast(charClass[ch]) == ccWord;} 25 | 26 | private: 27 | enum { maxChar=256 }; 28 | unsigned char charClass[maxChar]; // not type cc to save space 29 | }; 30 | 31 | #ifdef SCI_NAMESPACE 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /vendor/scintilla/src/ContractionState.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file ContractionState.h 3 | ** Manages visibility of lines for folding and wrapping. 4 | **/ 5 | // Copyright 1998-2007 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef CONTRACTIONSTATE_H 9 | #define CONTRACTIONSTATE_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | /** 16 | */ 17 | class ContractionState { 18 | // These contain 1 element for every document line. 19 | RunStyles *visible; 20 | RunStyles *expanded; 21 | RunStyles *heights; 22 | Partitioning *displayLines; 23 | int linesInDocument; 24 | 25 | void EnsureData(); 26 | 27 | bool OneToOne() const { 28 | // True when each document line is exactly one display line so need for 29 | // complex data structures. 30 | return visible == 0; 31 | } 32 | 33 | public: 34 | ContractionState(); 35 | virtual ~ContractionState(); 36 | 37 | void Clear(); 38 | 39 | int LinesInDoc() const; 40 | int LinesDisplayed() const; 41 | int DisplayFromDoc(int lineDoc) const; 42 | int DisplayLastFromDoc(int lineDoc) const; 43 | int DocFromDisplay(int lineDisplay) const; 44 | 45 | void InsertLine(int lineDoc); 46 | void InsertLines(int lineDoc, int lineCount); 47 | void DeleteLine(int lineDoc); 48 | void DeleteLines(int lineDoc, int lineCount); 49 | 50 | bool GetVisible(int lineDoc) const; 51 | bool SetVisible(int lineDocStart, int lineDocEnd, bool isVisible); 52 | bool HiddenLines() const; 53 | 54 | bool GetExpanded(int lineDoc) const; 55 | bool SetExpanded(int lineDoc, bool isExpanded); 56 | int ContractedNext(int lineDocStart) const; 57 | 58 | int GetHeight(int lineDoc) const; 59 | bool SetHeight(int lineDoc, int height); 60 | 61 | void ShowAll(); 62 | void Check() const; 63 | }; 64 | 65 | #ifdef SCI_NAMESPACE 66 | } 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /vendor/scintilla/src/Decoration.h: -------------------------------------------------------------------------------- 1 | /** @file Decoration.h 2 | ** Visual elements added over text. 3 | **/ 4 | // Copyright 1998-2007 by Neil Hodgson 5 | // The License.txt file describes the conditions under which this software may be distributed. 6 | 7 | #ifndef DECORATION_H 8 | #define DECORATION_H 9 | 10 | #ifdef SCI_NAMESPACE 11 | namespace Scintilla { 12 | #endif 13 | 14 | class Decoration { 15 | public: 16 | Decoration *next; 17 | RunStyles rs; 18 | int indicator; 19 | 20 | explicit Decoration(int indicator_); 21 | ~Decoration(); 22 | 23 | bool Empty() const; 24 | }; 25 | 26 | class DecorationList { 27 | int currentIndicator; 28 | int currentValue; 29 | Decoration *current; 30 | int lengthDocument; 31 | Decoration *DecorationFromIndicator(int indicator); 32 | Decoration *Create(int indicator, int length); 33 | void Delete(int indicator); 34 | void DeleteAnyEmpty(); 35 | public: 36 | Decoration *root; 37 | bool clickNotified; 38 | 39 | DecorationList(); 40 | ~DecorationList(); 41 | 42 | void SetCurrentIndicator(int indicator); 43 | int GetCurrentIndicator() const { return currentIndicator; } 44 | 45 | void SetCurrentValue(int value); 46 | int GetCurrentValue() const { return currentValue; } 47 | 48 | // Returns true if some values may have changed 49 | bool FillRange(int &position, int value, int &fillLength); 50 | 51 | void InsertSpace(int position, int insertLength); 52 | void DeleteRange(int position, int deleteLength); 53 | 54 | int AllOnFor(int position) const; 55 | int ValueAt(int indicator, int position); 56 | int Start(int indicator, int position); 57 | int End(int indicator, int position); 58 | }; 59 | 60 | #ifdef SCI_NAMESPACE 61 | } 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /vendor/scintilla/src/EditModel.cxx: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file EditModel.cxx 3 | ** Defines the editor state that must be visible to EditorView. 4 | **/ 5 | // Copyright 1998-2014 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "Platform.h" 23 | 24 | #include "ILexer.h" 25 | #include "Scintilla.h" 26 | 27 | #include "StringCopy.h" 28 | #include "SplitVector.h" 29 | #include "Partitioning.h" 30 | #include "RunStyles.h" 31 | #include "ContractionState.h" 32 | #include "CellBuffer.h" 33 | #include "KeyMap.h" 34 | #include "Indicator.h" 35 | #include "XPM.h" 36 | #include "LineMarker.h" 37 | #include "Style.h" 38 | #include "ViewStyle.h" 39 | #include "CharClassify.h" 40 | #include "Decoration.h" 41 | #include "CaseFolder.h" 42 | #include "Document.h" 43 | #include "UniConversion.h" 44 | #include "Selection.h" 45 | #include "PositionCache.h" 46 | #include "EditModel.h" 47 | 48 | #ifdef SCI_NAMESPACE 49 | using namespace Scintilla; 50 | #endif 51 | 52 | Caret::Caret() : 53 | active(false), on(false), period(500) {} 54 | 55 | EditModel::EditModel() { 56 | inOverstrike = false; 57 | xOffset = 0; 58 | trackLineWidth = false; 59 | posDrag = SelectionPosition(invalidPosition); 60 | braces[0] = invalidPosition; 61 | braces[1] = invalidPosition; 62 | bracesMatchStyle = STYLE_BRACEBAD; 63 | highlightGuideColumn = 0; 64 | primarySelection = true; 65 | imeInteraction = imeWindowed; 66 | foldFlags = 0; 67 | hotspot = Range(invalidPosition); 68 | wrapWidth = LineLayout::wrapWidthInfinite; 69 | pdoc = new Document(); 70 | pdoc->AddRef(); 71 | } 72 | 73 | EditModel::~EditModel() { 74 | pdoc->Release(); 75 | pdoc = 0; 76 | } 77 | -------------------------------------------------------------------------------- /vendor/scintilla/src/EditModel.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file EditModel.h 3 | ** Defines the editor state that must be visible to EditorView. 4 | **/ 5 | // Copyright 1998-2014 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef EDITMODEL_H 9 | #define EDITMODEL_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | /** 16 | */ 17 | class Caret { 18 | public: 19 | bool active; 20 | bool on; 21 | int period; 22 | 23 | Caret(); 24 | }; 25 | 26 | class EditModel { 27 | // Private so EditModel objects can not be copied 28 | EditModel(const EditModel &); 29 | EditModel &operator=(const EditModel &); 30 | 31 | public: 32 | bool inOverstrike; 33 | int xOffset; ///< Horizontal scrolled amount in pixels 34 | bool trackLineWidth; 35 | 36 | SpecialRepresentations reprs; 37 | Caret caret; 38 | SelectionPosition posDrag; 39 | Position braces[2]; 40 | int bracesMatchStyle; 41 | int highlightGuideColumn; 42 | Selection sel; 43 | bool primarySelection; 44 | 45 | enum IMEInteraction { imeWindowed, imeInline } imeInteraction; 46 | 47 | int foldFlags; 48 | ContractionState cs; 49 | // Hotspot support 50 | Range hotspot; 51 | 52 | // Wrapping support 53 | int wrapWidth; 54 | 55 | Document *pdoc; 56 | 57 | EditModel(); 58 | virtual ~EditModel(); 59 | virtual int TopLineOfMain() const = 0; 60 | virtual Point GetVisibleOriginInMain() const = 0; 61 | virtual int LinesOnScreen() const = 0; 62 | virtual Range GetHotSpotRange() const = 0; 63 | }; 64 | 65 | #ifdef SCI_NAMESPACE 66 | } 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /vendor/scintilla/src/ExternalLexer.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file ExternalLexer.h 3 | ** Support external lexers in DLLs. 4 | **/ 5 | // Copyright 2001 Simon Steele , portions copyright Neil Hodgson. 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef EXTERNALLEXER_H 9 | #define EXTERNALLEXER_H 10 | 11 | #if PLAT_WIN 12 | #define EXT_LEXER_DECL __stdcall 13 | #else 14 | #define EXT_LEXER_DECL 15 | #endif 16 | 17 | #ifdef SCI_NAMESPACE 18 | namespace Scintilla { 19 | #endif 20 | 21 | typedef void*(EXT_LEXER_DECL *GetLexerFunction)(unsigned int Index); 22 | typedef int (EXT_LEXER_DECL *GetLexerCountFn)(); 23 | typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength); 24 | typedef LexerFactoryFunction(EXT_LEXER_DECL *GetLexerFactoryFunction)(unsigned int Index); 25 | 26 | /// Sub-class of LexerModule to use an external lexer. 27 | class ExternalLexerModule : public LexerModule { 28 | protected: 29 | GetLexerFactoryFunction fneFactory; 30 | std::string name; 31 | public: 32 | ExternalLexerModule(int language_, LexerFunction fnLexer_, 33 | const char *languageName_=0, LexerFunction fnFolder_=0) : 34 | LexerModule(language_, fnLexer_, 0, fnFolder_), 35 | fneFactory(0), name(languageName_){ 36 | languageName = name.c_str(); 37 | } 38 | virtual void SetExternal(GetLexerFactoryFunction fFactory, int index); 39 | }; 40 | 41 | /// LexerMinder points to an ExternalLexerModule - so we don't leak them. 42 | class LexerMinder { 43 | public: 44 | ExternalLexerModule *self; 45 | LexerMinder *next; 46 | }; 47 | 48 | /// LexerLibrary exists for every External Lexer DLL, contains LexerMinders. 49 | class LexerLibrary { 50 | DynamicLibrary *lib; 51 | LexerMinder *first; 52 | LexerMinder *last; 53 | 54 | public: 55 | explicit LexerLibrary(const char *ModuleName); 56 | ~LexerLibrary(); 57 | void Release(); 58 | 59 | LexerLibrary *next; 60 | std::string m_sModuleName; 61 | }; 62 | 63 | /// LexerManager manages external lexers, contains LexerLibrarys. 64 | class LexerManager { 65 | public: 66 | ~LexerManager(); 67 | 68 | static LexerManager *GetInstance(); 69 | static void DeleteInstance(); 70 | 71 | void Load(const char *path); 72 | void Clear(); 73 | 74 | private: 75 | LexerManager(); 76 | static LexerManager *theInstance; 77 | 78 | void LoadLexerLibrary(const char *module); 79 | LexerLibrary *first; 80 | LexerLibrary *last; 81 | }; 82 | 83 | class LMMinder { 84 | public: 85 | ~LMMinder(); 86 | }; 87 | 88 | #ifdef SCI_NAMESPACE 89 | } 90 | #endif 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /vendor/scintilla/src/FontQuality.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file FontQuality.h 3 | ** Definitions to control font anti-aliasing. 4 | ** Redefine constants from Scintilla.h to avoid including Scintilla.h in PlatWin.cxx. 5 | **/ 6 | // Copyright 1998-2009 by Neil Hodgson 7 | // The License.txt file describes the conditions under which this software may be distributed. 8 | 9 | #ifndef FONTQUALITY_H 10 | #define FONTQUALITY_H 11 | 12 | #ifdef SCI_NAMESPACE 13 | namespace Scintilla { 14 | #endif 15 | 16 | // These definitions match Scintilla.h 17 | #define SC_EFF_QUALITY_MASK 0xF 18 | #define SC_EFF_QUALITY_DEFAULT 0 19 | #define SC_EFF_QUALITY_NON_ANTIALIASED 1 20 | #define SC_EFF_QUALITY_ANTIALIASED 2 21 | #define SC_EFF_QUALITY_LCD_OPTIMIZED 3 22 | 23 | // These definitions must match SC_TECHNOLOGY_* in Scintilla.h 24 | #define SCWIN_TECH_GDI 0 25 | #define SCWIN_TECH_DIRECTWRITE 1 26 | 27 | #ifdef SCI_NAMESPACE 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /vendor/scintilla/src/Indicator.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file Indicator.h 3 | ** Defines the style of indicators which are text decorations such as underlining. 4 | **/ 5 | // Copyright 1998-2001 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef INDICATOR_H 9 | #define INDICATOR_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | /** 16 | */ 17 | class Indicator { 18 | public: 19 | int style; 20 | ColourDesired fore; 21 | bool under; 22 | int fillAlpha; 23 | int outlineAlpha; 24 | Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)), under(false), fillAlpha(30), outlineAlpha(50) { 25 | } 26 | Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) : 27 | style(style_), fore(fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_) { 28 | } 29 | void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) const; 30 | }; 31 | 32 | #ifdef SCI_NAMESPACE 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /vendor/scintilla/src/KeyMap.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file KeyMap.h 3 | ** Defines a mapping between keystrokes and commands. 4 | **/ 5 | // Copyright 1998-2001 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef KEYMAP_H 9 | #define KEYMAP_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | #define SCI_NORM 0 16 | #define SCI_SHIFT SCMOD_SHIFT 17 | #define SCI_CTRL SCMOD_CTRL 18 | #define SCI_ALT SCMOD_ALT 19 | #define SCI_META SCMOD_META 20 | #define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT) 21 | #define SCI_ASHIFT (SCI_ALT | SCI_SHIFT) 22 | 23 | /** 24 | */ 25 | class KeyModifiers { 26 | public: 27 | int key; 28 | int modifiers; 29 | KeyModifiers(int key_, int modifiers_) : key(key_), modifiers(modifiers_) { 30 | } 31 | bool operator<(const KeyModifiers &other) const { 32 | if (key == other.key) 33 | return modifiers < other.modifiers; 34 | else 35 | return key < other.key; 36 | } 37 | }; 38 | 39 | /** 40 | */ 41 | class KeyToCommand { 42 | public: 43 | int key; 44 | int modifiers; 45 | unsigned int msg; 46 | }; 47 | 48 | /** 49 | */ 50 | class KeyMap { 51 | std::map kmap; 52 | static const KeyToCommand MapDefault[]; 53 | 54 | public: 55 | KeyMap(); 56 | ~KeyMap(); 57 | void Clear(); 58 | void AssignCmdKey(int key, int modifiers, unsigned int msg); 59 | unsigned int Find(int key, int modifiers) const; // 0 returned on failure 60 | }; 61 | 62 | #ifdef SCI_NAMESPACE 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /vendor/scintilla/src/LineMarker.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file LineMarker.h 3 | ** Defines the look of a line marker in the margin . 4 | **/ 5 | // Copyright 1998-2011 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef LINEMARKER_H 9 | #define LINEMARKER_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | typedef void (*DrawLineMarkerFn)(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, int tFold, int marginStyle, const void *lineMarker); 16 | 17 | /** 18 | */ 19 | class LineMarker { 20 | public: 21 | enum typeOfFold { undefined, head, body, tail, headWithTail }; 22 | 23 | int markType; 24 | ColourDesired fore; 25 | ColourDesired back; 26 | ColourDesired backSelected; 27 | int alpha; 28 | XPM *pxpm; 29 | RGBAImage *image; 30 | /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native 31 | * Draw function for drawing line markers. Allow those platforms to override 32 | * it instead of creating a new method(s) in the Surface class that existing 33 | * platforms must implement as empty. */ 34 | DrawLineMarkerFn customDraw; 35 | LineMarker() { 36 | markType = SC_MARK_CIRCLE; 37 | fore = ColourDesired(0,0,0); 38 | back = ColourDesired(0xff,0xff,0xff); 39 | backSelected = ColourDesired(0xff,0x00,0x00); 40 | alpha = SC_ALPHA_NOALPHA; 41 | pxpm = NULL; 42 | image = NULL; 43 | customDraw = NULL; 44 | } 45 | LineMarker(const LineMarker &) { 46 | // Defined to avoid pxpm being blindly copied, not as a complete copy constructor 47 | markType = SC_MARK_CIRCLE; 48 | fore = ColourDesired(0,0,0); 49 | back = ColourDesired(0xff,0xff,0xff); 50 | backSelected = ColourDesired(0xff,0x00,0x00); 51 | alpha = SC_ALPHA_NOALPHA; 52 | pxpm = NULL; 53 | image = NULL; 54 | customDraw = NULL; 55 | } 56 | ~LineMarker() { 57 | delete pxpm; 58 | delete image; 59 | } 60 | LineMarker &operator=(const LineMarker &other) { 61 | // Defined to avoid pxpm being blindly copied, not as a complete assignment operator 62 | if (this != &other) { 63 | markType = SC_MARK_CIRCLE; 64 | fore = ColourDesired(0,0,0); 65 | back = ColourDesired(0xff,0xff,0xff); 66 | backSelected = ColourDesired(0xff,0x00,0x00); 67 | alpha = SC_ALPHA_NOALPHA; 68 | delete pxpm; 69 | pxpm = NULL; 70 | delete image; 71 | image = NULL; 72 | customDraw = NULL; 73 | } 74 | return *this; 75 | } 76 | void SetXPM(const char *textForm); 77 | void SetXPM(const char *const *linesForm); 78 | void SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage); 79 | void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const; 80 | }; 81 | 82 | #ifdef SCI_NAMESPACE 83 | } 84 | #endif 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /vendor/scintilla/src/MarginView.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file MarginView.h 3 | ** Defines the appearance of the editor margin. 4 | **/ 5 | // Copyright 1998-2014 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef MARGINVIEW_H 9 | #define MARGINVIEW_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour); 16 | 17 | typedef void (*DrawWrapMarkerFn)(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour); 18 | 19 | /** 20 | * MarginView draws the margins. 21 | */ 22 | class MarginView { 23 | public: 24 | Surface *pixmapSelMargin; 25 | Surface *pixmapSelPattern; 26 | Surface *pixmapSelPatternOffset1; 27 | // Highlight current folding block 28 | HighlightDelimiter highlightDelimiter; 29 | 30 | int wrapMarkerPaddingRight; // right-most pixel padding of wrap markers 31 | /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native 32 | * DrawWrapMarker function for drawing wrap markers. Allow those platforms to 33 | * override it instead of creating a new method in the Surface class that 34 | * existing platforms must implement as empty. */ 35 | DrawWrapMarkerFn customDrawWrapMarker; 36 | 37 | MarginView(); 38 | 39 | void DropGraphics(bool freeObjects); 40 | void AllocateGraphics(const ViewStyle &vsDraw); 41 | void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw); 42 | void PaintMargin(Surface *surface, int topLine, PRectangle rc, PRectangle rcMargin, 43 | const EditModel &model, const ViewStyle &vs); 44 | }; 45 | 46 | #ifdef SCI_NAMESPACE 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /vendor/scintilla/src/PerLine.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file PerLine.h 3 | ** Manages data associated with each line of the document 4 | **/ 5 | // Copyright 1998-2009 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef PERLINE_H 9 | #define PERLINE_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | /** 16 | * This holds the marker identifier and the marker type to display. 17 | * MarkerHandleNumbers are members of lists. 18 | */ 19 | struct MarkerHandleNumber { 20 | int handle; 21 | int number; 22 | MarkerHandleNumber *next; 23 | }; 24 | 25 | /** 26 | * A marker handle set contains any number of MarkerHandleNumbers. 27 | */ 28 | class MarkerHandleSet { 29 | MarkerHandleNumber *root; 30 | 31 | public: 32 | MarkerHandleSet(); 33 | ~MarkerHandleSet(); 34 | int Length() const; 35 | int MarkValue() const; ///< Bit set of marker numbers. 36 | bool Contains(int handle) const; 37 | bool InsertHandle(int handle, int markerNum); 38 | void RemoveHandle(int handle); 39 | bool RemoveNumber(int markerNum, bool all); 40 | void CombineWith(MarkerHandleSet *other); 41 | }; 42 | 43 | class LineMarkers : public PerLine { 44 | SplitVector markers; 45 | /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big. 46 | int handleCurrent; 47 | public: 48 | LineMarkers() : handleCurrent(0) { 49 | } 50 | virtual ~LineMarkers(); 51 | virtual void Init(); 52 | virtual void InsertLine(int line); 53 | virtual void RemoveLine(int line); 54 | 55 | int MarkValue(int line); 56 | int MarkerNext(int lineStart, int mask) const; 57 | int AddMark(int line, int marker, int lines); 58 | void MergeMarkers(int pos); 59 | bool DeleteMark(int line, int markerNum, bool all); 60 | void DeleteMarkFromHandle(int markerHandle); 61 | int LineFromHandle(int markerHandle); 62 | }; 63 | 64 | class LineLevels : public PerLine { 65 | SplitVector levels; 66 | public: 67 | virtual ~LineLevels(); 68 | virtual void Init(); 69 | virtual void InsertLine(int line); 70 | virtual void RemoveLine(int line); 71 | 72 | void ExpandLevels(int sizeNew=-1); 73 | void ClearLevels(); 74 | int SetLevel(int line, int level, int lines); 75 | int GetLevel(int line) const; 76 | }; 77 | 78 | class LineState : public PerLine { 79 | SplitVector lineStates; 80 | public: 81 | LineState() { 82 | } 83 | virtual ~LineState(); 84 | virtual void Init(); 85 | virtual void InsertLine(int line); 86 | virtual void RemoveLine(int line); 87 | 88 | int SetLineState(int line, int state); 89 | int GetLineState(int line); 90 | int GetMaxLineState() const; 91 | }; 92 | 93 | class LineAnnotation : public PerLine { 94 | SplitVector annotations; 95 | public: 96 | LineAnnotation() { 97 | } 98 | virtual ~LineAnnotation(); 99 | virtual void Init(); 100 | virtual void InsertLine(int line); 101 | virtual void RemoveLine(int line); 102 | 103 | bool MultipleStyles(int line) const; 104 | int Style(int line) const; 105 | const char *Text(int line) const; 106 | const unsigned char *Styles(int line) const; 107 | void SetText(int line, const char *text); 108 | void ClearAll(); 109 | void SetStyle(int line, int style); 110 | void SetStyles(int line, const unsigned char *styles); 111 | int Length(int line) const; 112 | int Lines(int line) const; 113 | }; 114 | 115 | typedef std::vector TabstopList; 116 | 117 | class LineTabstops : public PerLine { 118 | SplitVector tabstops; 119 | public: 120 | LineTabstops() { 121 | } 122 | virtual ~LineTabstops(); 123 | virtual void Init(); 124 | virtual void InsertLine(int line); 125 | virtual void RemoveLine(int line); 126 | 127 | bool ClearTabstops(int line); 128 | bool AddTabstop(int line, int x); 129 | int GetNextTabstop(int line, int x) const; 130 | }; 131 | 132 | #ifdef SCI_NAMESPACE 133 | } 134 | #endif 135 | 136 | #endif 137 | -------------------------------------------------------------------------------- /vendor/scintilla/src/RESearch.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file RESearch.h 3 | ** Interface to the regular expression search library. 4 | **/ 5 | // Written by Neil Hodgson 6 | // Based on the work of Ozan S. Yigit. 7 | // This file is in the public domain. 8 | 9 | #ifndef RESEARCH_H 10 | #define RESEARCH_H 11 | 12 | #ifdef SCI_NAMESPACE 13 | namespace Scintilla { 14 | #endif 15 | 16 | /* 17 | * The following defines are not meant to be changeable. 18 | * They are for readability only. 19 | */ 20 | #define MAXCHR 256 21 | #define CHRBIT 8 22 | #define BITBLK MAXCHR/CHRBIT 23 | 24 | class CharacterIndexer { 25 | public: 26 | virtual char CharAt(int index)=0; 27 | virtual ~CharacterIndexer() { 28 | } 29 | }; 30 | 31 | class RESearch { 32 | 33 | public: 34 | explicit RESearch(CharClassify *charClassTable); 35 | ~RESearch(); 36 | void Clear(); 37 | void GrabMatches(CharacterIndexer &ci); 38 | const char *Compile(const char *pattern, int length, bool caseSensitive, bool posix); 39 | int Execute(CharacterIndexer &ci, int lp, int endp); 40 | 41 | enum { MAXTAG=10 }; 42 | enum { MAXNFA=2048 }; 43 | enum { NOTFOUND=-1 }; 44 | 45 | int bopat[MAXTAG]; 46 | int eopat[MAXTAG]; 47 | std::string pat[MAXTAG]; 48 | 49 | private: 50 | void ChSet(unsigned char c); 51 | void ChSetWithCase(unsigned char c, bool caseSensitive); 52 | int GetBackslashExpression(const char *pattern, int &incr); 53 | 54 | int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap); 55 | 56 | int bol; 57 | int tagstk[MAXTAG]; /* subpat tag stack */ 58 | char nfa[MAXNFA]; /* automaton */ 59 | int sta; 60 | unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */ 61 | int failure; 62 | CharClassify *charClass; 63 | bool iswordc(unsigned char x) const { 64 | return charClass->IsWord(x); 65 | } 66 | }; 67 | 68 | #ifdef SCI_NAMESPACE 69 | } 70 | #endif 71 | 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /vendor/scintilla/src/RunStyles.h: -------------------------------------------------------------------------------- 1 | /** @file RunStyles.h 2 | ** Data structure used to store sparse styles. 3 | **/ 4 | // Copyright 1998-2007 by Neil Hodgson 5 | // The License.txt file describes the conditions under which this software may be distributed. 6 | 7 | /// Styling buffer using one element for each run rather than using 8 | /// a filled buffer. 9 | 10 | #ifndef RUNSTYLES_H 11 | #define RUNSTYLES_H 12 | 13 | #ifdef SCI_NAMESPACE 14 | namespace Scintilla { 15 | #endif 16 | 17 | class RunStyles { 18 | private: 19 | Partitioning *starts; 20 | SplitVector *styles; 21 | int RunFromPosition(int position) const; 22 | int SplitRun(int position); 23 | void RemoveRun(int run); 24 | void RemoveRunIfEmpty(int run); 25 | void RemoveRunIfSameAsPrevious(int run); 26 | // Private so RunStyles objects can not be copied 27 | RunStyles(const RunStyles &); 28 | public: 29 | RunStyles(); 30 | ~RunStyles(); 31 | int Length() const; 32 | int ValueAt(int position) const; 33 | int FindNextChange(int position, int end) const; 34 | int StartRun(int position) const; 35 | int EndRun(int position) const; 36 | // Returns true if some values may have changed 37 | bool FillRange(int &position, int value, int &fillLength); 38 | void SetValueAt(int position, int value); 39 | void InsertSpace(int position, int insertLength); 40 | void DeleteAll(); 41 | void DeleteRange(int position, int deleteLength); 42 | int Runs() const; 43 | bool AllSame() const; 44 | bool AllSameAs(int value) const; 45 | int Find(int value, int start) const; 46 | 47 | void Check() const; 48 | }; 49 | 50 | #ifdef SCI_NAMESPACE 51 | } 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /vendor/scintilla/src/ScintillaBase.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file ScintillaBase.h 3 | ** Defines an enhanced subclass of Editor with calltips, autocomplete and context menu. 4 | **/ 5 | // Copyright 1998-2002 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef SCINTILLABASE_H 9 | #define SCINTILLABASE_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | #ifdef SCI_LEXER 16 | class LexState; 17 | #endif 18 | 19 | /** 20 | */ 21 | class ScintillaBase : public Editor { 22 | // Private so ScintillaBase objects can not be copied 23 | ScintillaBase(const ScintillaBase &); 24 | ScintillaBase &operator=(const ScintillaBase &); 25 | 26 | protected: 27 | /** Enumeration of commands and child windows. */ 28 | enum { 29 | idCallTip=1, 30 | idAutoComplete=2, 31 | 32 | idcmdUndo=10, 33 | idcmdRedo=11, 34 | idcmdCut=12, 35 | idcmdCopy=13, 36 | idcmdPaste=14, 37 | idcmdDelete=15, 38 | idcmdSelectAll=16 39 | }; 40 | 41 | enum { maxLenInputIME = 200 }; 42 | 43 | bool displayPopupMenu; 44 | Menu popup; 45 | AutoComplete ac; 46 | 47 | CallTip ct; 48 | 49 | int listType; ///< 0 is an autocomplete list 50 | int maxListWidth; /// Maximum width of list, in average character widths 51 | int multiAutoCMode; /// Mode for autocompleting when multiple selections are present 52 | 53 | #ifdef SCI_LEXER 54 | LexState *DocumentLexState(); 55 | void SetLexer(uptr_t wParam); 56 | void SetLexerLanguage(const char *languageName); 57 | void Colourise(int start, int end); 58 | #endif 59 | 60 | ScintillaBase(); 61 | virtual ~ScintillaBase(); 62 | virtual void Initialise() = 0; 63 | virtual void Finalise(); 64 | 65 | virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false); 66 | void Command(int cmdId); 67 | virtual void CancelModes(); 68 | virtual int KeyCommand(unsigned int iMessage); 69 | 70 | void AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen); 71 | void AutoCompleteStart(int lenEntered, const char *list); 72 | void AutoCompleteCancel(); 73 | void AutoCompleteMove(int delta); 74 | int AutoCompleteGetCurrent() const; 75 | int AutoCompleteGetCurrentText(char *buffer) const; 76 | void AutoCompleteCharacterAdded(char ch); 77 | void AutoCompleteCharacterDeleted(); 78 | void AutoCompleteCompleted(); 79 | void AutoCompleteMoveToCurrentWord(); 80 | static void AutoCompleteDoubleClick(void *p); 81 | 82 | void CallTipClick(); 83 | void CallTipShow(Point pt, const char *defn); 84 | virtual void CreateCallTipWindow(PRectangle rc) = 0; 85 | 86 | virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true) = 0; 87 | void ContextMenu(Point pt); 88 | 89 | virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers); 90 | virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); 91 | 92 | void NotifyStyleToNeeded(int endStyleNeeded); 93 | void NotifyLexerChanged(Document *doc, void *userData); 94 | 95 | public: 96 | // Public so scintilla_send_message can use it 97 | virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); 98 | }; 99 | 100 | #ifdef SCI_NAMESPACE 101 | } 102 | #endif 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /vendor/scintilla/src/Style.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file Style.h 3 | ** Defines the font and colour style for a class of text. 4 | **/ 5 | // Copyright 1998-2001 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef STYLE_H 9 | #define STYLE_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | struct FontSpecification { 16 | const char *fontName; 17 | int weight; 18 | bool italic; 19 | int size; 20 | int characterSet; 21 | int extraFontFlag; 22 | FontSpecification() : 23 | fontName(0), 24 | weight(SC_WEIGHT_NORMAL), 25 | italic(false), 26 | size(10 * SC_FONT_SIZE_MULTIPLIER), 27 | characterSet(0), 28 | extraFontFlag(0) { 29 | } 30 | bool operator==(const FontSpecification &other) const; 31 | bool operator<(const FontSpecification &other) const; 32 | }; 33 | 34 | // Just like Font but only has a copy of the FontID so should not delete it 35 | class FontAlias : public Font { 36 | // Private so FontAlias objects can not be assigned except for intiialization 37 | FontAlias &operator=(const FontAlias &); 38 | public: 39 | FontAlias(); 40 | FontAlias(const FontAlias &); 41 | virtual ~FontAlias(); 42 | void MakeAlias(Font &fontOrigin); 43 | void ClearFont(); 44 | }; 45 | 46 | struct FontMeasurements { 47 | unsigned int ascent; 48 | unsigned int descent; 49 | XYPOSITION aveCharWidth; 50 | XYPOSITION spaceWidth; 51 | int sizeZoomed; 52 | FontMeasurements(); 53 | void Clear(); 54 | }; 55 | 56 | /** 57 | */ 58 | class Style : public FontSpecification, public FontMeasurements { 59 | public: 60 | ColourDesired fore; 61 | ColourDesired back; 62 | bool eolFilled; 63 | bool underline; 64 | enum ecaseForced {caseMixed, caseUpper, caseLower}; 65 | ecaseForced caseForce; 66 | bool visible; 67 | bool changeable; 68 | bool hotspot; 69 | 70 | FontAlias font; 71 | 72 | Style(); 73 | Style(const Style &source); 74 | ~Style(); 75 | Style &operator=(const Style &source); 76 | void Clear(ColourDesired fore_, ColourDesired back_, 77 | int size_, 78 | const char *fontName_, int characterSet_, 79 | int weight_, bool italic_, bool eolFilled_, 80 | bool underline_, ecaseForced caseForce_, 81 | bool visible_, bool changeable_, bool hotspot_); 82 | void ClearTo(const Style &source); 83 | void Copy(Font &font_, const FontMeasurements &fm_); 84 | bool IsProtected() const { return !(changeable && visible);} 85 | }; 86 | 87 | #ifdef SCI_NAMESPACE 88 | } 89 | #endif 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /vendor/scintilla/src/UniConversion.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file UniConversion.h 3 | ** Functions to handle UTF-8 and UTF-16 strings. 4 | **/ 5 | // Copyright 1998-2001 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef UNICONVERSION_H 9 | #define UNICONVERSION_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | const int UTF8MaxBytes = 4; 16 | 17 | const int unicodeReplacementChar = 0xFFFD; 18 | 19 | unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen); 20 | void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len); 21 | unsigned int UTF8CharLength(unsigned char ch); 22 | unsigned int UTF16Length(const char *s, unsigned int len); 23 | unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen); 24 | unsigned int UTF32FromUTF8(const char *s, unsigned int len, unsigned int *tbuf, unsigned int tlen); 25 | unsigned int UTF16FromUTF32Character(unsigned int val, wchar_t *tbuf); 26 | 27 | extern int UTF8BytesOfLead[256]; 28 | void UTF8BytesOfLeadInitialise(); 29 | 30 | inline bool UTF8IsTrailByte(int ch) { 31 | return (ch >= 0x80) && (ch < 0xc0); 32 | } 33 | 34 | inline bool UTF8IsAscii(int ch) { 35 | return ch < 0x80; 36 | } 37 | 38 | enum { UTF8MaskWidth=0x7, UTF8MaskInvalid=0x8 }; 39 | int UTF8Classify(const unsigned char *us, int len); 40 | 41 | // Similar to UTF8Classify but returns a length of 1 for invalid bytes 42 | // instead of setting the invalid flag 43 | int UTF8DrawBytes(const unsigned char *us, int len); 44 | 45 | // Line separator is U+2028 \xe2\x80\xa8 46 | // Paragraph separator is U+2029 \xe2\x80\xa9 47 | const int UTF8SeparatorLength = 3; 48 | inline bool UTF8IsSeparator(const unsigned char *us) { 49 | return (us[0] == 0xe2) && (us[1] == 0x80) && ((us[2] == 0xa8) || (us[2] == 0xa9)); 50 | } 51 | 52 | // NEL is U+0085 \xc2\x85 53 | const int UTF8NELLength = 2; 54 | inline bool UTF8IsNEL(const unsigned char *us) { 55 | return (us[0] == 0xc2) && (us[1] == 0x85); 56 | } 57 | 58 | #ifdef SCI_NAMESPACE 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /vendor/scintilla/src/UnicodeFromUTF8.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file UnicodeFromUTF8.h 3 | ** Lexer infrastructure. 4 | **/ 5 | // Copyright 2013 by Neil Hodgson 6 | // This file is in the public domain. 7 | 8 | #ifndef UNICODEFROMUTF8_H 9 | #define UNICODEFROMUTF8_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | inline int UnicodeFromUTF8(const unsigned char *us) { 16 | if (us[0] < 0xC2) { 17 | return us[0]; 18 | } else if (us[0] < 0xE0) { 19 | return ((us[0] & 0x1F) << 6) + (us[1] & 0x3F); 20 | } else if (us[0] < 0xF0) { 21 | return ((us[0] & 0xF) << 12) + ((us[1] & 0x3F) << 6) + (us[2] & 0x3F); 22 | } else if (us[0] < 0xF5) { 23 | return ((us[0] & 0x7) << 18) + ((us[1] & 0x3F) << 12) + ((us[2] & 0x3F) << 6) + (us[3] & 0x3F); 24 | } 25 | return us[0]; 26 | } 27 | 28 | #ifdef SCI_NAMESPACE 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /vendor/scintilla/src/XPM.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file XPM.h 3 | ** Define a classes to hold image data in the X Pixmap (XPM) and RGBA formats. 4 | **/ 5 | // Copyright 1998-2003 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef XPM_H 9 | #define XPM_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | /** 16 | * Hold a pixmap in XPM format. 17 | */ 18 | class XPM { 19 | int height; 20 | int width; 21 | int nColours; 22 | std::vector pixels; 23 | ColourDesired colourCodeTable[256]; 24 | char codeTransparent; 25 | ColourDesired ColourFromCode(int ch) const; 26 | void FillRun(Surface *surface, int code, int startX, int y, int x); 27 | public: 28 | explicit XPM(const char *textForm); 29 | explicit XPM(const char *const *linesForm); 30 | ~XPM(); 31 | void Init(const char *textForm); 32 | void Init(const char *const *linesForm); 33 | /// Decompose image into runs and use FillRectangle for each run 34 | void Draw(Surface *surface, PRectangle &rc); 35 | int GetHeight() const { return height; } 36 | int GetWidth() const { return width; } 37 | void PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const; 38 | private: 39 | static std::vectorLinesFormFromTextForm(const char *textForm); 40 | }; 41 | 42 | /** 43 | * A translucent image stored as a sequence of RGBA bytes. 44 | */ 45 | class RGBAImage { 46 | // Private so RGBAImage objects can not be copied 47 | RGBAImage(const RGBAImage &); 48 | RGBAImage &operator=(const RGBAImage &); 49 | int height; 50 | int width; 51 | float scale; 52 | std::vector pixelBytes; 53 | public: 54 | RGBAImage(int width_, int height_, float scale_, const unsigned char *pixels_); 55 | explicit RGBAImage(const XPM &xpm); 56 | virtual ~RGBAImage(); 57 | int GetHeight() const { return height; } 58 | int GetWidth() const { return width; } 59 | float GetScale() const { return scale; } 60 | float GetScaledHeight() const { return height / scale; } 61 | float GetScaledWidth() const { return width / scale; } 62 | int CountBytes() const; 63 | const unsigned char *Pixels() const; 64 | void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff); 65 | }; 66 | 67 | /** 68 | * A collection of RGBAImage pixmaps indexed by integer id. 69 | */ 70 | class RGBAImageSet { 71 | typedef std::map ImageMap; 72 | ImageMap images; 73 | mutable int height; ///< Memorize largest height of the set. 74 | mutable int width; ///< Memorize largest width of the set. 75 | public: 76 | RGBAImageSet(); 77 | ~RGBAImageSet(); 78 | /// Remove all images. 79 | void Clear(); 80 | /// Add an image. 81 | void Add(int ident, RGBAImage *image); 82 | /// Get image by id. 83 | RGBAImage *Get(int ident); 84 | /// Give the largest height of the set. 85 | int GetHeight() const; 86 | /// Give the largest width of the set. 87 | int GetWidth() const; 88 | }; 89 | 90 | #ifdef SCI_NAMESPACE 91 | } 92 | #endif 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /vendor/scintilla/test/examples/x.cxx: -------------------------------------------------------------------------------- 1 | // A demonstration program 2 | #include 3 | #if 0 /* */ 4 | #define DUMMY() \ 5 | if (1); 6 | #endif 7 | 8 | #define M\ 9 | 10 | \ 11 | 12 | int main() { 13 | double x[] = {3.14159,6.02e23,1.6e-19,1.0+1}; 14 | int y[] = {75,0113,0x4b}; 15 | printf("hello world %d %g\n", y[0], x[0]); 16 | } 17 | -------------------------------------------------------------------------------- /vendor/scintilla/test/unit/testCharClassify.cxx: -------------------------------------------------------------------------------- 1 | // Unit Tests for Scintilla internal data structures 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "Platform.h" 8 | 9 | #include "CharClassify.h" 10 | 11 | #include "catch.hpp" 12 | 13 | // Test CharClassify. 14 | 15 | class CharClassifyTest { 16 | // Avoid warnings, private so never called. 17 | CharClassifyTest(const CharClassifyTest &); 18 | protected: 19 | CharClassifyTest() { 20 | pcc = new CharClassify(); 21 | for (int ch = 0; ch < 256; ch++) { 22 | if (ch == '\r' || ch == '\n') 23 | charClass[ch] = CharClassify::ccNewLine; 24 | else if (ch < 0x20 || ch == ' ') 25 | charClass[ch] = CharClassify::ccSpace; 26 | else if (ch >= 0x80 || isalnum(ch) || ch == '_') 27 | charClass[ch] = CharClassify::ccWord; 28 | else 29 | charClass[ch] = CharClassify::ccPunctuation; 30 | } 31 | } 32 | 33 | ~CharClassifyTest() { 34 | delete pcc; 35 | pcc = 0; 36 | } 37 | 38 | CharClassify *pcc; 39 | CharClassify::cc charClass[256]; 40 | 41 | static const char* GetClassName(CharClassify::cc charClass) { 42 | switch(charClass) { 43 | #define CASE(c) case CharClassify::c: return #c 44 | CASE(ccSpace); 45 | CASE(ccNewLine); 46 | CASE(ccWord); 47 | CASE(ccPunctuation); 48 | #undef CASE 49 | default: 50 | return ""; 51 | } 52 | } 53 | }; 54 | 55 | TEST_CASE_METHOD(CharClassifyTest, "Defaults") { 56 | for (int i = 0; i < 256; i++) { 57 | if (charClass[i] != pcc->GetClass(i)) 58 | std::cerr 59 | << "Character " << i 60 | << " should be class " << GetClassName(charClass[i]) 61 | << ", but got " << GetClassName(pcc->GetClass(i)) << std::endl; 62 | REQUIRE(charClass[i] == pcc->GetClass(i)); 63 | } 64 | } 65 | 66 | TEST_CASE_METHOD(CharClassifyTest, "Custom") { 67 | unsigned char buf[2] = {0, 0}; 68 | for (int i = 0; i < 256; i++) { 69 | CharClassify::cc thisClass = CharClassify::cc(i % 4); 70 | buf[0] = i; 71 | pcc->SetCharClasses(buf, thisClass); 72 | charClass[i] = thisClass; 73 | } 74 | for (int i = 0; i < 256; i++) { 75 | if (charClass[i] != pcc->GetClass(i)) 76 | std::cerr 77 | << "Character " << i 78 | << " should be class " << GetClassName(charClass[i]) 79 | << ", but got " << GetClassName(pcc->GetClass(i)) << std::endl; 80 | REQUIRE(charClass[i] == pcc->GetClass(i)); 81 | } 82 | } 83 | 84 | TEST_CASE_METHOD(CharClassifyTest, "CharsOfClass") { 85 | unsigned char buf[2] = {0, 0}; 86 | for (int i = 1; i < 256; i++) { 87 | CharClassify::cc thisClass = CharClassify::cc(i % 4); 88 | buf[0] = i; 89 | pcc->SetCharClasses(buf, thisClass); 90 | charClass[i] = thisClass; 91 | } 92 | for (int classVal = 0; classVal < 4; ++classVal) { 93 | CharClassify::cc thisClass = CharClassify::cc(classVal % 4); 94 | int size = pcc->GetCharsOfClass(thisClass, NULL); 95 | unsigned char* buffer = reinterpret_cast(malloc(size + 1)); 96 | CHECK(buffer); 97 | buffer[size] = '\0'; 98 | pcc->GetCharsOfClass(thisClass, buffer); 99 | for (int i = 1; i < 256; i++) { 100 | if (charClass[i] == thisClass) { 101 | if (!memchr(reinterpret_cast(buffer), i, size)) 102 | std::cerr 103 | << "Character " << i 104 | << " should be class " << GetClassName(thisClass) 105 | << ", but was not in GetCharsOfClass;" 106 | << " it is reported to be " 107 | << GetClassName(pcc->GetClass(i)) << std::endl; 108 | REQUIRE(memchr(reinterpret_cast(buffer), i, size)); 109 | } else { 110 | if (memchr(reinterpret_cast(buffer), i, size)) 111 | std::cerr 112 | << "Character " << i 113 | << " should not be class " << GetClassName(thisClass) 114 | << ", but was in GetCharsOfClass" 115 | << " it is reported to be " 116 | << GetClassName(pcc->GetClass(i)) << std::endl; 117 | REQUIRE_FALSE(memchr(reinterpret_cast(buffer), i, size)); 118 | } 119 | } 120 | free(buffer); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /vendor/scintilla/test/unit/testContractionState.cxx: -------------------------------------------------------------------------------- 1 | // Unit Tests for Scintilla internal data structures 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "Platform.h" 8 | 9 | #include "SplitVector.h" 10 | #include "Partitioning.h" 11 | #include "RunStyles.h" 12 | #include "ContractionState.h" 13 | 14 | #include "catch.hpp" 15 | 16 | // Test ContractionState. 17 | 18 | TEST_CASE("ContractionState") { 19 | 20 | ContractionState cs; 21 | 22 | SECTION("IsEmptyInitially") { 23 | REQUIRE(1 == cs.LinesInDoc()); 24 | REQUIRE(1 == cs.LinesDisplayed()); 25 | REQUIRE(0 == cs.DisplayFromDoc(0)); 26 | REQUIRE(0 == cs.DocFromDisplay(0)); 27 | } 28 | 29 | SECTION("OneLine") { 30 | cs.InsertLine(0); 31 | REQUIRE(2 == cs.LinesInDoc()); 32 | REQUIRE(2 == cs.LinesDisplayed()); 33 | REQUIRE(0 == cs.DisplayFromDoc(0)); 34 | REQUIRE(0 == cs.DocFromDisplay(0)); 35 | REQUIRE(1 == cs.DisplayFromDoc(1)); 36 | REQUIRE(1 == cs.DocFromDisplay(1)); 37 | } 38 | 39 | SECTION("InsertionThenDeletions") { 40 | cs.InsertLines(0,4); 41 | cs.DeleteLine(1); 42 | 43 | REQUIRE(4 == cs.LinesInDoc()); 44 | REQUIRE(4 == cs.LinesDisplayed()); 45 | for (int l=0;l<4;l++) { 46 | REQUIRE(l == cs.DisplayFromDoc(l)); 47 | REQUIRE(l == cs.DocFromDisplay(l)); 48 | } 49 | 50 | cs.DeleteLines(0,2); 51 | REQUIRE(2 == cs.LinesInDoc()); 52 | REQUIRE(2 == cs.LinesDisplayed()); 53 | for (int l=0;l<2;l++) { 54 | REQUIRE(l == cs.DisplayFromDoc(l)); 55 | REQUIRE(l == cs.DocFromDisplay(l)); 56 | } 57 | } 58 | 59 | SECTION("ShowHide") { 60 | cs.InsertLines(0,4); 61 | REQUIRE(true == cs.GetVisible(0)); 62 | REQUIRE(true == cs.GetVisible(1)); 63 | REQUIRE(true == cs.GetVisible(2)); 64 | REQUIRE(5 == cs.LinesDisplayed()); 65 | 66 | cs.SetVisible(1, 1, false); 67 | REQUIRE(true == cs.GetVisible(0)); 68 | REQUIRE(0 == cs.GetVisible(1)); 69 | REQUIRE(true == cs.GetVisible(2)); 70 | REQUIRE(4 == cs.LinesDisplayed()); 71 | REQUIRE(1 == cs.HiddenLines()); 72 | 73 | cs.SetVisible(1, 2, true); 74 | for (int l=0;l<4;l++) { 75 | REQUIRE(true == cs.GetVisible(0)); 76 | } 77 | 78 | cs.SetVisible(1, 1, false); 79 | REQUIRE(0 == cs.GetVisible(1)); 80 | cs.ShowAll(); 81 | for (int l=0;l<4;l++) { 82 | REQUIRE(true == cs.GetVisible(0)); 83 | } 84 | REQUIRE(0 == cs.HiddenLines()); 85 | } 86 | 87 | SECTION("Hidden") { 88 | cs.InsertLines(0,1); 89 | for (int l=0;l<2;l++) { 90 | REQUIRE(true == cs.GetVisible(0)); 91 | } 92 | REQUIRE(0 == cs.HiddenLines()); 93 | 94 | cs.SetVisible(1, 1, false); 95 | REQUIRE(true == cs.GetVisible(0)); 96 | REQUIRE(0 == cs.GetVisible(1)); 97 | REQUIRE(1 == cs.HiddenLines()); 98 | 99 | cs.SetVisible(1, 1, true); 100 | for (int l=0;l<2;l++) { 101 | REQUIRE(true == cs.GetVisible(0)); 102 | } 103 | REQUIRE(0 == cs.HiddenLines()); 104 | } 105 | 106 | SECTION("Contracting") { 107 | cs.InsertLines(0,4); 108 | for (int l=0;l<4;l++) { 109 | REQUIRE(true == cs.GetExpanded(l)); 110 | } 111 | 112 | cs.SetExpanded(2, false); 113 | REQUIRE(true == cs.GetExpanded(1)); 114 | REQUIRE(0 == cs.GetExpanded(2)); 115 | REQUIRE(true == cs.GetExpanded(3)); 116 | 117 | REQUIRE(2 == cs.ContractedNext(0)); 118 | REQUIRE(2 == cs.ContractedNext(1)); 119 | REQUIRE(2 == cs.ContractedNext(2)); 120 | REQUIRE(-1 == cs.ContractedNext(3)); 121 | 122 | cs.SetExpanded(2, true); 123 | REQUIRE(true == cs.GetExpanded(1)); 124 | REQUIRE(true == cs.GetExpanded(2)); 125 | REQUIRE(true == cs.GetExpanded(3)); 126 | } 127 | 128 | SECTION("ChangeHeight") { 129 | cs.InsertLines(0,4); 130 | for (int l=0;l<4;l++) { 131 | REQUIRE(1 == cs.GetHeight(l)); 132 | } 133 | 134 | cs.SetHeight(1, 2); 135 | REQUIRE(1 == cs.GetHeight(0)); 136 | REQUIRE(2 == cs.GetHeight(1)); 137 | REQUIRE(1 == cs.GetHeight(2)); 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /vendor/scintilla/test/unit/testDecoration.cxx: -------------------------------------------------------------------------------- 1 | // Unit Tests for Scintilla internal data structures 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include "Platform.h" 9 | 10 | #include "SplitVector.h" 11 | #include "Partitioning.h" 12 | #include "RunStyles.h" 13 | #include "Decoration.h" 14 | 15 | #include "catch.hpp" 16 | 17 | const int indicator=4; 18 | 19 | // Test Decoration. 20 | 21 | TEST_CASE("Decoration") { 22 | 23 | Decoration deco(indicator); 24 | 25 | SECTION("HasCorrectIndicator") { 26 | REQUIRE(indicator == deco.indicator); 27 | } 28 | 29 | SECTION("IsEmptyInitially") { 30 | REQUIRE(0 == deco.rs.Length()); 31 | REQUIRE(1 == deco.rs.Runs()); 32 | REQUIRE(deco.Empty()); 33 | } 34 | 35 | SECTION("SimpleSpace") { 36 | deco.rs.InsertSpace(0, 1); 37 | REQUIRE(deco.Empty()); 38 | } 39 | 40 | SECTION("SimpleRun") { 41 | deco.rs.InsertSpace(0, 1); 42 | deco.rs.SetValueAt(0, 2); 43 | REQUIRE(!deco.Empty()); 44 | } 45 | } 46 | 47 | // Test DecorationList. 48 | 49 | TEST_CASE("DecorationList") { 50 | 51 | DecorationList decol; 52 | 53 | SECTION("HasCorrectIndicator") { 54 | decol.SetCurrentIndicator(indicator); 55 | REQUIRE(indicator == decol.GetCurrentIndicator()); 56 | } 57 | 58 | SECTION("HasCorrectCurrentValue") { 59 | const int value = 55; 60 | decol.SetCurrentValue(value); 61 | REQUIRE(value == decol.GetCurrentValue()); 62 | } 63 | 64 | SECTION("ExpandSetValues") { 65 | decol.SetCurrentIndicator(indicator); 66 | decol.InsertSpace(0, 9); 67 | const int value = 59; 68 | int position = 4; 69 | int fillLength = 3; 70 | bool changed = decol.FillRange(position, value, fillLength); 71 | REQUIRE(changed); 72 | REQUIRE(position == 4); 73 | REQUIRE(fillLength == 3); 74 | REQUIRE(fillLength == 3); 75 | REQUIRE(decol.ValueAt(indicator, 5) == value); 76 | REQUIRE(decol.AllOnFor(5) == (1 << indicator)); 77 | REQUIRE(decol.Start(indicator, 5) == 4); 78 | REQUIRE(decol.End(indicator, 5) == 7); 79 | const int indicatorB=6; 80 | decol.SetCurrentIndicator(indicatorB); 81 | changed = decol.FillRange(position, value, fillLength); 82 | REQUIRE(changed); 83 | REQUIRE(decol.AllOnFor(5) == ((1 << indicator) | (1 << indicatorB))); 84 | decol.DeleteRange(5, 1); 85 | REQUIRE(decol.Start(indicatorB, 5) == 4); 86 | REQUIRE(decol.End(indicatorB, 5) == 6); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /vendor/scintilla/test/unit/unitTest.cxx: -------------------------------------------------------------------------------- 1 | // Unit Tests for Scintilla internal data structures 2 | 3 | /* 4 | Currently tested: 5 | SplitVector 6 | Partitioning 7 | RunStyles 8 | ContractionState 9 | CharClassify 10 | Decoration 11 | DecorationList 12 | CellBuffer 13 | 14 | To do: 15 | PerLine * 16 | Range 17 | StyledText 18 | CaseFolder ... 19 | Document 20 | RESearch 21 | Selection 22 | UniConversion 23 | Style 24 | 25 | lexlib: 26 | Accessor 27 | LexAccessor 28 | CharacterSet 29 | OptionSet 30 | PropSetSimple 31 | StyleContext 32 | WordList 33 | */ 34 | 35 | #include 36 | #include 37 | 38 | #include "Platform.h" 39 | 40 | #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file 41 | #include "catch.hpp" 42 | 43 | // Needed for PLATFORM_ASSERT in code being tested 44 | 45 | void Platform::Assert(const char *c, const char *file, int line) { 46 | fprintf(stderr, "Assertion [%s] failed at %s %d\n", c, file, line); 47 | abort(); 48 | } 49 | 50 | void Platform::DebugPrintf(const char *format, ...) { 51 | char buffer[2000]; 52 | va_list pArguments; 53 | va_start(pArguments, format); 54 | vsprintf(buffer, format, pArguments); 55 | va_end(pArguments); 56 | fprintf(stderr, "%s", buffer); 57 | } 58 | -------------------------------------------------------------------------------- /vendor/scintilla/win32/CheckD2D.cxx: -------------------------------------------------------------------------------- 1 | // This file is compiled to check whether Direct2D and DirectWrite headers are available. 2 | #include 3 | #include 4 | -------------------------------------------------------------------------------- /vendor/scintilla/win32/PlatWin.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file PlatWin.h 3 | ** Implementation of platform facilities on Windows. 4 | **/ 5 | // Copyright 1998-2011 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef PLATWIN_H 9 | #define PLATWIN_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | 15 | extern bool IsNT(); 16 | extern void Platform_Initialise(void *hInstance); 17 | extern void Platform_Finalise(bool fromDllMain); 18 | 19 | #if defined(USE_D2D) 20 | extern bool LoadD2D(); 21 | extern ID2D1Factory *pD2DFactory; 22 | extern IDWriteFactory *pIDWriteFactory; 23 | #endif 24 | 25 | #ifdef SCI_NAMESPACE 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /vendor/scintilla/win32/ScintRes.rc: -------------------------------------------------------------------------------- 1 | // Resource file for Scintilla 2 | // Copyright 1998-2010 by Neil Hodgson 3 | // The License.txt file describes the conditions under which this software may be distributed. 4 | 5 | #include 6 | 7 | #define VERSION_SCINTILLA "3.5.2" 8 | #define VERSION_WORDS 3, 5, 2, 0 9 | 10 | VS_VERSION_INFO VERSIONINFO 11 | FILEVERSION VERSION_WORDS 12 | PRODUCTVERSION VERSION_WORDS 13 | FILEFLAGSMASK 0x3fL 14 | FILEFLAGS 0 15 | FILEOS VOS_NT_WINDOWS32 16 | FILETYPE VFT_APP 17 | FILESUBTYPE VFT2_UNKNOWN 18 | BEGIN 19 | BLOCK "VarFileInfo" 20 | BEGIN 21 | VALUE "Translation", 0x409, 1200 22 | END 23 | BLOCK "StringFileInfo" 24 | BEGIN 25 | BLOCK "040904b0" 26 | BEGIN 27 | VALUE "CompanyName", "Neil Hodgson neilh@scintilla.org\0" 28 | VALUE "FileDescription", "Scintilla.DLL - a Source Editing Component\0" 29 | VALUE "FileVersion", VERSION_SCINTILLA "\0" 30 | VALUE "InternalName", "Scintilla\0" 31 | VALUE "LegalCopyright", "Copyright 1998-2012 by Neil Hodgson\0" 32 | VALUE "OriginalFilename", "Scintilla.DLL\0" 33 | VALUE "ProductName", "Scintilla\0" 34 | VALUE "ProductVersion", VERSION_SCINTILLA "\0" 35 | END 36 | END 37 | END 38 | -------------------------------------------------------------------------------- /www/.gitignore: -------------------------------------------------------------------------------- 1 | *.wasm 2 | *.a 3 | *.o 4 | -------------------------------------------------------------------------------- /www/application.ztt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <? try output.writeAll(context.display_name); ?> 7 | 8 | 30 | 31 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | --------------------------------------------------------------------------------