├── .gitignore ├── Applications ├── Fragaria Complex │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Features.xib │ ├── FeaturesWindowController.h │ ├── FeaturesWindowController.m │ ├── Info.plist │ ├── Lorem.html │ ├── MainMenu.xib │ └── main.m ├── Fragaria Doc │ ├── ApplicationDelegate.h │ ├── ApplicationDelegate.m │ ├── Info.plist │ ├── MainMenu-Document.xib │ ├── MyDocument.h │ ├── MyDocument.m │ ├── MyDocument.xib │ └── main.m ├── Fragaria Prefs │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Info.plist │ ├── MGSSampleBreakpointDelegate.h │ ├── MGSSampleBreakpointDelegate.m │ ├── MainMenu.xib │ ├── README.html │ └── main.m ├── Fragaria Simple │ ├── ExampleCustomParser.h │ ├── ExampleCustomParser.m │ ├── ExampleCustomParserWithComposition.h │ ├── ExampleCustomParserWithComposition.m │ ├── FragariaAppDelegate.h │ ├── FragariaAppDelegate.m │ ├── Info.plist │ ├── MGSSimpleBreakpointDelegate.h │ ├── MGSSimpleBreakpointDelegate.m │ ├── MainMenu.xib │ ├── example.txt │ └── main.m ├── Fragaria Swift │ ├── AppDelegate.swift │ ├── Document.swift │ ├── Document.xib │ ├── Fragaria-Swift-Bridging-Header.h │ ├── Info.plist │ └── MainMenu.xib └── MASPreferences │ ├── LICENSE.md │ ├── MASPreferencesViewController.h │ ├── MASPreferencesWindow.xib │ ├── MASPreferencesWindowController.h │ ├── MASPreferencesWindowController.m │ └── README.md ├── ChangeLog.md ├── Doxygen └── Doxyfile ├── Fragaria.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── Fragaria.xcscheme │ └── FragariaDefaultsCoordinator.xcscheme ├── Fragaria ├── Additional Syntax Definitions │ ├── actionscript.plist │ ├── actionscript3.plist │ ├── active4d.plist │ ├── ada.plist │ ├── ampl.plist │ ├── apache.plist │ ├── apex.plist │ ├── applescript.plist │ ├── asm-m68k.plist │ ├── asm-mips.plist │ ├── asm-x86.plist │ ├── asp-js.plist │ ├── asp-vb.plist │ ├── aspdotnet-cs.plist │ ├── aspdotnet-vb.plist │ ├── awk.plist │ ├── batch.plist │ ├── c.plist │ ├── cobol.plist │ ├── coffeescript.plist │ ├── coldfusion.plist │ ├── cpp.plist │ ├── csharp.plist │ ├── csound.plist │ ├── css.plist │ ├── d.plist │ ├── dylan.plist │ ├── eiffel.plist │ ├── erl.plist │ ├── eztpl.plist │ ├── f-script.plist │ ├── fortran.plist │ ├── freefem.plist │ ├── gedcom.plist │ ├── gnuassembler.plist │ ├── graphviz.plist │ ├── haskell.plist │ ├── header.plist │ ├── html.plist │ ├── idl.plist │ ├── java.plist │ ├── javafx.plist │ ├── javascript.plist │ ├── jsp.plist │ ├── latex.plist │ ├── lilypond.plist │ ├── lisp.plist │ ├── logtalk.plist │ ├── lsl.plist │ ├── lua.plist │ ├── markdown.plist │ ├── matlab.plist │ ├── mel.plist │ ├── metapost.plist │ ├── metaslang.plist │ ├── mysql.plist │ ├── nemerle.plist │ ├── nrnhoc.plist │ ├── objectivec.plist │ ├── objectivecaml.plist │ ├── ox.plist │ ├── pascal.plist │ ├── pdf.plist │ ├── perl.plist │ ├── php.plist │ ├── plist.plist │ ├── postscript.plist │ ├── prolog.plist │ ├── python.plist │ ├── r.plist │ ├── rhtml.plist │ ├── ruby.plist │ ├── scala.plist │ ├── sgml.plist │ ├── shell.plist │ ├── sml.plist │ ├── sql.plist │ ├── stata.plist │ ├── supercollider.plist │ ├── tcltk.plist │ ├── torquescript.plist │ ├── udo.plist │ ├── vb.plist │ ├── verilog.plist │ ├── vhdl.plist │ └── xml.plist ├── Base.lproj │ ├── MGSContextMenu.xib │ ├── SMLDetab.xib │ ├── SMLEntab.xib │ └── SMLGoToLine.xib ├── Colour Schemes │ ├── Classic Fragaria.plist │ ├── Midnight.plist │ ├── Solarized Dark.plist │ └── Solarized Light.plist ├── Fragaria.h ├── FragariaMacros.h ├── FragariaUtilities.h ├── FragariaUtilities.m ├── Images.xcassets │ ├── Attribute.colorset │ │ └── Contents.json │ ├── AutoComplete.colorset │ │ └── Contents.json │ ├── Command.colorset │ │ └── Contents.json │ ├── Comment.colorset │ │ └── Contents.json │ ├── Contents.json │ ├── DefaultErrorHighlighting.colorset │ │ └── Contents.json │ ├── Instruction.colorset │ │ └── Contents.json │ ├── KeyCurrentLineHighlight.colorset │ │ └── Contents.json │ ├── Keyword.colorset │ │ └── Contents.json │ ├── Number.colorset │ │ └── Contents.json │ ├── String.colorset │ │ └── Contents.json │ ├── TextInvisibleCharacters.colorset │ │ └── Contents.json │ ├── Variable.colorset │ │ └── Contents.json │ ├── messagesAccess.imageset │ │ ├── Contents.json │ │ └── messagesAccess.pdf │ ├── messagesConfig.imageset │ │ ├── Contents.json │ │ └── messagesConfig.pdf │ ├── messagesDocument.imageset │ │ ├── Contents.json │ │ └── messagesDocument.pdf │ ├── messagesError.imageset │ │ ├── Contents.json │ │ └── messagesError.pdf │ ├── messagesInfo.imageset │ │ ├── Contents.json │ │ └── messagesInfo.pdf │ ├── messagesPanic.imageset │ │ ├── Contents.json │ │ └── messagesPanic.pdf │ └── messagesWarning.imageset │ │ ├── Contents.json │ │ └── messagesWarning.pdf ├── Info.plist ├── Integrated Syntax Definitions │ └── none.plist ├── Localizable.strings ├── MGSAbstractSyntaxColouring.h ├── MGSAbstractSyntaxColouring.m ├── MGSAttributeOverlayTextStorage.h ├── MGSAttributeOverlayTextStorage.m ├── MGSAutoCompleteDelegate.h ├── MGSBreakpointDelegate.h ├── MGSClassicFragariaParserFactory.h ├── MGSClassicFragariaParserFactory.m ├── MGSClassicFragariaSyntaxDefinition.h ├── MGSClassicFragariaSyntaxDefinition.m ├── MGSClassicFragariaSyntaxParser.h ├── MGSClassicFragariaSyntaxParser.m ├── MGSColourScheme.h ├── MGSColourScheme.m ├── MGSColourSchemePrivate.h ├── MGSColourToPlainTextTransformer.h ├── MGSColourToPlainTextTransformer.m ├── MGSDragOperationDelegate.h ├── MGSExtraInterfaceController.h ├── MGSExtraInterfaceController.m ├── MGSFragariaTextViewDelegate.h ├── MGSFragariaView.h ├── MGSFragariaView.m ├── MGSFragariaViewPrivate.h ├── MGSLayoutManager.h ├── MGSLayoutManager.m ├── MGSLineNumberView.h ├── MGSLineNumberView.m ├── MGSLineNumberViewDecoration.h ├── MGSMutableColourScheme.h ├── MGSMutableColourScheme.m ├── MGSMutableColourSchemeFromPlistTransformer.h ├── MGSMutableColourSchemeFromPlistTransformer.m ├── MGSMutableSubstring.h ├── MGSMutableSubstring.m ├── MGSParserFactory.h ├── MGSRangeEntries.h ├── MGSRangeEntries.m ├── MGSStandardParser.h ├── MGSStandardParser.m ├── MGSSyntaxAwareEditor.h ├── MGSSyntaxColouring.h ├── MGSSyntaxColouring.m ├── MGSSyntaxController.h ├── MGSSyntaxController.m ├── MGSSyntaxError.h ├── MGSSyntaxError.m ├── MGSSyntaxErrorController.h ├── MGSSyntaxErrorController.m ├── MGSSyntaxParser.h ├── MGSSyntaxParser.m ├── MGSSyntaxParserClient.h ├── MGSTextView+MGSDragging.h ├── MGSTextView+MGSDragging.m ├── MGSTextView+MGSTextActions.h ├── MGSTextView+MGSTextActions.m ├── MGSTextView.h ├── MGSTextView.m ├── MGSTextViewPrivate.h ├── NSCharacterSet+Fragaria.h ├── NSCharacterSet+Fragaria.m ├── NSColor+TransformedCompare.h ├── NSColor+TransformedCompare.m ├── NSObject+Fragaria.h ├── NSObject+Fragaria.m ├── NSScanner+Fragaria.h ├── NSScanner+Fragaria.m ├── NSSet+Fragaria.h ├── NSSet+Fragaria.m ├── NSString+Fragaria.h ├── NSString+Fragaria.m ├── NSTextStorage+Fragaria.h ├── NSTextStorage+Fragaria.m ├── en-GB.lproj │ ├── Localizable.strings │ ├── MGSContextMenu.xib │ ├── SMLDetab.xib │ ├── SMLEntab.xib │ ├── SMLGoToLine.xib │ └── SyntaxGroupNames.strings └── en.lproj │ ├── Localizable.strings │ └── SyntaxGroupNames.strings ├── FragariaDefaultsCoordinator ├── Base.lproj │ ├── MGSColourSchemeSave.xib │ ├── MGSPrefsColourProperties.xib │ ├── MGSPrefsCommonViews.xib │ └── MGSPrefsEditorProperties.xib ├── FragariaDefaultsCoordinator.h ├── Images.xcassets │ ├── Contents.json │ ├── MGSBold.imageset │ │ ├── Contents.json │ │ └── bold.pdf │ ├── MGSItalic.imageset │ │ ├── Contents.json │ │ └── italic.pdf │ └── MGSUnderline.imageset │ │ ├── Contents.json │ │ └── underline.pdf ├── Info.plist ├── MGSBoolToColourTransformer.h ├── MGSBoolToColourTransformer.m ├── MGSBoolToGlobalHintTransformer.h ├── MGSBoolToGlobalHintTransformer.m ├── MGSColourSchemeListController.h ├── MGSColourSchemeListController.m ├── MGSColourSchemeSaveController.h ├── MGSColourSchemeSaveController.m ├── MGSColourSchemeTableCellView.xib ├── MGSColourSchemeTableViewDataSource.h ├── MGSColourSchemeTableViewDataSource.m ├── MGSFontWell.h ├── MGSFontWell.m ├── MGSFragariaView+Definitions.h ├── MGSFragariaView+Definitions.m ├── MGSHybridUserDefaultsController.h ├── MGSHybridUserDefaultsController.m ├── MGSPreferencesProxyDictionary.h ├── MGSPreferencesProxyDictionary.m ├── MGSPrefsColourPropertiesViewController.h ├── MGSPrefsColourPropertiesViewController.m ├── MGSPrefsEditorPropertiesViewController.h ├── MGSPrefsEditorPropertiesViewController.m ├── MGSPrefsViewController.h ├── MGSPrefsViewController.m ├── MGSUserDefaults.h ├── MGSUserDefaults.m ├── MGSUserDefaultsController.h ├── MGSUserDefaultsController.m ├── MGSUserDefaultsControllerProtocol.h ├── MGSUserDefaultsDelegate.h ├── en-GB.lproj │ └── Localizable.strings └── en.lproj │ └── Localizable.strings ├── FragariaDefaultsCoordinatorTests ├── Info.plist ├── MGSPrefsViewControllerTests.m ├── MGSUserDefaultsControllerTests.m ├── MGSUserDefaultsDefinitionsTests.m ├── MGSUserDefaultsTests.m ├── MGSUserDefaultsUtilities.h └── MGSUserDefaultsUtilities.m ├── FragariaTests ├── ColorSchemeTestCases │ ├── ColorScheme_NotAPlist.rtf │ ├── ColorScheme_WrongRootObject.plist │ ├── ColorScheme_WrongType1.plist │ ├── ColorScheme_WrongType2.plist │ └── ColorScheme_WrongType3.plist ├── HighlightingTestSamples │ ├── actionscript3_1.as │ ├── ampl_1.mod │ ├── apex_class_1.apex │ ├── apex_trigger_1.apex │ ├── asm-x86_1.asm-nasm │ ├── asm-x86_2.asm │ ├── asp-vb_1.asp │ ├── awk_1.awk │ ├── batch_1.bat │ ├── c_1.c │ ├── coffeescript_1.coffee │ ├── coldfusion_1.cfm │ ├── cpp_1.cpp │ ├── cpp_2.cpp │ ├── csharp_1.cs │ ├── csound_1.csd │ ├── css_1.css │ ├── css_2.css │ ├── d_1.d │ ├── eiffel_1.e │ ├── erl_1.erl │ ├── erl_2.erl │ ├── fortran_1.f90 │ ├── fortran_2.f90 │ ├── haskell_1.hs │ ├── haskell_2.hs │ ├── html_1.html │ ├── java_1.java │ ├── javascript_1.js │ ├── javascript_2.js │ ├── jsp_1.jsp │ ├── jsp_2.jsp │ ├── latex_1.tex │ ├── latex_2.tex │ ├── lilypond_1.ly │ ├── lisp_1.scheme │ ├── lisp_2.lisp │ ├── lisp_3.lisp │ ├── lua_1.lua │ ├── markdown_1.md │ ├── matlab_1.m │ ├── matlab_2.matlab │ ├── mel_1.mel │ ├── objectivec_1.m │ ├── objectivecaml_1.ml │ ├── objectivecaml_2.ml │ ├── pascal_1.pas │ ├── perl_1.pl │ ├── perl_2.pl │ ├── php_1.php │ ├── php_2.php │ ├── prolog_1.plg │ ├── python_1.py │ ├── r_1.r │ ├── rhtml_1.Rhtml │ ├── ruby_1.rb │ ├── ruby_2.rb │ ├── scala_1.scala │ ├── shell_1.sh │ ├── shell_2.sh │ ├── sql_1.sql │ ├── stata_1.do │ ├── tcltk_1.tcl │ ├── tcltk_2.tcl │ ├── vb_1.vbs │ ├── verilog_1.v │ ├── vhdl_1.vhd │ ├── xml_1.xml │ └── xml_2.xml ├── Info.plist ├── MGSAttributeOverlayTextStorageTest.m ├── MGSColourSchemeTests.m ├── MGSColourToPlainTextTransformerTests.m ├── MGSFragariaRowColumnFunctionsTests.m ├── MGSFragariaViewTests.m ├── MGSLineNumberCacheTests.m ├── MGSLineRangeForCharacterTests.m ├── MGSStringColumnTests.m ├── MGSSyntaxControllerTests.m ├── MGSSyntaxErrorControllerTests.m ├── MGSSyntaxErrorTests.m └── MGSTextViewTests.m ├── LICENSE-2.0.txt ├── README.md └── TODO.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata/ 14 | profile 15 | *.moved-aside 16 | 17 | ## Ignore incredibly annoying .DS_Store files 18 | .DS_Store 19 | 20 | ## IDE 21 | .idea 22 | 23 | ## Generated Documentation 24 | AppleDoc 25 | Jazzy 26 | Doxygen/html 27 | Doxygen/latex 28 | -------------------------------------------------------------------------------- /Applications/Fragaria Complex/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MGSFragariaView Demo 4 | // 5 | // Created by Jim Derry on 2015/02/07. 6 | // 7 | // A playground and demonstration for MGSFragariaView, and 8 | // Fragaria and Smulton in general. 9 | // 10 | 11 | #import 12 | #import 13 | 14 | 15 | 16 | @interface AppDelegate : NSObject 17 | 18 | @end 19 | 20 | -------------------------------------------------------------------------------- /Applications/Fragaria Complex/FeaturesWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FeaturesWindowController.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 2/26/15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @class MGSFragariaView; 12 | 13 | 14 | @interface FeaturesWindowController : NSWindowController 15 | 16 | 17 | @property (nonatomic,weak) MGSFragariaView *viewTop; 18 | 19 | @property (nonatomic,weak) MGSFragariaView *viewBottom; 20 | 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Applications/Fragaria Complex/FeaturesWindowController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FeaturesWindowController.m 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 2/26/15. 6 | // 7 | // 8 | 9 | #import "FeaturesWindowController.h" 10 | #import 11 | 12 | @interface FeaturesWindowController () 13 | 14 | @end 15 | 16 | @implementation FeaturesWindowController 17 | 18 | 19 | - (void)windowDidLoad { 20 | [super windowDidLoad]; 21 | 22 | // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. 23 | } 24 | 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Applications/Fragaria Complex/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Applications/Fragaria Complex/Lorem.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Hello, world

9 |

This is a sample file. Note that the syntaxDefinitionName has been set in the NIB using User Defined Runtime Attributes

10 |

The lower text editor simply copies the text from the upper editor. It's set for CSS in code so it doesn't look as pretty.

11 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam lacinia lorem in orci facilisis bibendum. Sed ut libero vestibulum ante maximus pellentesque. Mauris ac quam semper, pulvinar lacus id, consectetur massa. Donec ut ex orci. Aliquam elementum enim vitae molestie aliquet. Quisque ac volutpat orci. Ut at varius velit, sed accumsan quam. Sed non rutrum tellus. Aliquam lobortis mollis augue consequat consectetur. Proin sagittis orci vitae velit viverra tincidunt. Integer efficitur est felis, fermentum eleifend mauris tempus at. Proin varius pharetra felis, non congue mauris ultrices sit amet. Nam ornare erat dui, ut interdum massa tempor non. Maecenas molestie felis et magna lobortis, et finibus nisl molestie.

12 |

Sed gravida vestibulum mollis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce quis feugiat libero. Morbi nisi massa, ornare vel dapibus a, pulvinar quis nisi. Fusce vulputate convallis ligula eget consequat. Vestibulum tortor orci, accumsan nec ex in, tempor iaculis diam. Mauris vel consectetur lacus, ac pretium augue. Duis sagittis lacus mauris, ut interdum ex scelerisque non. Duis sit amet dictum arcu. Nulla eu metus vel diam lacinia viverra vel et nisl. Curabitur felis orci, convallis non magna eu, convallis interdum est. Aliquam erat volutpat. Aliquam feugiat accumsan hendrerit. Aenean nec posuere eros.

13 | 14 | 15 | -------------------------------------------------------------------------------- /Applications/Fragaria Complex/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MGSFragariaView 4 | // 5 | // Created by Jim Derry on 2/7/15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /Applications/Fragaria Doc/ApplicationDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ApplicationDelegate.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 30/05/15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface ApplicationDelegate : NSObject 13 | 14 | 15 | - (IBAction)openPreferences:(id)sender; 16 | 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Applications/Fragaria Doc/ApplicationDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // ApplicationDelegate.m 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 30/05/15. 6 | // 7 | // 8 | 9 | #import "ApplicationDelegate.h" 10 | #import 11 | #import 12 | #import "MASPreferencesWindowController.h" 13 | 14 | 15 | @implementation ApplicationDelegate { 16 | MASPreferencesWindowController *prefsWindow; 17 | } 18 | 19 | 20 | - (void)applicationWillFinishLaunching:(NSNotification *)aNotification 21 | { 22 | MGSUserDefaultsController *shc; 23 | NSMutableSet *tmp; 24 | 25 | shc = [MGSUserDefaultsController sharedController]; 26 | 27 | tmp = [[shc managedProperties] mutableCopy]; 28 | [tmp removeObject:MGSFragariaDefaultsSyntaxDefinitionName]; 29 | [shc setManagedProperties:tmp]; 30 | 31 | [shc setPersistent:YES]; 32 | } 33 | 34 | 35 | - (IBAction)openPreferences:(id)sender 36 | { 37 | NSArray *c; 38 | NSViewController *color, *editor; 39 | 40 | if (!prefsWindow) { 41 | color = [[MGSPrefsColourPropertiesViewController alloc] init]; 42 | editor = [[MGSPrefsEditorPropertiesViewController alloc] init]; 43 | c = @[color, editor]; 44 | prefsWindow = [[MASPreferencesWindowController alloc] initWithViewControllers:c]; 45 | } 46 | [prefsWindow showWindow:self]; 47 | } 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Applications/Fragaria Doc/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeExtensions 11 | 12 | CFBundleTypeIconFile 13 | 14 | CFBundleTypeName 15 | 16 | CFBundleTypeRole 17 | Editor 18 | LSItemContentTypes 19 | 20 | public.data 21 | 22 | NSDocumentClass 23 | MyDocument 24 | 25 | 26 | CFBundleExecutable 27 | ${EXECUTABLE_NAME} 28 | CFBundleIconFile 29 | 30 | CFBundleIdentifier 31 | $(PRODUCT_BUNDLE_IDENTIFIER) 32 | CFBundleInfoDictionaryVersion 33 | 6.0 34 | CFBundleName 35 | ${PRODUCT_NAME} 36 | CFBundlePackageType 37 | APPL 38 | CFBundleShortVersionString 39 | 1 40 | CFBundleSignature 41 | ???? 42 | CFBundleVersion 43 | 1 44 | LSMinimumSystemVersion 45 | ${MACOSX_DEPLOYMENT_TARGET} 46 | NSMainNibFile 47 | MainMenu-Document 48 | NSPrincipalClass 49 | NSApplication 50 | 51 | 52 | -------------------------------------------------------------------------------- /Applications/Fragaria Doc/MyDocument.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyDocument.h 3 | // Fragaria Document 4 | // 5 | // Created by Jonathan on 24/07/2010. 6 | // Copyright 2010 mugginsoft.com. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import 12 | 13 | 14 | @class MGSFragariaView; 15 | 16 | @interface MyDocument : NSDocument 17 | 18 | @property (nonatomic,assign) NSString *syntaxDefinition; 19 | @property NSTextStorage *contents; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Applications/Fragaria Doc/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 30/04/2010. 6 | // Copyright 2010 mugginsoft.com. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /Applications/Fragaria Prefs/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MGSFragariaView Demo 4 | // 5 | // Created by Jim Derry on 2015/03/15. 6 | // 7 | // A playground and demonstration for MGSFragariaView and the new-style 8 | // preferences panels. 9 | // 10 | // 11 | 12 | #import 13 | #import 14 | 15 | 16 | /** 17 | * This application delegate serves as the main delegate and application 18 | * controller for the MGSFragariaViewModern application target. It demos 19 | * most of the major features provided by MGSFragariaView. 20 | **/ 21 | @interface AppDelegate : NSObject 22 | 23 | @property (nonatomic, assign, readonly) NSArray *availableSyntaxDefinitions; 24 | 25 | @end 26 | 27 | -------------------------------------------------------------------------------- /Applications/Fragaria Prefs/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Applications/Fragaria Prefs/MGSSampleBreakpointDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSSimpleBreakpointDelegate.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 29/01/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | /** 14 | * This class serves as an example on how to use an external delegate class 15 | * with MGSFragariaView. 16 | **/ 17 | @interface MGSSampleBreakpointDelegate : NSObject { 18 | NSMutableIndexSet *breakpoints; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Applications/Fragaria Prefs/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MGSFragariaViewModern 4 | // 5 | // Created by Jim Derry on 3/15/15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /Applications/Fragaria Simple/ExampleCustomParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleCustomParser.h 3 | // Fragaria Simple 4 | // 5 | // Created by Daniele Cattaneo on 28/12/2018. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | /* This is the simplest use-case for custom parsers: a single standalone 13 | * parser with a single factory that exports just that parser. 14 | * In this case, the parser factory can be made the same object as the 15 | * parser itself. 16 | * 17 | * If we want to share the same parser for multiple syntax definitions, 18 | * it is better to have a separate parser class, whose state is set 19 | * depending on the language, and a single parser factory which 20 | * initializes each parser according to the language. 21 | * See the implementation of MGSClassicFragariaParserFactory for an 22 | * example of this use case. */ 23 | 24 | @interface ExampleCustomParser : MGSSyntaxParser 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Applications/Fragaria Simple/ExampleCustomParser.m: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleCustomParser.m 3 | // Fragaria Simple 4 | // 5 | // Created by Daniele Cattaneo on 28/12/2018. 6 | // 7 | 8 | #import "ExampleCustomParser.h" 9 | 10 | 11 | @implementation ExampleCustomParser 12 | 13 | 14 | - (NSArray *)syntaxDefinitionNames 15 | { 16 | return @[@"Example Custom Parser"]; 17 | } 18 | 19 | 20 | - (nonnull MGSSyntaxParser *)parserForSyntaxDefinitionName:(nonnull NSString *)syndef 21 | { 22 | return self; 23 | } 24 | 25 | 26 | - (NSRange)parseForClient:(id)client 27 | { 28 | NSString *string = client.stringToParse; 29 | NSRange realRange = [client resetTokenGroupsInRange:client.rangeToParse]; 30 | 31 | /* Color as an instruction every word starting with an uppercase letter */ 32 | NSCharacterSet *uppercase = [NSCharacterSet uppercaseLetterCharacterSet]; 33 | [string enumerateSubstringsInRange:realRange options:NSStringEnumerationByWords usingBlock: 34 | ^(NSString * _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOL * _Nonnull stop) { 35 | if ([substring length] > 0 && [uppercase characterIsMember:[substring characterAtIndex:0]]) { 36 | [client setGroup:MGSSyntaxGroupInstruction forTokenInRange:substringRange atomic:YES]; 37 | } 38 | }]; 39 | 40 | return realRange; 41 | } 42 | 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Applications/Fragaria Simple/ExampleCustomParserWithComposition.h: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleCustomParserWithComposition.h 3 | // Fragaria Simple 4 | // 5 | // Created by Daniele Cattaneo on 28/12/2018. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | /* This parser modifies the output of an existing parser (specifically, the 13 | * standard Fragaria Objective-C parser), similarly to what could previously 14 | * be done through SMLSyntaxColouringDelegate. */ 15 | 16 | @interface ExampleCustomParserWithComposition : MGSSyntaxParser 17 | 18 | @end 19 | 20 | NS_ASSUME_NONNULL_END 21 | -------------------------------------------------------------------------------- /Applications/Fragaria Simple/ExampleCustomParserWithComposition.m: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleCustomParserWithComposition.m 3 | // Fragaria Simple 4 | // 5 | // Created by Daniele Cattaneo on 28/12/2018. 6 | // 7 | 8 | #import "ExampleCustomParserWithComposition.h" 9 | 10 | 11 | @implementation ExampleCustomParserWithComposition 12 | { 13 | MGSSyntaxParser *objcParser; 14 | } 15 | 16 | 17 | - (instancetype)init 18 | { 19 | self = [super init]; 20 | objcParser = [[MGSSyntaxController sharedInstance] parserForSyntaxDefinitionName:@"Objective-C"]; 21 | if (!objcParser) { 22 | NSLog(@"Where's my standard objc parser!?"); 23 | return nil; 24 | } 25 | return self; 26 | } 27 | 28 | 29 | - (NSArray *)syntaxDefinitionNames 30 | { 31 | return @[@"Objective-C Plus"]; 32 | } 33 | 34 | 35 | - (nonnull MGSSyntaxParser *)parserForSyntaxDefinitionName:(nonnull NSString *)syndef 36 | { 37 | /* Note that calling -parserForSyntaxDefinitionName: on [MGSSyntaxController sharedInstance] 38 | * inside the implementation of -parserForSyntaxDefinitionName: on a parser factory 39 | * is fully supported, as long as it does not cause a recursion 40 | * inside your parser factory code. */ 41 | return self; 42 | } 43 | 44 | 45 | - (NSRange)parseForClient:(id)client 46 | { 47 | /* Color as a command every word starting with NS */ 48 | NSRange realRange = [objcParser parseForClient:client]; 49 | 50 | [client.stringToParse enumerateSubstringsInRange:realRange options:NSStringEnumerationByWords usingBlock: 51 | ^(NSString * _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOL * _Nonnull stop) { 52 | /* Ignore whatever is inside a string */ 53 | NSString *g = [client groupOfTokenAtCharacterIndex:substringRange.location]; 54 | if ([MGSSyntaxGroupString isEqual:g]) 55 | return; 56 | 57 | if ([substring length] > 0 && [substring hasPrefix:@"NS"]) { 58 | [client setGroup:MGSSyntaxGroupCommand forTokenInRange:substringRange atomic:YES]; 59 | } 60 | }]; 61 | 62 | return realRange; 63 | } 64 | 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Applications/Fragaria Simple/FragariaAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // FragariaAppDelegate.h 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 30/04/2010. 6 | // Copyright 2010 mugginsoft.com. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class MGSTextView; 13 | @class MGSSimpleBreakpointDelegate; 14 | 15 | @interface FragariaAppDelegate : NSObject 16 | 17 | - (IBAction)copyToPasteBoard:(id)sender; 18 | - (IBAction)reloadString:(id)sender; 19 | 20 | @property (weak) IBOutlet NSWindow *window; 21 | 22 | @property (nonatomic,assign) NSString *syntaxDefinition; 23 | 24 | @property NSString *row; 25 | @property NSString *column; 26 | 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Applications/Fragaria Simple/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0.1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Applications/Fragaria Simple/MGSSimpleBreakpointDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSSimpleBreakpointDelegate.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 29/01/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | @interface MGSSimpleBreakpointDelegate : NSObject { 14 | NSMutableSet *breakpoints; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Applications/Fragaria Simple/MGSSimpleBreakpointDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSSimpleBreakpointDelegate.m 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 29/01/15. 6 | // 7 | // 8 | 9 | #import "MGSSimpleBreakpointDelegate.h" 10 | 11 | 12 | @implementation MGSSimpleBreakpointDelegate 13 | 14 | 15 | - (instancetype)init { 16 | self = [super init]; 17 | breakpoints = [[NSMutableSet alloc] init]; 18 | return self; 19 | } 20 | 21 | 22 | - (NSColor *)breakpointColourForLine:(NSUInteger)line ofFragaria:(MGSFragariaView *)sender 23 | { 24 | /* This is just a demo! A real app would have a more sophisticated way 25 | * of deciding a breakpoint's color. */ 26 | 27 | if (line % 2 == 0) 28 | /* Non-standard-color breakpoint */ 29 | return [NSColor orangeColor]; 30 | 31 | if (line % 3 == 0) 32 | /* Transparent breakpoint */ 33 | return [[NSColor greenColor] colorWithAlphaComponent:0.25]; 34 | 35 | /* Standard color breakpoint */ 36 | return nil; 37 | } 38 | 39 | 40 | - (void)toggleBreakpointForFragaria:(MGSFragariaView *)sender onLine:(NSUInteger)line { 41 | NSNumber *lineNumber; 42 | 43 | lineNumber = [NSNumber numberWithInteger:line]; 44 | if ([breakpoints containsObject:lineNumber]) 45 | [breakpoints removeObject:lineNumber]; 46 | else 47 | [breakpoints addObject:lineNumber]; 48 | } 49 | 50 | 51 | - (NSSet*)breakpointsForFragaria:(MGSFragariaView *)sender { 52 | return [breakpoints copy]; 53 | } 54 | 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Applications/Fragaria Simple/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 30/04/2010. 6 | // Copyright 2010 mugginsoft.com. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /Applications/Fragaria Swift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Fragaria Swift 4 | // 5 | // Created by Daniele Cattaneo on 04/12/15. 6 | // 7 | // 8 | 9 | import Cocoa 10 | import Fragaria 11 | import FragariaDefaultsCoordinator 12 | 13 | 14 | @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { 15 | 16 | 17 | var prefsWindow: MASPreferencesWindowController! 18 | 19 | 20 | func applicationWillFinishLaunching(_ aNotification: Notification) { 21 | let shc: MGSUserDefaultsController = MGSUserDefaultsController.shared() 22 | shc.managedProperties.remove(MGSFragariaDefaultsSyntaxDefinitionName) 23 | shc.isPersistent = true 24 | } 25 | 26 | 27 | @IBAction func openPreferences(_ sender: AnyObject) { 28 | if prefsWindow == nil { 29 | let color = MGSPrefsColourPropertiesViewController() 30 | let editor = MGSPrefsEditorPropertiesViewController() 31 | prefsWindow = MASPreferencesWindowController(viewControllers: [color, editor]) 32 | } 33 | prefsWindow.showWindow(self) 34 | } 35 | 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Applications/Fragaria Swift/Document.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Document.swift 3 | // Fragaria Swift 4 | // 5 | // Created by Daniele Cattaneo on 04/12/15. 6 | // 7 | // 8 | 9 | import Cocoa 10 | import Fragaria 11 | import FragariaDefaultsCoordinator 12 | 13 | 14 | class Document: NSDocument { 15 | 16 | 17 | @IBOutlet var fragaria: MGSFragariaView!; 18 | 19 | 20 | override init() { 21 | super.init() 22 | } 23 | 24 | 25 | override func windowControllerDidLoadNib(_ aController: NSWindowController) { 26 | super.windowControllerDidLoadNib(aController) 27 | fragaria.syntaxDefinitionName = "Objective-C" 28 | fragaria.isSyntaxColoured = true 29 | fragaria.showsLineNumbers = true 30 | fragaria.string = "// This is the future" 31 | self.undoManager = fragaria.undoManager 32 | MGSUserDefaultsController.shared().addFragaria(toManagedSet: fragaria) 33 | } 34 | 35 | 36 | deinit { 37 | MGSUserDefaultsController.shared().removeFragaria(fromManagedSet: fragaria) 38 | } 39 | 40 | 41 | override class var autosavesInPlace: Bool { 42 | return true 43 | } 44 | 45 | 46 | override var windowNibName: NSNib.Name? { 47 | return "Document" 48 | } 49 | 50 | 51 | override func data(ofType typeName: String) throws -> Data { 52 | throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil) 53 | } 54 | 55 | 56 | override func read(from data: Data, ofType typeName: String) throws { 57 | throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil) 58 | } 59 | 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Applications/Fragaria Swift/Fragaria-Swift-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Fragaria-Swift-Bridging-Header.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 05/12/15. 6 | // 7 | // 8 | 9 | #import "MASPreferencesWindowController.h" 10 | -------------------------------------------------------------------------------- /Applications/Fragaria Swift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeExtensions 11 | 12 | txt 13 | 14 | CFBundleTypeIconFile 15 | 16 | CFBundleTypeName 17 | DocumentType 18 | CFBundleTypeOSTypes 19 | 20 | ???? 21 | 22 | CFBundleTypeRole 23 | Editor 24 | NSDocumentClass 25 | $(PRODUCT_MODULE_NAME).Document 26 | 27 | 28 | CFBundleExecutable 29 | $(EXECUTABLE_NAME) 30 | CFBundleIconFile 31 | 32 | CFBundleIdentifier 33 | $(PRODUCT_BUNDLE_IDENTIFIER) 34 | CFBundleInfoDictionaryVersion 35 | 6.0 36 | CFBundleName 37 | $(PRODUCT_NAME) 38 | CFBundlePackageType 39 | APPL 40 | CFBundleShortVersionString 41 | 1.0 42 | CFBundleSignature 43 | ???? 44 | CFBundleVersion 45 | 1 46 | LSMinimumSystemVersion 47 | $(MACOSX_DEPLOYMENT_TARGET) 48 | NSMainNibFile 49 | MainMenu 50 | NSPrincipalClass 51 | NSApplication 52 | 53 | 54 | -------------------------------------------------------------------------------- /Applications/MASPreferences/LICENSE.md: -------------------------------------------------------------------------------- 1 | MASPreferences is licensed under the BSD license. -------------------------------------------------------------------------------- /Applications/MASPreferences/MASPreferencesViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Any controller providing preference pane view must support this protocol 3 | // 4 | 5 | #import 6 | 7 | @protocol MASPreferencesViewController 8 | 9 | @optional 10 | 11 | - (void)viewWillAppear; 12 | - (void)viewDidDisappear; 13 | - (NSView *)initialKeyView; 14 | 15 | @property (nonatomic, readonly) BOOL hasResizableWidth; 16 | @property (nonatomic, readonly) BOOL hasResizableHeight; 17 | 18 | @required 19 | 20 | @property (nonatomic, readonly) NSString *identifier; 21 | @property (nonatomic, readonly) NSImage *toolbarItemImage; 22 | @property (nonatomic, readonly) NSString *toolbarItemLabel; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Applications/MASPreferences/MASPreferencesWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // You create an application Preferences window using code like this: 3 | // _preferencesWindowController = [[MASPreferencesWindowController alloc] initWithViewControllers:controllers 4 | // title:title] 5 | // 6 | // To open the Preferences window: 7 | // [_preferencesWindowController showWindow:sender] 8 | // 9 | 10 | #import 11 | #import "MASPreferencesViewController.h" 12 | 13 | extern NSString *const kMASPreferencesWindowControllerDidChangeViewNotification; 14 | 15 | __attribute__((__visibility__("default"))) 16 | #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 17 | @interface MASPreferencesWindowController : NSWindowController 18 | #else 19 | @interface MASPreferencesWindowController : NSWindowController 20 | #endif 21 | { 22 | @private 23 | NSMutableArray *_viewControllers; 24 | NSMutableDictionary *_minimumViewRects; 25 | NSString *_title; 26 | NSViewController *_selectedViewController; 27 | IBOutlet NSToolbar *toolbar; 28 | } 29 | 30 | @property (nonatomic, readonly) NSMutableArray *viewControllers; 31 | @property (nonatomic, readonly) NSUInteger indexOfSelectedController; 32 | @property (nonatomic, readonly, retain) NSViewController *selectedViewController; 33 | @property (nonatomic, readonly) NSString *title; 34 | @property (nonatomic, assign) IBOutlet NSToolbar *toolbar; 35 | 36 | - (id)initWithViewControllers:(NSArray *)viewControllers; 37 | - (id)initWithViewControllers:(NSArray *)viewControllers title:(NSString *)title; 38 | - (void)addViewController:(NSViewController *) viewController; 39 | 40 | - (void)selectControllerAtIndex:(NSUInteger)controllerIndex; 41 | - (void)selectControllerWithIdentifier:(NSString *)identifier; 42 | 43 | - (IBAction)goNextTab:(id)sender; 44 | - (IBAction)goPreviousTab:(id)sender; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Applications/MASPreferences/README.md: -------------------------------------------------------------------------------- 1 | # MASPreferences 2 | 3 | This component is intended as a replacement for SS_PrefsController by Matt Legend Gemmell and Selectable Toolbar by Brandon Walkin. It is designed to use NSViewController subclasses for preference panes. 4 | 5 | # How to use 6 | 7 | You can find a Demo project at [MASPreferencesDemo](https://github.com/shpakovski/MASPreferencesDemo). -------------------------------------------------------------------------------- /Fragaria.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Fragaria/Additional Syntax Definitions/erl.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | 7 | endCommand 8 | 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | " 19 | secondString 20 | ' 21 | firstSingleLineComment 22 | % 23 | secondSingleLineComment 24 | % 25 | beginFirstMultiLineComment 26 | % 27 | endFirstMultiLineComment 28 | % 29 | beginSecondMultiLineComment 30 | % 31 | endSecondMultiLineComment 32 | % 33 | functionDefinition 34 | ^[a-z]+.*\(.*\)\s*-> 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | module 44 | include 45 | compile 46 | author 47 | vsn 48 | behavior 49 | behaviour 50 | define 51 | record 52 | after 53 | and 54 | andalso 55 | band 56 | begin 57 | bnot 58 | bor 59 | bsi 60 | bsr 61 | case 62 | catch 63 | cond 64 | div 65 | end 66 | fun 67 | if 68 | let 69 | not 70 | of 71 | or 72 | orelse 73 | query 74 | receive 75 | rem 76 | try 77 | when 78 | xor 79 | 80 | autocompleteWords 81 | 82 | name 83 | Erlang 84 | extensions 85 | erl hrl 86 | 87 | 88 | -------------------------------------------------------------------------------- /Fragaria/Additional Syntax Definitions/latex.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | { 7 | endCommand 8 | } 9 | beginInstruction 10 | [ 11 | endInstruction 12 | ] 13 | beginVariable 14 | \ 15 | endVariable 16 | {}()[],?.;/:+=><~ 17 | firstString 18 | $ 19 | secondString 20 | 21 | firstSingleLineComment 22 | % 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | 27 | endFirstMultiLineComment 28 | 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | \\((sub)*section|part|chapter|paragraph){[^}]*} 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | \begin{document} 44 | \end{document} 45 | 46 | autocompleteWords 47 | 48 | name 49 | LaTeX 50 | extensions 51 | tex 52 | groupSpecialization 53 | 54 | variable 55 | instruction 56 | command 57 | instruction.parameter.tex 58 | instruction 59 | instruction.parameter.tex 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Fragaria/Additional Syntax Definitions/markdown.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | autocompleteWords 6 | 7 | beginCommand 8 | < 9 | beginFirstMultiLineComment 10 | 11 | beginInstruction 12 | [ 13 | beginSecondMultiLineComment 14 | 15 | beginVariable 16 | 17 | endCommand 18 | > 19 | endFirstMultiLineComment 20 | 21 | endInstruction 22 | ] 23 | endSecondMultiLineComment 24 | 25 | endVariable 26 | 27 | firstSingleLineComment 28 | 29 | firstString 30 | 31 | numberDefinition 32 | ^(\s?(=|-|\*\s|\+\s)*\n|((?<=>\s)|(?<!-))[0-9]+\.\s|\n?(?<![\*\+-])[\*\+-]{1}\s) 33 | keywords 34 | 35 | # 36 | ** 37 | 38 | keywordsCaseSensitive 39 | 40 | recolourKeywordIfAlreadyColoured 41 | 42 | removeFromFunction 43 | 44 | secondSingleLineComment 45 | 46 | secondString 47 | ` 48 | singleLineCommentRegex 49 | \n?\s?(?<![a-zA-Z0-9/])>\s 50 | variableRegex 51 | (\s(\*{1,2}([^*\s]*)\*\*?|_{1,2}([^_]*)__?)\s|[&#]([^;\s]*);) 52 | name 53 | Markdown 54 | extensions 55 | md 56 | groupSpecialization 57 | 58 | variable 59 | number.formatting.md 60 | keywords 61 | number.formatting.md 62 | number 63 | number.formatting.md 64 | instruction 65 | instruction.link.md 66 | command 67 | command.tag 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /Fragaria/Additional Syntax Definitions/pdf.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | 7 | endCommand 8 | 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | / 15 | endVariable 16 | ()><[]{}/% 17 | firstString 18 | 19 | secondString 20 | 21 | firstSingleLineComment 22 | % 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | 27 | endFirstMultiLineComment 28 | 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | endobj 44 | endstream 45 | f 46 | false 47 | n 48 | null 49 | obj 50 | R 51 | startxref 52 | stream 53 | trailer 54 | true 55 | xref 56 | 57 | autocompleteWords 58 | 59 | name 60 | PDF 61 | extensions 62 | pdf 63 | 64 | 65 | -------------------------------------------------------------------------------- /Fragaria/Additional Syntax Definitions/plist.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | < 7 | endCommand 8 | > 9 | beginInstruction 10 | <? 11 | endInstruction 12 | ?> 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | " 19 | secondString 20 | 21 | firstSingleLineComment 22 | 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | <!-- 27 | endFirstMultiLineComment 28 | --> 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | autocompleteWords 44 | 45 | key 46 | string 47 | real 48 | integer 49 | date 50 | true 51 | false 52 | data 53 | array 54 | dict 55 | 56 | name 57 | Plist 58 | extensions 59 | plist 60 | groupSpecialization 61 | 62 | command 63 | command.tag 64 | instruction 65 | command.scriptingDelimiter 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /Fragaria/Additional Syntax Definitions/sgml.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | < 7 | endCommand 8 | > 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | " 19 | secondString 20 | ' 21 | firstSingleLineComment 22 | 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | <!-- 27 | endFirstMultiLineComment 28 | --> 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | autocompleteWords 44 | 45 | name 46 | SGML 47 | extensions 48 | sgml 49 | groupSpecialization 50 | 51 | command 52 | command.tag 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Fragaria/Additional Syntax Definitions/shell.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | ` 7 | endCommand 8 | ´ 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | $ 15 | endVariable 16 | (){}=;:[] 17 | firstString 18 | " 19 | secondString 20 | ' 21 | firstSingleLineComment 22 | # 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | 27 | endFirstMultiLineComment 28 | 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | ^\s*(function)?\s?\w*(\(\))?\s?\n?\s*\{ 35 | removeFromFunction 36 | function 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | if 44 | then 45 | elif 46 | else 47 | fi 48 | case 49 | in 50 | ;; 51 | esac 52 | while 53 | for 54 | do 55 | done 56 | continue 57 | local 58 | return 59 | 60 | autocompleteWords 61 | 62 | name 63 | Shell 64 | extensions 65 | sh tool 66 | 67 | 68 | -------------------------------------------------------------------------------- /Fragaria/Additional Syntax Definitions/supercollider.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | 7 | endCommand 8 | 9 | beginInstruction 10 | | 11 | endInstruction 12 | | 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | " 19 | secondString 20 | ' 21 | firstSingleLineComment 22 | // 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | /* 27 | endFirstMultiLineComment 28 | */ 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | ^\s*.*\(.*\)\n?\s*\{ 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | and 44 | ar 45 | arg 46 | case 47 | classvar 48 | collect 49 | do 50 | dup 51 | false 52 | if 53 | inf 54 | kr 55 | new 56 | nil 57 | or 58 | protect 59 | switch 60 | this 61 | true 62 | super 63 | try 64 | var 65 | while 66 | 67 | autocompleteWords 68 | 69 | name 70 | SuperCollider 71 | extensions 72 | sc scd 73 | 74 | 75 | -------------------------------------------------------------------------------- /Fragaria/Additional Syntax Definitions/torquescript.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | autocompleteWords 6 | 7 | beginCommand 8 | 9 | beginFirstMultiLineComment 10 | /* 11 | beginInstruction 12 | 13 | beginSecondMultiLineComment 14 | 15 | beginVariable 16 | $% 17 | endCommand 18 | 19 | endFirstMultiLineComment 20 | */ 21 | endInstruction 22 | 23 | endSecondMultiLineComment 24 | 25 | endVariable 26 | ./*+-()=; 27 | firstSingleLineComment 28 | // 29 | firstString 30 | " 31 | functionDefinition 32 | ^\s*\w*function\s+.* 33 | keywords 34 | 35 | break 36 | case 37 | continue 38 | datablock 39 | default 40 | else 41 | function 42 | if 43 | for 44 | new 45 | or 46 | package 47 | return 48 | switch 49 | switch$ 50 | while 51 | yes 52 | no 53 | on 54 | off 55 | true 56 | false 57 | 58 | keywordsCaseSensitive 59 | 60 | recolourKeywordIfAlreadyColoured 61 | 62 | removeFromFunction 63 | function 64 | secondSingleLineComment 65 | 66 | secondString 67 | ' 68 | name 69 | TorqueScript 70 | extensions 71 | cs 72 | 73 | 74 | -------------------------------------------------------------------------------- /Fragaria/Additional Syntax Definitions/xml.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | < 7 | endCommand 8 | > 9 | beginInstruction 10 | <? 11 | endInstruction 12 | ?> 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | " 19 | secondString 20 | ' 21 | firstSingleLineComment 22 | 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | <!-- 27 | endFirstMultiLineComment 28 | --> 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | keywords 42 | 43 | CDATA 44 | EMPTY 45 | INCLUDE 46 | IGNORE 47 | NDATA 48 | #IMPLIED 49 | #PCDATA 50 | #REQUIRED 51 | 52 | autocompleteWords 53 | 54 | name 55 | XML 56 | extensions 57 | xml dtd xsd xsl 58 | groupSpecialization 59 | 60 | command 61 | command.tag 62 | instruction 63 | command.scriptingDelimiter 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Fragaria/Colour Schemes/Classic Fragaria.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | backgroundColor 6 | 1.000000 1.000000 1.000000 7 | colourForAttributes 8 | 0.500000 0.500000 0.200000 9 | colourForAutocomplete 10 | 0.840000 0.410000 0.006000 11 | colourForCommands 12 | 0.031000 0.000000 0.855000 13 | colourForComments 14 | 0.000000 0.450000 0.000000 15 | colourForInstructions 16 | 0.737000 0.000000 0.647000 17 | colourForKeywords 18 | 0.737000 0.000000 0.647000 19 | colourForNumbers 20 | 0.031000 0.000000 0.855000 21 | colourForStrings 22 | 0.804000 0.071000 0.153000 23 | colourForVariables 24 | 0.730000 0.000000 0.740000 25 | coloursAttributes 26 | 1 27 | coloursAutocomplete 28 | 0 29 | coloursCommands 30 | 1 31 | coloursComments 32 | 1 33 | coloursInstructions 34 | 1 35 | coloursKeywords 36 | 1 37 | coloursNumbers 38 | 1 39 | coloursStrings 40 | 1 41 | coloursVariables 42 | 1 43 | currentLineHighlightColour 44 | 0.960000 0.960000 0.710000 45 | defaultSyntaxErrorHighlightingColour 46 | 1.000000 1.000000 0.700000 47 | displayName 48 | Classic Fragaria 49 | insertionPointColor 50 | 0.000000 0.000000 0.000000 51 | textColor 52 | 0.000000 0.000000 0.000000 53 | textInvisibleCharactersColour 54 | 0.000000 0.000000 0.000000 55 | 56 | 57 | -------------------------------------------------------------------------------- /Fragaria/Colour Schemes/Midnight.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | backgroundColor 6 | 0.000000 0.000000 0.000000 7 | colourForAttributes 8 | 0.500000 0.500000 0.200000 9 | colourForAutocomplete 10 | 0.840000 0.410000 0.006000 11 | colourForCommands 12 | 0.031000 0.000000 0.855000 13 | colourForComments 14 | 0.254902 0.800000 0.270588 15 | colourForInstructions 16 | 0.737000 0.000000 0.647000 17 | colourForKeywords 18 | 0.827451 0.094118 0.580392 19 | colourForNumbers 20 | 0.466667 0.427451 1.000000 21 | colourForStrings 22 | 1.000000 0.172549 0.219608 23 | colourForVariables 24 | 0.730000 0.000000 0.740000 25 | coloursAttributes 26 | 1 27 | coloursAutocomplete 28 | 0 29 | coloursCommands 30 | 1 31 | coloursComments 32 | 1 33 | coloursInstructions 34 | 1 35 | coloursKeywords 36 | 1 37 | coloursNumbers 38 | 1 39 | coloursStrings 40 | 1 41 | coloursVariables 42 | 1 43 | currentLineHighlightColour 44 | 0.000000 0.000000 0.000000 45 | defaultSyntaxErrorHighlightingColour 46 | 0.400000 0.400000 0.400000 47 | displayName 48 | Midnight 49 | insertionPointColor 50 | 1.000000 1.000000 1.000000 51 | textColor 52 | 1.000000 1.000000 1.000000 53 | textInvisibleCharactersColour 54 | 0.905882 0.905882 0.905882 55 | 56 | 57 | -------------------------------------------------------------------------------- /Fragaria/Colour Schemes/Solarized Dark.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | backgroundColor 6 | 0.009374 0.126774 0.153473 7 | colourForAttributes 8 | 0.647465 0.467514 0.018687 9 | colourForAutocomplete 10 | 0.741762 0.213253 0.073530 11 | colourForCommands 12 | 0.127549 0.462659 0.782314 13 | colourForComments 14 | 0.276720 0.356660 0.382985 15 | colourForInstructions 16 | 0.777389 0.108025 0.435166 17 | colourForKeywords 18 | 0.777389 0.108025 0.435166 19 | colourForNumbers 20 | 0.127549 0.462659 0.782314 21 | colourForStrings 22 | 0.819270 0.108407 0.141457 23 | colourForVariables 24 | 0.647465 0.467514 0.018687 25 | coloursAttributes 26 | 1 27 | coloursAutocomplete 28 | 0 29 | coloursCommands 30 | 1 31 | coloursComments 32 | 1 33 | coloursInstructions 34 | 1 35 | coloursKeywords 36 | 1 37 | coloursNumbers 38 | 1 39 | coloursStrings 40 | 1 41 | coloursVariables 42 | 1 43 | currentLineHighlightColour 44 | 0.039381 0.160116 0.198333 45 | defaultSyntaxErrorHighlightingColour 46 | 0.198333 0.157088 0.078098 47 | displayName 48 | Solarized Dark 49 | insertionPointColor 50 | 0.505992 0.564858 0.563637 51 | textColor 52 | 0.440580 0.509629 0.516858 53 | textInvisibleCharactersColour 54 | 0.276720 0.356660 0.382985 55 | 56 | 57 | -------------------------------------------------------------------------------- /Fragaria/Colour Schemes/Solarized Light.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | backgroundColor 6 | 0.989434 0.957944 0.864060 7 | colourForAttributes 8 | 0.647465 0.467514 0.018687 9 | colourForAutocomplete 10 | 0.741762 0.213253 0.073530 11 | colourForCommands 12 | 0.127549 0.462659 0.782314 13 | colourForComments 14 | 0.505992 0.564858 0.563637 15 | colourForInstructions 16 | 0.777389 0.108025 0.435166 17 | colourForKeywords 18 | 0.777389 0.108025 0.435166 19 | colourForNumbers 20 | 0.127549 0.462659 0.782314 21 | colourForStrings 22 | 0.819270 0.108407 0.141457 23 | colourForVariables 24 | 0.647465 0.467514 0.018687 25 | coloursAttributes 26 | 1 27 | coloursAutocomplete 28 | 0 29 | coloursCommands 30 | 1 31 | coloursComments 32 | 1 33 | coloursInstructions 34 | 1 35 | coloursKeywords 36 | 1 37 | coloursNumbers 38 | 1 39 | coloursStrings 40 | 1 41 | coloursVariables 42 | 1 43 | currentLineHighlightColour 44 | 0.916111 0.890012 0.797811 45 | defaultSyntaxErrorHighlightingColour 46 | 0.989434 0.810012 0.594155 47 | displayName 48 | Solarized Light 49 | insertionPointColor 50 | 0.000000 0.000000 0.000000 51 | textColor 52 | 0.324366 0.407177 0.438506 53 | textInvisibleCharactersColour 54 | 0.505992 0.564858 0.563637 55 | 56 | 57 | -------------------------------------------------------------------------------- /Fragaria/Fragaria.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Fragaria.h 3 | * Fragaria 4 | * 5 | * Created by Jonathan on 30/04/2010. 6 | * Copyright 2010 mugginsoft.com. All rights reserved. 7 | * 8 | */ 9 | 10 | #undef FRAGARIA_PRIVATE 11 | #import 12 | #import 13 | 14 | #import 15 | #import 16 | #import 17 | #import 18 | 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | #import 31 | 32 | #import 33 | #import 34 | #import 35 | 36 | #import 37 | #import 38 | -------------------------------------------------------------------------------- /Fragaria/FragariaMacros.h: -------------------------------------------------------------------------------- 1 | // 2 | // Header.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 28/10/2018. 6 | // 7 | 8 | #ifndef FragariaMacros_h 9 | #define FragariaMacros_h 10 | 11 | 12 | #define FRAGARIA_DEPRECATED __attribute__((deprecated)) 13 | #define FRAGARIA_DEPRECATED_MSG(m) __attribute__((deprecated(m))) 14 | 15 | #ifndef FRAGARIA_PRIVATE 16 | #define FRAGARIA_PUB_UNAVAIL __attribute__((deprecated)) 17 | #define FRAGARIA_PUB_UNAVAIL_MSG(m) __attribute__((deprecated(m))) 18 | #else 19 | #define FRAGARIA_PUB_UNAVAIL 20 | #define FRAGARIA_PUB_UNAVAIL_MSG(m) 21 | #endif 22 | 23 | 24 | #endif /* FragariaMacros_h */ 25 | -------------------------------------------------------------------------------- /Fragaria/FragariaUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // FragariaUtilities.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 07/07/2019. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @class MGSColourScheme; 13 | @class MGSSyntaxParser; 14 | 15 | 16 | /** Colors an attributed string with the specified parser and color scheme. 17 | * @param str The attributed string to modify. 18 | * @param parser The parser to use. 19 | * @param scheme The color scheme. If nil, the default color scheme will 20 | * be used. 21 | * @warning Existing attributes are not guaranteed to be retained. On return, 22 | * all font attributes will be based on the font attribute of the first 23 | * character of the string. */ 24 | void MGSHighlightAttributedString(NSMutableAttributedString *str, MGSSyntaxParser *parser, MGSColourScheme * __nullable scheme); 25 | 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Fragaria/FragariaUtilities.m: -------------------------------------------------------------------------------- 1 | // 2 | // FragariaUtilities.m 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 07/07/2019. 6 | // 7 | 8 | #import "FragariaUtilities.h" 9 | #import "MGSAbstractSyntaxColouring.h" 10 | #import "MGSColourScheme.h" 11 | 12 | 13 | @interface MGSSimpleSyntaxColoring: MGSAbstractSyntaxColouring 14 | 15 | @property (nonatomic, strong) NSMutableAttributedString *textStorage; 16 | 17 | @end 18 | 19 | 20 | @implementation MGSSimpleSyntaxColoring { 21 | NSMutableAttributedString *_textStorage; 22 | } 23 | 24 | @synthesize textStorage = _textStorage; 25 | 26 | @end 27 | 28 | 29 | void MGSHighlightAttributedString(NSMutableAttributedString *str, MGSSyntaxParser *parser, MGSColourScheme *scheme) 30 | { 31 | if (str.length == 0) 32 | return; 33 | 34 | if (!scheme) 35 | scheme = [[MGSColourScheme alloc] init]; 36 | 37 | NSFont *font = [str attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL]; 38 | MGSSimpleSyntaxColoring *colorer = [[MGSSimpleSyntaxColoring alloc] init]; 39 | colorer.textStorage = str; 40 | colorer.parser = parser; 41 | colorer.colourScheme = scheme; 42 | colorer.textFont = font ?: [NSFont userFontOfSize:12.0]; 43 | [colorer recolourChangedRange:NSMakeRange(0, str.length)]; 44 | } 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/Attribute.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.200", 9 | "green" : "0.500", 10 | "red" : "0.500" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.200", 27 | "green" : "0.500", 28 | "red" : "0.500" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/AutoComplete.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.006", 9 | "green" : "0.410", 10 | "red" : "0.840" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.006", 27 | "green" : "0.410", 28 | "red" : "0.840" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/Command.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.855", 9 | "green" : "0.000", 10 | "red" : "0.031" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.855", 27 | "green" : "0.000", 28 | "red" : "0.031" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/Comment.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.000", 9 | "green" : "0.450", 10 | "red" : "0.000" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.271", 27 | "green" : "0.800", 28 | "red" : "0.255" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/DefaultErrorHighlighting.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.700", 9 | "green" : "1.000", 10 | "red" : "1.000" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "gray-gamma-22", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "white" : "0.400" 27 | } 28 | }, 29 | "idiom" : "universal" 30 | } 31 | ], 32 | "info" : { 33 | "author" : "xcode", 34 | "version" : 1 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/Instruction.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.647", 9 | "green" : "0.450", 10 | "red" : "0.737" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.647", 27 | "green" : "0.450", 28 | "red" : "0.737" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/KeyCurrentLineHighlight.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.710", 9 | "green" : "0.960", 10 | "red" : "0.960" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.000", 27 | "green" : "0.000", 28 | "red" : "0.000" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/Keyword.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.647", 9 | "green" : "0.450", 10 | "red" : "0.737" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.580", 27 | "green" : "0.094", 28 | "red" : "0.827" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/Number.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.855", 9 | "green" : "0.000", 10 | "red" : "0.031" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "1.000", 27 | "green" : "0.427", 28 | "red" : "0.467" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/String.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.153", 9 | "green" : "0.071", 10 | "red" : "0.804" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.220", 27 | "green" : "0.173", 28 | "red" : "1.000" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/TextInvisibleCharacters.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.000", 9 | "green" : "0.000", 10 | "red" : "0.000" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.906", 27 | "green" : "0.906", 28 | "red" : "0.906" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/Variable.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.740", 9 | "green" : "0.000", 10 | "red" : "0.730" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.740", 27 | "green" : "0.000", 28 | "red" : "0.730" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesAccess.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "messagesAccess.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesAccess.imageset/messagesAccess.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shysaur/Fragaria/3d4526d025a73ea5b4e26cc3fec61be57229c158/Fragaria/Images.xcassets/messagesAccess.imageset/messagesAccess.pdf -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesConfig.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "messagesConfig.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesConfig.imageset/messagesConfig.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shysaur/Fragaria/3d4526d025a73ea5b4e26cc3fec61be57229c158/Fragaria/Images.xcassets/messagesConfig.imageset/messagesConfig.pdf -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesDocument.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "messagesDocument.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesDocument.imageset/messagesDocument.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shysaur/Fragaria/3d4526d025a73ea5b4e26cc3fec61be57229c158/Fragaria/Images.xcassets/messagesDocument.imageset/messagesDocument.pdf -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesError.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "messagesError.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesError.imageset/messagesError.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shysaur/Fragaria/3d4526d025a73ea5b4e26cc3fec61be57229c158/Fragaria/Images.xcassets/messagesError.imageset/messagesError.pdf -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesInfo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "messagesInfo.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesInfo.imageset/messagesInfo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shysaur/Fragaria/3d4526d025a73ea5b4e26cc3fec61be57229c158/Fragaria/Images.xcassets/messagesInfo.imageset/messagesInfo.pdf -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesPanic.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "messagesPanic.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesPanic.imageset/messagesPanic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shysaur/Fragaria/3d4526d025a73ea5b4e26cc3fec61be57229c158/Fragaria/Images.xcassets/messagesPanic.imageset/messagesPanic.pdf -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesWarning.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "messagesWarning.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Fragaria/Images.xcassets/messagesWarning.imageset/messagesWarning.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shysaur/Fragaria/3d4526d025a73ea5b4e26cc3fec61be57229c158/Fragaria/Images.xcassets/messagesWarning.imageset/messagesWarning.pdf -------------------------------------------------------------------------------- /Fragaria/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleShortVersionString 16 | DUMMY 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | DUMMY 21 | 22 | 23 | -------------------------------------------------------------------------------- /Fragaria/Integrated Syntax Definitions/none.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beginCommand 6 | 7 | endCommand 8 | 9 | beginInstruction 10 | 11 | endInstruction 12 | 13 | beginVariable 14 | 15 | endVariable 16 | 17 | firstString 18 | 19 | secondString 20 | 21 | firstSingleLineComment 22 | 23 | secondSingleLineComment 24 | 25 | beginFirstMultiLineComment 26 | 27 | endFirstMultiLineComment 28 | 29 | beginSecondMultiLineComment 30 | 31 | endSecondMultiLineComment 32 | 33 | functionDefinition 34 | 35 | removeFromFunction 36 | 37 | keywordsCaseSensitive 38 | 39 | recolourKeywordIfAlreadyColoured 40 | 41 | allowSyntaxColouring 42 | 43 | keywords 44 | 45 | autocompleteWords 46 | 47 | name 48 | None 49 | extensions 50 | txt 51 | 52 | 53 | -------------------------------------------------------------------------------- /Fragaria/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* Localized name of syntax group \"attribute\" */ 2 | "Attribute" = "Attribute"; 3 | 4 | /* Localized name of syntax group \"autocomplete\" */ 5 | "Autocomplete" = "Autocomplete"; 6 | 7 | /* Localized name of syntax group \"command\" */ 8 | "Command" = "Command"; 9 | 10 | /* Localized name of syntax group \"comment\" */ 11 | "Comment" = "Comment"; 12 | 13 | /* Name for Custom Settings scheme. */ 14 | "Custom Settings" = "Custom Settings"; 15 | 16 | /* Localized name of syntax group \"instruction\" */ 17 | "Instruction" = "Instruction"; 18 | 19 | /* Localized name of syntax group \"keyword\" */ 20 | "Keyword" = "Keyword"; 21 | 22 | /* Localized name of syntax group \"number\" */ 23 | "Number" = "Number"; 24 | 25 | /* Localized name of syntax group \"string\" */ 26 | "String" = "String"; 27 | 28 | /* Localized name of syntax group \"variable\" */ 29 | "Variable" = "Variable"; 30 | 31 | -------------------------------------------------------------------------------- /Fragaria/MGSAbstractSyntaxColouring.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSAbstractSyntaxColouring.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 07/07/2019. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | #import "MGSSyntaxParserClient.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @class MGSColourScheme; 15 | @class MGSSyntaxParser; 16 | 17 | 18 | @interface MGSAbstractSyntaxColouring : NSObject 19 | 20 | 21 | /// @name Setting the object of coloring 22 | 23 | /** The text storage containing the text to color. 24 | * @note To be overridden in a concrete implementation. */ 25 | @property (nonatomic, readonly) NSMutableAttributedString *textStorage; 26 | 27 | 28 | /// @name Coloring Settings 29 | 30 | /** The parser currently used for colouring the text. */ 31 | @property (nonatomic, strong) MGSSyntaxParser *parser; 32 | 33 | /** The colour scheme */ 34 | @property (nonatomic, strong) MGSColourScheme *colourScheme; 35 | /** The base font to use for highlighting */ 36 | @property (nonatomic, strong) NSFont *textFont; 37 | 38 | /** If multiline strings should be coloured. */ 39 | @property (nonatomic, assign) BOOL coloursMultiLineStrings; 40 | /** If coloring should end at end of line. */ 41 | @property (nonatomic, assign) BOOL coloursOnlyUntilEndOfLine; 42 | 43 | 44 | /// @name Performing Highlighting 45 | 46 | /** Indicates the character ranges where colouring is valid. */ 47 | @property (strong, readonly) NSMutableIndexSet *inspectedCharacterIndexes; 48 | 49 | /** Recolors the invalid characters in the specified range. 50 | * @param range A character range where, when this method returns, all syntax 51 | * colouring will be guaranteed to be up-to-date. */ 52 | - (void)recolourRange:(NSRange)range; 53 | 54 | /** Marks the entire text's colouring as invalid and removes all coloring 55 | * attributes applied. */ 56 | - (void)invalidateAllColouring; 57 | 58 | /** Forces a recolouring of the character range specified. The recolouring will 59 | * be done anew even if the specified range is already valid (wholly or in 60 | * part). 61 | * @param rangeToRecolour Indicates the range to be recoloured. 62 | * @return The range that was effectively coloured. The returned range always 63 | * contains entirely the initial range. */ 64 | - (NSRange)recolourChangedRange:(NSRange)rangeToRecolour; 65 | 66 | 67 | @end 68 | 69 | 70 | NS_ASSUME_NONNULL_END 71 | -------------------------------------------------------------------------------- /Fragaria/MGSAttributeOverlayTextStorage.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSAttributeOverlayTextStorage.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 28/10/2018. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | 14 | /** An implementation of NSTextStorage as a view of another text storage's 15 | * text but with different attributes. 16 | * 17 | * Any change on the text of this text storage will be reflected to the parent 18 | * text storage and vice versa. Changes on the attributes of the parent text 19 | * storage will be reflected on this text storage if there is not an attribute 20 | * set on this text storage which overrides it. Changes on the attributes of 21 | * this text storage do not reflect to changes in the attributes of the parent 22 | * text storage. */ 23 | @interface MGSAttributeOverlayTextStorage : NSTextStorage 24 | 25 | 26 | /** Initializes this text storage as a view of the specified text storage. 27 | * @param ts The parent text storage 28 | * @returns A new instance of MGSAttributeOverlayTextStorage. */ 29 | - (instancetype)initWithParentTextStorage:(NSTextStorage *)ts NS_DESIGNATED_INITIALIZER; 30 | 31 | /** The text storage which is the parent of this text storage. */ 32 | @property (readonly, strong) NSTextStorage *parentTextStorage; 33 | 34 | 35 | @end 36 | 37 | 38 | NS_ASSUME_NONNULL_END 39 | -------------------------------------------------------------------------------- /Fragaria/MGSAutoCompleteDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSAutoCompleteDelegate.h 3 | // Fragaria 4 | // 5 | // Created by Viktor Lidholt on 4/12/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | 12 | /** 13 | * The MGSAutoCompleteDelegate defines an interface for allowing a delegate to 14 | * return a list of suitable autocomplete choices. 15 | **/ 16 | @protocol MGSAutoCompleteDelegate 17 | 18 | - (NSArray *) completions; ///< A dictionary of words that can be used for autocompletion. 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Fragaria/MGSClassicFragariaSyntaxParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSClassicFragariaSyntaxParser.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 27/12/2018. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import "MGSSyntaxParser.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | 14 | @class MGSClassicFragariaSyntaxDefinition; 15 | 16 | 17 | @interface MGSClassicFragariaSyntaxParser : MGSSyntaxParser 18 | 19 | 20 | - (instancetype)initWithSyntaxDefinition:(MGSClassicFragariaSyntaxDefinition *)sdef; 21 | 22 | @property (nonatomic, readonly) MGSClassicFragariaSyntaxDefinition *syntaxDefinition; 23 | 24 | 25 | @end 26 | 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Fragaria/MGSColourSchemePrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSColourSchemePrivate.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 20/09/18. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | #import "MGSColourScheme.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | 15 | extern NSString * const MGSColourSchemeKeySyntaxGroupOptions; 16 | 17 | 18 | @interface MGSColourSchemeGroupData : NSObject 19 | 20 | - (instancetype)initWithOptionDictionary:(NSDictionary *)optionDictionary; 21 | - (NSDictionary *)optionDictionary; 22 | 23 | @property (nonatomic) BOOL enabled; 24 | @property (nonatomic, nullable) NSColor *color; 25 | @property (nonatomic) MGSFontVariant fontVariant; 26 | 27 | @end 28 | 29 | 30 | @interface MGSColourScheme () 31 | { 32 | @protected 33 | NSMutableDictionary *_groupData; 34 | } 35 | 36 | - (BOOL)loadFromSchemeFileURL:(NSURL *)file error:(NSError **)err; 37 | 38 | @property (nonatomic, strong) NSString *displayName; 39 | 40 | @property (nonatomic, strong) NSColor *textColor; 41 | @property (nonatomic, strong) NSColor *backgroundColor; 42 | @property (nonatomic, strong) NSColor *defaultSyntaxErrorHighlightingColour; 43 | @property (nonatomic, strong) NSColor *textInvisibleCharactersColour; 44 | @property (nonatomic, strong) NSColor *currentLineHighlightColour; 45 | @property (nonatomic, strong) NSColor *insertionPointColor; 46 | @property (nonatomic, strong) NSColor *selectionBackgroundColor; 47 | @property (nonatomic, strong) NSColor *gutterTextColor; 48 | @property (nonatomic, strong) NSColor *gutterBackgroundColor; 49 | 50 | @property (nonatomic, copy) NSDictionary *> *syntaxGroupOptions; 51 | 52 | @end 53 | 54 | 55 | NS_ASSUME_NONNULL_END 56 | 57 | -------------------------------------------------------------------------------- /Fragaria/MGSColourToPlainTextTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSFontToTextTransformer.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/23/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | /** 12 | * This NSValueTransformer transforms an NSColor back and forth into 13 | * an easy-to-edit human readable dictionary of strings. 14 | **/ 15 | @interface MGSColourToPlainTextTransformer : NSValueTransformer 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Fragaria/MGSColourToPlainTextTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSFontToTextTransformer.m 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/23/15. 6 | // 7 | // 8 | 9 | #import "MGSColourToPlainTextTransformer.h" 10 | 11 | 12 | @implementation MGSColourToPlainTextTransformer 13 | 14 | 15 | /* 16 | * + transformedValueClass 17 | */ 18 | + (Class)transformedValueClass 19 | { 20 | return [NSColor class]; 21 | } 22 | 23 | 24 | /* 25 | * + allowsReverseTransformation 26 | */ 27 | + (BOOL)allowsReverseTransformation 28 | { 29 | return YES; 30 | } 31 | 32 | 33 | /* 34 | * - transformedValue: 35 | */ 36 | - (id)transformedValue:(id)col 37 | { 38 | NSColor *nc; 39 | NSMutableString *tmp = [NSMutableString string]; 40 | 41 | if ([col colorUsingColorSpaceName:NSNamedColorSpace]) { 42 | [tmp appendFormat:@"%@ %@", [col catalogNameComponent], [col colorNameComponent]]; 43 | 44 | } else if ((nc = [col colorUsingColorSpaceName:NSCalibratedRGBColorSpace])) { 45 | [tmp appendFormat:@"%lf %lf %lf", nc.redComponent, nc.greenComponent, nc.blueComponent]; 46 | if (nc.alphaComponent != 1.0) 47 | [tmp appendFormat:@" %lf", nc.alphaComponent]; 48 | 49 | } else { 50 | NSLog(@"MGSStringFromColor: can't convert %@, returning red", col); 51 | return @"1.0 0.0 0.0"; 52 | } 53 | 54 | return [tmp copy]; 55 | } 56 | 57 | 58 | /* 59 | * - reverseTransformedValue: 60 | */ 61 | -(id)reverseTransformedValue:(id)str 62 | { 63 | NSScanner *scan = [NSScanner scannerWithString:str]; 64 | 65 | CGFloat r, g, b, a = 1.0; 66 | if (([scan scanDouble:&r] && [scan scanDouble:&g] && [scan scanDouble:&b])) { 67 | [scan scanDouble:&a]; 68 | return [NSColor colorWithCalibratedRed:r green:g blue:b alpha:a]; 69 | } 70 | 71 | [scan setScanLocation:0]; 72 | NSString *catalog, *color; 73 | if ([scan scanUpToCharactersFromSet:[NSCharacterSet whitespaceCharacterSet] intoString:&catalog] && 74 | [scan scanUpToCharactersFromSet:[NSCharacterSet whitespaceCharacterSet] intoString:&color]) { 75 | NSColor *res = [NSColor colorWithCatalogName:catalog colorName:color]; 76 | if (res) 77 | return res; 78 | } 79 | 80 | NSLog(@"MGSColorFromString: can't parse %@, returning red", str); 81 | return [NSColor redColor]; 82 | } 83 | 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /Fragaria/MGSDragOperationDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSDragOperationDelegate.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 08/02/15. 6 | // 7 | // - Defines the that delegates may conform to. 8 | // 9 | 10 | #import 11 | 12 | 13 | /** 14 | * MGSDragOperationDelegate passes the methods to 15 | * a delegate so that is it possible to implement the protocol without 16 | * having to subclass the view. 17 | **/ 18 | @protocol MGSDragOperationDelegate 19 | 20 | @optional 21 | 22 | /** 23 | * Refer to the NSDraggingDestination documentation. 24 | * @param sender Indicates the object sending the message. 25 | **/ 26 | - (NSDragOperation)draggingEntered:(id)sender; 27 | 28 | /** 29 | * Refer to the NSDraggingDestination documentation. 30 | **/ 31 | - (BOOL)wantsPeriodicDraggingUpdates; 32 | 33 | /** 34 | * Refer to the NSDraggingDestination documentation. 35 | * @param sender Indicates the object sending the message. 36 | **/ 37 | - (NSDragOperation)draggingUpdated:(id)sender; 38 | 39 | /** 40 | * Refer to the NSDraggingDestination documentation. 41 | * @param sender Indicates the object sending the message. 42 | **/ 43 | - (void)draggingEnded:(id)sender; 44 | 45 | /** 46 | * Refer to the NSDraggingDestination documentation. 47 | * @param sender Indicates the object sending the message. 48 | **/ 49 | - (void)draggingExited:(id)sender; 50 | 51 | /** 52 | * Refer to the NSDraggingDestination documentation. 53 | * @param sender Indicates the object sending the message. 54 | **/ 55 | - (BOOL)prepareForDragOperation:(id)sender; 56 | 57 | /** 58 | * Refer to the NSDraggingDestination documentation. 59 | * @param sender Indicates the object sending the message. 60 | **/ 61 | - (BOOL)performDragOperation:(id)sender; 62 | 63 | /** 64 | * Refer to the NSDraggingDestination documentation. 65 | * @param sender Indicates the object sending the message. 66 | **/ 67 | - (void)concludeDragOperation:(id )sender; 68 | 69 | /** 70 | * Refer to the NSDraggingDestination documentation. 71 | * @param sender Indicates the object sending the message. 72 | **/ 73 | - (void)updateDraggingItemsForDrag:(id)sender; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Fragaria/MGSFragariaTextViewDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSFragariaTextViewDelegate.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 2/22/15. 6 | // 7 | // 8 | 9 | /** 10 | * This protocol defines an interface for delegates that wish 11 | * to receive notifications from Fragaria's text view. 12 | **/ 13 | #pragma mark - MGSFragariaTextViewDelegate Protocol 14 | @protocol MGSFragariaTextViewDelegate 15 | @optional 16 | 17 | /** 18 | * This notification is send when the paste has been accepted. You can use 19 | * this delegate method to query the pasteboard for additional pasteboard content 20 | * that may be relevant to the application: eg: a plist that may contain custom data. 21 | * @param note is an NSNotification instance. 22 | **/ 23 | - (void)mgsTextDidPaste:(NSNotification *)note; 24 | 25 | @end 26 | 27 | 28 | -------------------------------------------------------------------------------- /Fragaria/MGSFragariaViewPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSFragariaViewPrivate.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/25/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | @class MGSSyntaxErrorController; 10 | @class MGSLineNumberView; 11 | @class MGSSyntaxColouring; 12 | @class MGSMutableColourScheme; 13 | 14 | 15 | #pragma mark - Class Extension 16 | 17 | 18 | @interface MGSFragariaView() 19 | 20 | 21 | /** Fragaria's syntax colouring object. */ 22 | @property (nonatomic, assign, readonly) MGSSyntaxColouring *syntaxColouring; 23 | 24 | /** Fragaria's gutter view. */ 25 | @property (nonatomic, strong, readonly) MGSLineNumberView *gutterView; 26 | 27 | /** The controller which manages and displays the syntax errors in Fragaria's 28 | * text view and gutter view. */ 29 | @property (readonly) MGSSyntaxErrorController *syntaxErrorController; 30 | 31 | 32 | @end 33 | 34 | -------------------------------------------------------------------------------- /Fragaria/MGSLayoutManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | MGSFragaria 3 | Written by Jonathan Mitchell, jonathan@mugginsoft.com 4 | Find the latest version at https://github.com/mugginsoft/Fragaria 5 | 6 | Smultron version 3.6b1, 2009-09-12 7 | Written by Peter Borg, pgw3@mac.com 8 | Find the latest version at http://smultron.sourceforge.net 9 | 10 | Copyright 2004-2009 Peter Borg 11 | 12 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 13 | this file except in compliance with the License. You may obtain a copy of the 14 | License at 15 | 16 | http://www.apache.org/licenses/LICENSE-2.0 17 | 18 | Unless required by applicable law or agreed to in writing, software distributed 19 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 20 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 21 | specific language governing permissions and limitations under the License. 22 | */ 23 | /// @cond PRIVATE 24 | 25 | #import 26 | 27 | 28 | enum { 29 | MGSUnderlineStyleSquiggly = 0x0F 30 | }; 31 | 32 | 33 | /** 34 | * MGSLayoutManager handles the layout of all of the glyphs in the text editor. 35 | **/ 36 | @interface MGSLayoutManager : NSLayoutManager 37 | 38 | /** 39 | * Returns an attributed string with temporary attributes having been 40 | * applied as standard attributes. 41 | **/ 42 | - (NSAttributedString *)attributedStringWithTemporaryAttributesApplied; 43 | 44 | /** 45 | * Specifies the font for drawing invisible characters. 46 | **/ 47 | @property (nonatomic) NSFont *invisibleCharactersFont; 48 | 49 | /** 50 | * Specifies the color for drawing invisible characters. 51 | **/ 52 | @property (nonatomic) NSColor *invisibleCharactersColour; 53 | 54 | /** 55 | * Indicates whether or not glyphs for invisible characters will 56 | * appear in the text editor. 57 | **/ 58 | @property BOOL showsInvisibleCharacters; 59 | 60 | /** 61 | * Clears the current substitutes for invisible characters 62 | **/ 63 | - (void)clearInvisibleCharacterSubstitutes; 64 | 65 | /** 66 | * Remove the substitute for invisible character `character` 67 | **/ 68 | - (void)removeSubstituteForInvisibleCharacter:(unichar)character; 69 | 70 | /** 71 | * Add a substitute `substitute` for invisible character `character` 72 | **/ 73 | - (void)addSubstitute:(NSString*)substitute forInvisibleCharacter:(unichar)character; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Fragaria/MGSLineNumberViewDecoration.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSLineNumberViewDecoration.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 09/03/16. 6 | // 7 | // 8 | 9 | #import 10 | 11 | 12 | /** A protocol for decoration objects of MGSLineNumberView. */ 13 | 14 | @protocol MGSLineNumberViewDecoration 15 | 16 | 17 | /** The image to display. */ 18 | - (NSImage *)warningImage; 19 | 20 | /** Returns nil or a contextual menu appropriate for the decoration. */ 21 | - (NSMenu *)contextualMenu; 22 | 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Fragaria/MGSMutableColourSchemeFromPlistTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSMutableColourSchemeFromPlistTransformer.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 03/07/2019. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | extern NSValueTransformerName const MGSMutableColourSchemeFromPlistTransformerName; 13 | 14 | 15 | @interface MGSMutableColourSchemeFromPlistTransformer : NSValueTransformer 16 | 17 | @end 18 | 19 | 20 | NS_ASSUME_NONNULL_END 21 | -------------------------------------------------------------------------------- /Fragaria/MGSMutableColourSchemeFromPlistTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSMutableColourSchemeFromPlistTransformer.m 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 03/07/2019. 6 | // 7 | 8 | #import "MGSMutableColourSchemeFromPlistTransformer.h" 9 | #import "MGSMutableColourScheme.h" 10 | 11 | 12 | NSValueTransformerName const MGSMutableColourSchemeFromPlistTransformerName = @"MGSMutableColourSchemeFromPlistTransformer"; 13 | 14 | 15 | @implementation MGSMutableColourSchemeFromPlistTransformer 16 | 17 | 18 | + (void)load 19 | { 20 | MGSMutableColourSchemeFromPlistTransformer *reg = [[MGSMutableColourSchemeFromPlistTransformer alloc] init]; 21 | [NSValueTransformer setValueTransformer:reg forName:MGSMutableColourSchemeFromPlistTransformerName]; 22 | } 23 | 24 | 25 | + (Class)transformedValueClass 26 | { 27 | return [MGSMutableColourScheme class]; 28 | } 29 | 30 | 31 | + (BOOL)allowsReverseTransformation 32 | { 33 | return YES; 34 | } 35 | 36 | 37 | - (id)transformedValue:(id)value 38 | { 39 | if (!value || ![value isKindOfClass:[NSDictionary class]]) 40 | return nil; 41 | return [[MGSMutableColourScheme alloc] initWithPropertyList:value error:nil]; 42 | } 43 | 44 | 45 | - (id)reverseTransformedValue:(id)value 46 | { 47 | if (!value || ![value isKindOfClass:[MGSColourScheme class]]) 48 | return nil; 49 | return [value propertyListRepresentation]; 50 | } 51 | 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Fragaria/MGSStandardParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSStandardParser.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 27/04/2019. 6 | // 7 | 8 | #import "MGSSyntaxParser.h" 9 | #import "MGSParserFactory.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | 14 | /** The parser that defines the "Standard" language. 15 | * 16 | * The "Standard" language is a language without any colouring, 17 | * without any file associations, and which is guaranteed to 18 | * be available. */ 19 | 20 | @interface MGSStandardParser : MGSSyntaxParser 21 | 22 | 23 | + (NSString *)standardSyntaxDefinitionName; 24 | 25 | 26 | @end 27 | 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /Fragaria/MGSStandardParser.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSStandardParser.m 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 27/04/2019. 6 | // 7 | 8 | #import "MGSStandardParser.h" 9 | 10 | 11 | @implementation MGSStandardParser 12 | 13 | 14 | + (NSString *)standardSyntaxDefinitionName 15 | { 16 | return @"Standard"; 17 | } 18 | 19 | 20 | - (NSArray *)syntaxDefinitionNames 21 | { 22 | return @[[[self class] standardSyntaxDefinitionName]]; 23 | } 24 | 25 | 26 | - (nonnull MGSSyntaxParser *)parserForSyntaxDefinitionName:(nonnull NSString *)syndef 27 | { 28 | return self; 29 | } 30 | 31 | 32 | - (NSRange)parseForClient:(id)client 33 | { 34 | return NSMakeRange(0, client.stringToParse.length); 35 | } 36 | 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Fragaria/MGSSyntaxAwareEditor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSSyntaxAwareEditor.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 01/12/2018. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | 13 | /** Protocol used to support syntax-aware editing commands in Fragaria. 14 | * Implemented by syntax parsers. */ 15 | @protocol MGSSyntaxAwareEditor 16 | 17 | 18 | /** Returns YES if the object supports `-commentOrUncomment:`. */ 19 | @property (readonly, nonatomic) BOOL providesCommentOrUncomment; 20 | 21 | 22 | @optional 23 | 24 | /** Toggle comments as appropriate for the language on the 25 | * given mutable string. 26 | * @param string The string to be mutated. */ 27 | - (void)commentOrUncomment:(NSMutableString *)string; 28 | 29 | 30 | @end 31 | 32 | 33 | NS_ASSUME_NONNULL_END 34 | -------------------------------------------------------------------------------- /Fragaria/MGSSyntaxParser.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSSyntaxParser.m 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 30/10/2018. 6 | // 7 | 8 | #import "MGSSyntaxParser.h" 9 | #import "NSScanner+Fragaria.h" 10 | #import "MGSSyntaxAwareEditor.h" 11 | #import "MGSMutableSubstring.h" 12 | 13 | 14 | @implementation MGSSyntaxParser 15 | 16 | 17 | - (NSRange)parseForClient:(id)client 18 | { 19 | return NSMakeRange(0, client.stringToParse.length); 20 | } 21 | 22 | 23 | #pragma mark - Editor 24 | 25 | 26 | - (BOOL)providesCommentOrUncomment 27 | { 28 | return NO; 29 | } 30 | 31 | 32 | - (void)commentOrUncomment:(NSMutableString *)string 33 | { 34 | } 35 | 36 | 37 | #pragma mark - Autocompletion 38 | 39 | 40 | - (NSArray *)completions 41 | { 42 | return @[]; 43 | } 44 | 45 | 46 | - (NSArray *)autocompletionKeywords 47 | { 48 | return @[]; 49 | } 50 | 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Fragaria/MGSTextView+MGSDragging.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSTextView+JSDExtension.h 3 | // Fragaria 4 | // 5 | // File created by Jim Derry on 2015/02/07. 6 | // 7 | // - Extends MGSTextView to use its delegate to pass off its methods to the delegate. 8 | // - Implements the required protocol classes, passing them on to the delegate. 9 | // 10 | 11 | #import 12 | 13 | 14 | @interface MGSTextView (MGSDragging) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Fragaria/MGSTextViewPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSTextViewPrivate.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 26/02/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | #import "MGSTextView.h" 11 | 12 | 13 | @class MGSExtraInterfaceController; 14 | @class MGSSyntaxColouring; 15 | @class MGSLayoutManager; 16 | @class MGSMutableColourScheme; 17 | 18 | 19 | @interface MGSTextView () 20 | 21 | 22 | /// @name Private properties 23 | 24 | 25 | /** The controller which manages the accessory user interface for this text 26 | * view. */ 27 | @property (readonly) MGSExtraInterfaceController *interfaceController; 28 | 29 | /** Instances of this class will perform syntax highlighting in text views. */ 30 | @property (readonly) MGSSyntaxColouring *syntaxColouring; 31 | 32 | /** MGSTextView's layout manager is an MGSLayoutManager internally, but that 33 | * class is not exposed. */ 34 | @property (assign, readonly) MGSLayoutManager *layoutManager; 35 | 36 | /** The shared color scheme, set by MGSFragariaView */ 37 | @property (nonatomic, strong) MGSMutableColourScheme *colourScheme; 38 | 39 | @property (nonatomic) BOOL useSystemSelectionColor; 40 | 41 | - (void)updateLineWrap; 42 | 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Fragaria/NSCharacterSet+Fragaria.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSCharacterSet+NSCharacterSet_Fragaria.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 25/04/2019. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | 15 | @interface NSCharacterSet (Fragaria) 16 | 17 | - (BOOL)mgs_isEmpty; 18 | 19 | @end 20 | 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /Fragaria/NSCharacterSet+Fragaria.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSCharacterSet+Fragaria.m 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 25/04/2019. 6 | // 7 | 8 | #import "NSCharacterSet+Fragaria.h" 9 | 10 | 11 | @implementation NSCharacterSet (Fragaria) 12 | 13 | 14 | - (BOOL)mgs_isEmpty 15 | { 16 | return [self isEqual:[NSCharacterSet characterSetWithCharactersInString:@""]]; 17 | } 18 | 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Fragaria/NSColor+TransformedCompare.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSColor+TransformedCompare.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/23/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | 12 | /** The MGSTransformCompare category allows comparison of NSColors after 13 | * transformation by an NSValueTransformer.*/ 14 | @interface NSColor (MGSTransformedCompare) 15 | 16 | 17 | /** Compares the objects produced by the specified value transformer from this 18 | * color and the specified color, and returns YES if they are equal. 19 | * @param colour Object to compare with. 20 | * @param transf Name of the value transformer to be used. */ 21 | - (BOOL)mgs_isEqualToColor:(NSColor *)colour transformedThrough:(NSString*)transf; 22 | 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Fragaria/NSColor+TransformedCompare.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSColor+TransformedCompare.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/23/15. 6 | // 7 | // 8 | 9 | #import "NSColor+TransformedCompare.h" 10 | #import "MGSColourToPlainTextTransformer.h" 11 | 12 | 13 | @implementation NSColor (MGSTransformedCompare) 14 | 15 | 16 | /* 17 | * - mgs_isEqualToColor:transformedThrough: 18 | */ 19 | - (BOOL)mgs_isEqualToColor:(NSColor *)colour transformedThrough:(NSString*)tname 20 | { 21 | NSValueTransformer *xformer = [NSValueTransformer valueTransformerForName:tname]; 22 | 23 | id result1 = [xformer transformedValue:self]; 24 | id result2 = [xformer transformedValue:colour]; 25 | 26 | return [result1 isEqual:result2]; 27 | } 28 | 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Fragaria/NSObject+Fragaria.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Fragaria.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 29/05/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | 12 | /** 13 | * This category adds miscellaneous methods to NSObject, to be used only 14 | * internally to Fragaria. 15 | */ 16 | 17 | @interface NSObject (Fragaria) 18 | 19 | 20 | /** If the specified property is bound to an object, set the given value on 21 | * the bound object. 22 | * @discussion For details on why this is necessary, see 23 | * http://www.tomdalling.com/blog/cocoa/implementing-your-own-cocoa-bindings/ 24 | * @param value The value to be set on the bound object. 25 | * @param binding The property of this object which is to be propagated. */ 26 | - (void)mgs_propagateValue:(id)value forBinding:(NSString*)binding; 27 | 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Fragaria/NSScanner+Fragaria.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSScanner+Fragaria.h 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 12/08/2010. 6 | // Copyright 2010 mugginsoft.com. All rights reserved. 7 | // 8 | /// @cond PRIVATE 9 | 10 | #import 11 | 12 | 13 | /** 14 | * This category adds features to NSScanner. 15 | **/ 16 | @interface NSScanner (Fragaria) 17 | 18 | /** 19 | * mgs_setScanLocation ensures the idx is not beyond the length of the document. 20 | * If it is the location is set to the end of the text, and a message is written 21 | * to the console. 22 | * @param idx The character position to double-check. 23 | **/ 24 | - (void)mgs_setScanLocation:(NSUInteger)idx; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Fragaria/NSScanner+Fragaria.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSScanner+Fragaria.m 3 | // Fragaria 4 | // 5 | // Created by Jonathan on 12/08/2010. 6 | // Copyright 2010 mugginsoft.com. All rights reserved. 7 | // 8 | 9 | #import "NSScanner+Fragaria.h" 10 | 11 | 12 | @implementation NSScanner (Fragaria) 13 | 14 | /* 15 | 16 | mgs_setScanLocation: 17 | 18 | */ 19 | - (void)mgs_setScanLocation:(NSUInteger)idx 20 | { 21 | /* 22 | 23 | NSScanner raises if the index is beyond the end of the string. 24 | 25 | */ 26 | NSUInteger maxIndex = [[self string] length]; 27 | if (idx > maxIndex) { 28 | NSLog(@"Invalid scan location %lu > max of %lu", (long)idx, (long)maxIndex); 29 | idx = maxIndex; 30 | } 31 | 32 | [self setScanLocation:idx]; 33 | } 34 | @end 35 | -------------------------------------------------------------------------------- /Fragaria/NSSet+Fragaria.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSSet+Fragaria.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 06/03/16. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | 12 | /** This private category adds an utility initializer to NSSet. */ 13 | 14 | @interface NSSet (Fragaria) 15 | 16 | 17 | /** Returns an NSSet of those NSNumbers that are indexes of the specified 18 | * index set. 19 | * @param is An index set. */ 20 | - (NSSet *)mgs_initWithIndexSet:(NSIndexSet *)is; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Fragaria/NSString+Fragaria.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Fragaria.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 16/05/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | 12 | /** 13 | * A private category which adds helper functions to NSString. 14 | */ 15 | 16 | @interface NSString (Fragaria) 17 | 18 | 19 | /** The real location of the specified character index in this line, in 20 | * characters. 21 | * @discussion This method takes in account the real width of tabulation 22 | * characters. Newlines are treated like infinite-width tabs. 23 | * @param c A character index in the line string. 24 | * @param tabwidth The width of a tab. */ 25 | - (NSUInteger)mgs_columnOfCharacter:(NSUInteger)c tabWidth:(NSUInteger)tabwidth; 26 | 27 | /** Returns the character index in this row that corresponds to the specified 28 | * column (measured in characters). 29 | * @discussion This method takes in account the real width of tabulation 30 | * characters. Newlines are treated like infinite-width tabs. 31 | * @param c A column number. 32 | * @param tabwidth The width of a tab. */ 33 | - (NSUInteger)mgs_characterInColumn:(NSUInteger)c tabWidth:(NSUInteger)tabwidth; 34 | 35 | /** Returns the range of characters representing the line containing a given 36 | * character. 37 | * @param i A character index in the string. 38 | * @returns If i points to a valid index in the string, calling this method 39 | * is equivalent to calling [self lineRangeForRange:NSMakeRange(i, 0)]. 40 | * In all other cases, this function returns a range with NSNotFound as 41 | * location, and 0 as length. */ 42 | - (NSRange)mgs_lineRangeForCharacterIndex:(NSUInteger)i; 43 | 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Fragaria/NSString+Fragaria.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Fragaria.m 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 16/05/15. 6 | // 7 | // 8 | 9 | #import "NSString+Fragaria.h" 10 | 11 | 12 | @implementation NSString (Fragaria) 13 | 14 | 15 | /* 16 | * - mgs_columnOfCharacter:tabWidth: 17 | */ 18 | - (NSUInteger)mgs_columnOfCharacter:(NSUInteger)c tabWidth:(NSUInteger)tabwidth 19 | { 20 | NSUInteger i, pos, phase; 21 | NSCharacterSet *nl; 22 | unichar chr; 23 | 24 | pos = 0; 25 | nl = [NSCharacterSet newlineCharacterSet]; 26 | for (i=0; i 9 | 10 | 11 | /** A category of NSTextStorage, used for globally caching line numbers. */ 12 | 13 | @interface NSTextStorage (Fragaria) 14 | 15 | 16 | /** The row (line number) where the specified character index is located. 17 | * @param c A character index in the string. 18 | * @result If c is a valid character index, the index of a non-empty row 19 | * is returned. Otherwise, if c points to one character past the end of the 20 | * string, the function returns the row where that character will be when it 21 | * is inserted. In all other cases, NSNotFound is returned. */ 22 | - (NSUInteger)mgs_rowOfCharacter:(NSUInteger)c; 23 | 24 | /** The character index where the first character of the specified row (line 25 | * number) is located. 26 | * @param l A line number. 27 | * @discussion Any line number returned by mgs_rowOfCharacter: is a valid line 28 | * number for this function. 29 | * @result l may point to a line that contains no characters; in this case, 30 | * this method returns the index where its first character will be placed 31 | * when it is inserted. If this index can't be determined, NSNotFound is 32 | * returned. */ 33 | - (NSUInteger)mgs_firstCharacterInRow:(NSUInteger)l; 34 | 35 | /** The character index corresponding to the offset of a character in its row 36 | * (line). 37 | * @param i A character index, relative to the beginning of the line. 38 | * @param l A line number. 39 | * @returns A character index, or NSNotFound the line number is invalid. 40 | * @discussion Any line number returned by mgs_rowOfCharacter: is a valid 41 | * line number for this function. If the line number is valid, this function 42 | * will always return a valid character index in that line. If the 43 | * index parameter specifies a character outside the bounds of the line, 44 | * the index of one past the last character of content of that line will be 45 | * returned. */ 46 | - (NSUInteger)mgs_characterAtIndex:(NSUInteger)i withinRow:(NSUInteger)l; 47 | 48 | /** Returns the amount of text lines in this storage. */ 49 | - (NSUInteger)mgs_lineCount; 50 | 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Fragaria/en-GB.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* Name for Custom Settings scheme. */ 2 | "Custom Settings" = "Custom Settings"; 3 | 4 | -------------------------------------------------------------------------------- /Fragaria/en-GB.lproj/SyntaxGroupNames.strings: -------------------------------------------------------------------------------- 1 | /* 2 | SyntaxGroupNames.strings 3 | Fragaria 4 | 5 | Created by Daniele Cattaneo on 25/04/2019. 6 | 7 | */ 8 | 9 | "number" = "Number"; 10 | "command" = "Command"; 11 | "instruction" = "Instruction"; 12 | "keyword" = "Keyword"; 13 | "autocomplete" = "Autocomplete"; 14 | "variable" = "Variable"; 15 | "strings" = "String"; 16 | "attribute" = "Attribute"; 17 | "comments" = "Comment"; 18 | "command.scriptingDelimiter" = "Scripting Delimiter"; 19 | "command.tag" = "HTML/XML Tag"; 20 | "command.attributeList.dot" = "GraphViz Attribute List"; 21 | "instruction.parameter.tex" = "TeX Instruction Argument List"; 22 | "number.literalList" = "Lisp Literal List"; 23 | "instruction.link.md" = "Markdown Link"; 24 | "number.formatting.md" = "Markdown Formatting"; 25 | "instruction.block" = "Block"; 26 | -------------------------------------------------------------------------------- /Fragaria/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* Name for Custom Settings scheme. */ 2 | "Custom Settings" = "Custom Settings"; 3 | 4 | -------------------------------------------------------------------------------- /Fragaria/en.lproj/SyntaxGroupNames.strings: -------------------------------------------------------------------------------- 1 | /* 2 | SyntaxGroupNames.strings 3 | Fragaria 4 | 5 | Created by Daniele Cattaneo on 25/04/2019. 6 | 7 | */ 8 | 9 | "number" = "Number"; 10 | "command" = "Command"; 11 | "instruction" = "Instruction"; 12 | "keyword" = "Keyword"; 13 | "autocomplete" = "Autocomplete"; 14 | "variable" = "Variable"; 15 | "strings" = "String"; 16 | "attribute" = "Attribute"; 17 | "comments" = "Comment"; 18 | "command.scriptingDelimiter" = "Scripting Delimiter"; 19 | "command.tag" = "HTML/XML Tag"; 20 | "command.attributeList.dot" = "GraphViz Attribute List"; 21 | "instruction.parameter.tex" = "TeX Instruction Argument List"; 22 | "number.literalList" = "Lisp Literal List"; 23 | "instruction.link.md" = "Markdown Link"; 24 | "number.formatting.md" = "Markdown Formatting"; 25 | "instruction.block" = "Block"; 26 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/FragariaDefaultsCoordinator.h: -------------------------------------------------------------------------------- 1 | // 2 | // FragariaDefaultsCoordinator.h 3 | // FragariaDefaultsCoordinator 4 | // 5 | // Created by Daniele Cattaneo on 21/10/2018. 6 | // 7 | 8 | #import 9 | 10 | //! Project version number for FragariaDefaultsCoordinator. 11 | FOUNDATION_EXPORT double FragariaDefaultsCoordinatorVersionNumber; 12 | 13 | //! Project version string for FragariaDefaultsCoordinator. 14 | FOUNDATION_EXPORT const unsigned char FragariaDefaultsCoordinatorVersionString[]; 15 | 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | #import 26 | #import 27 | 28 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/Images.xcassets/MGSBold.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "bold.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | }, 12 | "properties" : { 13 | "template-rendering-intent" : "template" 14 | } 15 | } -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/Images.xcassets/MGSBold.imageset/bold.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shysaur/Fragaria/3d4526d025a73ea5b4e26cc3fec61be57229c158/FragariaDefaultsCoordinator/Images.xcassets/MGSBold.imageset/bold.pdf -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/Images.xcassets/MGSItalic.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "italic.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | }, 12 | "properties" : { 13 | "template-rendering-intent" : "template" 14 | } 15 | } -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/Images.xcassets/MGSItalic.imageset/italic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shysaur/Fragaria/3d4526d025a73ea5b4e26cc3fec61be57229c158/FragariaDefaultsCoordinator/Images.xcassets/MGSItalic.imageset/italic.pdf -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/Images.xcassets/MGSUnderline.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "underline.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | }, 12 | "properties" : { 13 | "template-rendering-intent" : "template" 14 | } 15 | } -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/Images.xcassets/MGSUnderline.imageset/underline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shysaur/Fragaria/3d4526d025a73ea5b4e26cc3fec61be57229c158/FragariaDefaultsCoordinator/Images.xcassets/MGSUnderline.imageset/underline.pdf -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | 22 | 23 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSBoolToColourTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSPropertyAvailableTransformer.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/15/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | /** 12 | * Given a @(YES) or @(NO) input, returns a colour suitable for enabled @(YES) 13 | * or disabled @(NO) controls. 14 | **/ 15 | @interface MGSBoolToColourTransformer : NSValueTransformer 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSBoolToColourTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSPropertyAvailableTransformer.m 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/15/15. 6 | // 7 | // 8 | 9 | #import "MGSBoolToColourTransformer.h" 10 | 11 | @implementation MGSBoolToColourTransformer 12 | 13 | + (Class)transformedValueClass 14 | { 15 | return [NSNumber class]; 16 | } 17 | 18 | 19 | + (BOOL)allowsReverseTransformation 20 | { 21 | return NO; 22 | } 23 | 24 | 25 | - (id)transformedValue:(id)value 26 | { 27 | // return [NSColor controlTextColor]; 28 | return [value boolValue] == YES ? [NSColor controlTextColor] : [[NSColor controlTextColor] colorWithAlphaComponent:0.25]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSBoolToGlobalHintTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSBoolToGlobalHintTransformer.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/25/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | 12 | /** 13 | * Given a @(YES) or @(NO) input, returns a string suitable for explaining 14 | * why some items are stylized. 15 | **/ 16 | @interface MGSBoolToGlobalHintTransformer : NSValueTransformer 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSBoolToGlobalHintTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSBoolToGlobalHintTransformer.m 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/25/15. 6 | // 7 | // 8 | 9 | #import "MGSBoolToGlobalHintTransformer.h" 10 | 11 | @implementation MGSBoolToGlobalHintTransformer 12 | 13 | + (Class)transformedValueClass 14 | { 15 | return [NSString class]; 16 | } 17 | 18 | 19 | + (BOOL)allowsReverseTransformation 20 | { 21 | return NO; 22 | } 23 | 24 | 25 | - (id)transformedValue:(id)value 26 | { 27 | if (value && [value boolValue]) 28 | { 29 | return NSLocalizedStringFromTableInBundle(@"Items in bold affect all of your views.", nil, [NSBundle bundleForClass:[self class]], @"Hint explaining why certain items are bold."); 30 | } 31 | 32 | return nil; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSColourSchemeSaveController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSColourSchemeSaveController.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/21/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | /** 12 | * Provides a scheme naming service for MGSColourSchemeListController, as well 13 | * as a file deletion confirmation service. 14 | **/ 15 | @interface MGSColourSchemeSaveController : NSWindowController 16 | 17 | 18 | @property (nonatomic) NSSet *usedSchemeNames; 19 | 20 | /** 21 | * The name of the scheme. You can retrieve this after showSchemeNameGetter 22 | * returns. 23 | **/ 24 | @property (nonatomic, strong) NSString *schemeName; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSColourSchemeSaveController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSColourSchemeSaveController.m 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/21/15. 6 | // 7 | // 8 | 9 | #import "MGSColourSchemeSaveController.h" 10 | 11 | 12 | @interface MGSColourSchemeSaveController () 13 | 14 | @property (nonatomic, strong) IBOutlet NSTextField *schemeNameField; 15 | 16 | @property (nonatomic, strong) IBOutlet NSButton *bCancel; 17 | @property (nonatomic, strong) IBOutlet NSButton *bSave; 18 | 19 | @property (nonatomic, assign) BOOL saveButtonEnabled; 20 | @property (nonatomic, assign) BOOL nameInUse; 21 | 22 | @end 23 | 24 | 25 | @implementation MGSColourSchemeSaveController 26 | { 27 | void (^deleteCompletion)(BOOL); 28 | } 29 | 30 | /* 31 | * - init 32 | */ 33 | - (instancetype)init 34 | { 35 | self = [self initWithWindowNibName:@"MGSColourSchemeSave" owner:self]; 36 | return self; 37 | } 38 | 39 | 40 | /* 41 | * - awakeFromNib 42 | */ 43 | - (void)awakeFromNib 44 | { 45 | [self.window setDefaultButtonCell:[self.bSave cell]]; 46 | } 47 | 48 | 49 | #pragma mark - File Naming Sheet 50 | 51 | 52 | /* 53 | * - closeSheet 54 | */ 55 | - (IBAction)closeSheet:(id)sender 56 | { 57 | NSModalResponse response; 58 | 59 | if (sender == self.bSave) { 60 | response = NSModalResponseOK; 61 | } else { 62 | response = NSModalResponseCancel; 63 | } 64 | 65 | [self.window.sheetParent endSheet:self.window returnCode:response]; 66 | } 67 | 68 | 69 | /* 70 | * @property saveButtonEnabled 71 | */ 72 | + (NSSet *)keyPathsForValuesAffectingSaveButtonEnabled 73 | { 74 | return [NSSet setWithObjects:@"schemeName", @"usedSchemeNames", nil]; 75 | } 76 | 77 | 78 | - (BOOL)saveButtonEnabled 79 | { 80 | return self.schemeName && [self.schemeName length] > 0 && ![self.usedSchemeNames containsObject:self.schemeName]; 81 | } 82 | 83 | 84 | + (NSSet *)keyPathsForValuesAffectingNameInUse 85 | { 86 | return [NSSet setWithObjects:@"schemeName", @"usedSchemeNames", nil]; 87 | } 88 | 89 | 90 | - (BOOL)nameInUse 91 | { 92 | return [self.usedSchemeNames containsObject:self.schemeName]; 93 | } 94 | 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSFontWell.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSFontWell.h 3 | // Fragaria 4 | // 5 | // Created by Daniele Cattaneo on 27/05/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | 12 | /** 13 | * The MGSFontWell control is a text field which object value is a font and 14 | * can be first responder, which works similarly to NSColorWell. Its text is 15 | * fixed to a description of its font value. The action of this control 16 | * is changing its font. 17 | */ 18 | 19 | @interface MGSFontWell : NSControl 20 | 21 | 22 | /** The font object for this control */ 23 | @property (nonatomic) NSFont *selectedFont; 24 | 25 | /** Sets the value of the receiver to a font value obtained from the specified 26 | * object. 27 | * @param sender The object from which to take the value. This object must 28 | * respond to the -font message.*/ 29 | - (IBAction)takeFontFrom:(id)sender; 30 | 31 | /** Make the control first responder and order front the font panel. 32 | * @param sender The object who sent the message. */ 33 | - (IBAction)activate:(id)sender; 34 | 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSPreferencesProxyDictionary.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSPreferencesProxyDictionary.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/14/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | 11 | @class MGSUserDefaultsController; 12 | 13 | 14 | /** 15 | * An NSMutableDictionary subclass implemented by MGSUserDefaultsController so 16 | * that it can persist keys in the user defaults system, if desired. 17 | */ 18 | @interface MGSPreferencesProxyDictionary : NSMutableDictionary 19 | 20 | /* 21 | * A convenience initializer to assign the controller and dictionary contents. 22 | * using a different ID for preferences. 23 | * @param controller The instance of MGSUserDefaultsController owning this dictionary. 24 | * @param dictionary An initial dictionary of values to populate this dictionary. 25 | * @param preferencesID Specify a different groupID for this controller's 26 | * NSUserDefaults storage. The default if nil is the groupID of the 27 | * specified controller. 28 | */ 29 | - (instancetype)initWithController:(MGSUserDefaultsController *)controller 30 | dictionary:(NSDictionary *)dictionary 31 | preferencesID:(NSString *)preferencesID; 32 | 33 | /** 34 | * A convenience initializer to assign the controller and dictionary contents. 35 | * @param controller The instance of MGSUserDefaultsController owning this dictionary. 36 | * @param dictionary An initial dictionary of values to populate this dictionary. 37 | **/ 38 | - (instancetype)initWithController:(MGSUserDefaultsController *)controller dictionary:(NSDictionary *)dictionary; 39 | 40 | /** A reference to the controller that owns an instance of this class. */ 41 | @property (nonatomic,weak,readonly) MGSUserDefaultsController *controller; 42 | 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSPrefsColourPropertiesViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSPrefsColourPropertiesViewController.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/15/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class MGSMutableColourScheme; 13 | 14 | 15 | /** 16 | * MGSPrefsColourPropertiesViewController provides a basic class for managing 17 | * instances of the MGSPrefsColourProperties nib. 18 | **/ 19 | 20 | @interface MGSPrefsColourPropertiesViewController : MGSPrefsViewController 21 | 22 | 23 | @property (nonatomic, weak) IBOutlet NSObjectController *currentSchemeObjectController; 24 | 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSPrefsEditorPropertiesViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSPrefsEditorPropertiesViewController.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/15/15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | 12 | /** 13 | * MGSPrefsEditorPropertiesViewController provides a basic view controller for 14 | * managing and instance of the MGSPrefsEditorProperties nib. 15 | **/ 16 | 17 | @interface MGSPrefsEditorPropertiesViewController : MGSPrefsViewController 18 | 19 | 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSUserDefaults.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSUserDefaults.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/3/15. 6 | // 7 | /// @cond PRIVATE 8 | 9 | #import 10 | #import 11 | 12 | 13 | /** This macro defines the groupID that should correspond to the global group 14 | * for MGSUserDefaults and, by extension, MGSUserDefaultsController. */ 15 | #define MGSUSERDEFAULTS_GLOBAL_ID @"Global" 16 | 17 | 18 | /** 19 | * MGSUserDefaults is the NSUserDefaults internal replacement for use by 20 | * MGSUserDefaultsController. The main characteristic versus NSUserDefaults 21 | * is that it is assigned a `groupID` that is used to group multiple sets 22 | * of the same default together in a manner that is transparent to the 23 | * developer. 24 | * 25 | * In general user defaults managed by this class are not compatible with 26 | * NSUserDefaults. It's certainly possible to use NSUserDefaults to change 27 | * or read managed keys, but there's not much point. 28 | */ 29 | @interface MGSUserDefaults : NSUserDefaults 30 | 31 | 32 | #pragma mark - Class Methods - Singleton Controllers 33 | 34 | /** 35 | * Provides a shared controller for `groupID`. 36 | * @param groupID Indicates the identifier for this group 37 | * of user defaults. 38 | **/ 39 | + (instancetype)sharedUserDefaultsForGroupID:(NSString *)groupID; 40 | 41 | 42 | /** 43 | * Provides the shared controller for global defaults. 44 | **/ 45 | + (instancetype)sharedUserDefaults; 46 | 47 | 48 | #pragma mark - Instance Methods 49 | 50 | /** 51 | * Registers user defaults for this instance. 52 | * @param registrationDictionary The dictionary of values to register. 53 | **/ 54 | - (void)registerDefaults:(NSDictionary *)registrationDictionary; 55 | 56 | 57 | #pragma mark - Properties 58 | 59 | /** 60 | * Returns the groupID of this instance of the controller. 61 | **/ 62 | @property (nonatomic,strong,readonly) NSString *groupID; 63 | 64 | 65 | #pragma mark - Utility Methods 66 | 67 | 68 | + (id)defaultsObjectFromObject:(id)obj; 69 | 70 | 71 | + (id)objectFromDefaultsObject:(id)obj; 72 | 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/MGSUserDefaultsDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSUserDefaultsDelegate.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 9/6/18. 6 | // 7 | #include 8 | 9 | 10 | @protocol MGSUserDefaultsDelegate 11 | 12 | @optional 13 | /** Ask the delegate to provide a dictionary of MGSFragariaView properties 14 | * to be used for the given appearance. Properties not supplied by this 15 | * delegate method will use the built-in defaults, so a complete list is 16 | * not required. 17 | * 18 | * Informally, the AppDelegate can adopt this method without setting the 19 | * controller's delegate. This can be useful for overriding initial 20 | * defaults that are applied during instantiation before a delegate can 21 | * be set. 22 | */ 23 | - (NSDictionary *)defaultsForGroupID:(NSString*)groupID AppearanceName:(NSString *)appearanceName; 24 | 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/en-GB.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* Color Scheme Table View Global Option */ 2 | "Background" = "Background"; 3 | 4 | /* String for cancel button. */ 5 | "Cancel" = "Cancel"; 6 | 7 | /* Toolbar item name for the Colors preference pane */ 8 | "Colors" = "Colours"; 9 | 10 | /* Name for Custom Settings scheme. */ 11 | "Custom Settings" = "Custom Settings"; 12 | 13 | /* String for delete button. */ 14 | "Delete" = "Delete"; 15 | 16 | /* The text for the save/delete scheme button when it should read Delete Scheme… */ 17 | "Delete Scheme…" = "Delete Scheme…"; 18 | 19 | /* String to alert. */ 20 | "Delete the scheme?" = "Delete the scheme?"; 21 | 22 | /* String for alert information. */ 23 | "Deleted schemes cannot be restored." = "Deleted schemes cannot be restored."; 24 | 25 | /* Toolbar item name for the Editor preference pane */ 26 | "Editor" = "Editor"; 27 | 28 | /* Colour Scheme Table Header */ 29 | "Global Properties" = "Global Properties"; 30 | 31 | /* Color Scheme Table View Global Option */ 32 | "Insertion Point" = "Insertion Point"; 33 | 34 | /* Color Scheme Table View Global Option */ 35 | "Invisible Characters" = "Invisible Characters"; 36 | 37 | /* Hint explaining why certain items are bold. */ 38 | "Items in bold affect all of your views." = "Items in bold affect all of your views."; 39 | 40 | /* Default name for new schemes. */ 41 | "New Scheme" = "New Scheme"; 42 | 43 | /* The text for the save/delete scheme button when it should read Save Scheme… */ 44 | "Save Scheme…" = "Save Scheme…"; 45 | 46 | /* Color Scheme Table View Global Option */ 47 | "Selected Line Background" = "Selected Line Background"; 48 | 49 | /* Colour Scheme Table Header */ 50 | "Syntax Highlighting" = "Syntax Highlighting"; 51 | 52 | /* Color Scheme Table View Global Option */ 53 | "Syntax Error Background" = "Syntax Error Background"; 54 | 55 | /* Color Scheme Table View Global Option */ 56 | "Text" = "Text"; 57 | 58 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinator/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* Color Scheme Table View Global Option */ 2 | "Background" = "Background"; 3 | 4 | /* String for cancel button. */ 5 | "Cancel" = "Cancel"; 6 | 7 | /* Toolbar item name for the Colors preference pane */ 8 | "Colors" = "Colors"; 9 | 10 | /* Name for Custom Settings scheme. */ 11 | "Custom Settings" = "Custom Settings"; 12 | 13 | /* String for delete button. */ 14 | "Delete" = "Delete"; 15 | 16 | /* The text for the save/delete scheme button when it should read Delete Scheme… */ 17 | "Delete Scheme…" = "Delete Scheme…"; 18 | 19 | /* String to alert. */ 20 | "Delete the scheme?" = "Delete the scheme?"; 21 | 22 | /* String for alert information. */ 23 | "Deleted schemes cannot be restored." = "Deleted schemes cannot be restored."; 24 | 25 | /* Toolbar item name for the Editor preference pane */ 26 | "Editor" = "Editor"; 27 | 28 | /* Colour Scheme Table Header */ 29 | "Global Properties" = "Global Properties"; 30 | 31 | /* Color Scheme Table View Global Option */ 32 | "Insertion Point" = "Insertion Point"; 33 | 34 | /* Color Scheme Table View Global Option */ 35 | "Invisible Characters" = "Invisible Characters"; 36 | 37 | /* Hint explaining why certain items are bold. */ 38 | "Items in bold affect all of your views." = "Items in bold affect all of your views."; 39 | 40 | /* Default name for new schemes. */ 41 | "New Scheme" = "New Scheme"; 42 | 43 | /* The text for the save/delete scheme button when it should read Save Scheme… */ 44 | "Save Scheme…" = "Save Scheme…"; 45 | 46 | /* Color Scheme Table View Global Option */ 47 | "Selected Line Background" = "Selected Line Background"; 48 | 49 | /* Colour Scheme Table Header */ 50 | "Syntax Highlighting" = "Syntax Highlighting"; 51 | 52 | /* Color Scheme Table View Global Option */ 53 | "Syntax Error Background" = "Syntax Error Background"; 54 | 55 | /* Color Scheme Table View Global Option */ 56 | "Text" = "Text"; 57 | 58 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinatorTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinatorTests/MGSPrefsViewControllerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSPrefsViewControllerTests.m 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/22/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | 14 | /** 15 | * Adds some basic tests for MGSPrefsViewController. 16 | **/ 17 | @interface MGSPrefsViewControllerTests : XCTestCase 18 | 19 | @end 20 | 21 | 22 | @implementation MGSPrefsViewControllerTests 23 | 24 | /* 25 | * - setUp 26 | */ 27 | - (void)setUp 28 | { 29 | [super setUp]; 30 | } 31 | 32 | 33 | /* 34 | * - tearDown 35 | */ 36 | - (void)tearDown 37 | { 38 | [super tearDown]; 39 | } 40 | 41 | 42 | /* 43 | * - test_managedProperties 44 | */ 45 | - (void)test_managedProperties 46 | { 47 | MGSUserDefaultsController *controller = [MGSUserDefaultsController sharedControllerForGroupID:@"managedPropertiesTest"]; 48 | controller.managedProperties = [NSSet setWithArray:@[ MGSFragariaDefaultsShowsGutter, MGSFragariaDefaultsTextFont]]; 49 | 50 | MGSPrefsViewController *viewController = [[MGSPrefsEditorPropertiesViewController alloc] init]; 51 | viewController.userDefaultsController = controller; 52 | 53 | NSNumber *result = [viewController valueForKeyPath:@"managedProperties.showsGutter"]; 54 | XCTAssert([result boolValue] == YES); 55 | 56 | result = [viewController.managedProperties valueForKey:MGSFragariaDefaultsTextFont]; 57 | XCTAssert([result boolValue] == YES); 58 | 59 | result = [viewController.managedProperties valueForKey:@"SomeUnknownKey"]; 60 | XCTAssert([result boolValue] == NO); 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinatorTests/MGSUserDefaultsDefinitionsTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSUserDefaultsDefinitionsTests.m 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/9/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import "MGSFragariaView+Definitions.h" 12 | #import "MGSFragariaView.h" 13 | #import "MGSUserDefaultsUtilities.h" 14 | 15 | 16 | /** 17 | * Basic tests for MGSUserDefaultsDefinitions. 18 | **/ 19 | 20 | @interface MGSUserDefaultsDefinitionsTests : XCTestCase 21 | 22 | @end 23 | 24 | @implementation MGSUserDefaultsDefinitionsTests 25 | 26 | - (void)setUp 27 | { 28 | [super setUp]; 29 | } 30 | 31 | 32 | - (void)tearDown 33 | { 34 | [super tearDown]; 35 | } 36 | 37 | 38 | /* 39 | * Ensures that name-spacing inline function works correctly. 40 | */ 41 | - (void)test_namespace_function 42 | { 43 | NSString *expects = @"MGSFragariaDefaultsUseTabStops"; 44 | 45 | XCTAssert([expects isEqualToString:[MGSFragariaView namespacedKeyForKey:MGSFragariaDefaultsUseTabStops]]); 46 | } 47 | 48 | 49 | /* 50 | * Ensures the manually-managed defaults dictionary works. 51 | */ 52 | - (void)test_fragariaDefaultsDictionaryWithNamespace 53 | { 54 | NSLog(@"%@", [MGSFragariaView defaultsDictionaryWithNamespace]); 55 | id object = [[MGSFragariaView defaultsDictionaryWithNamespace] objectForKey:@"MGSFragariaDefaultsAutoCompleteDelay"]; 56 | XCTAssert(object != nil); 57 | } 58 | 59 | 60 | /* 61 | * Ensures all of the properties are still available in MGSFragariaView. 62 | */ 63 | - (void)test_properties_exist 64 | { 65 | NSDictionary *properties = [MGSUserDefaultsUtilities propertiesOfClass:[MGSFragariaView class]]; 66 | NSDictionary *localDict = [MGSFragariaView defaultsDictionary]; 67 | NSUInteger count = 0; 68 | 69 | for (NSString *key in [localDict allKeys]) 70 | { 71 | 72 | if (![[properties allKeys] containsObject:key] ) 73 | { 74 | count++; 75 | NSLog(@"Property `%@` not recognized.", key); 76 | } 77 | } 78 | XCTAssert(count == 0, @"%lu of %lu properties not recgonized. Consult the log output for results.", count, localDict.count); 79 | } 80 | 81 | 82 | 83 | 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /FragariaDefaultsCoordinatorTests/MGSUserDefaultsUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MGSUserDefaultsUtilities.h 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/4/15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | 12 | /** 13 | * This class implements some utilities required by MGSUserDefaults tests. 14 | **/ 15 | @interface MGSUserDefaultsUtilities : NSObject 16 | 17 | /** 18 | * Returns a dictionary of all visible properties of an object, including 19 | * those from all its superclasses. Courtesy of Duncan Babbage. 20 | * @param object The object for which you want to retrieve property 21 | * information. 22 | **/ 23 | + (NSDictionary *)propertiesOfObject:(id)object; 24 | 25 | 26 | /** 27 | * Returns a dictionary of all visible properties of a class, including 28 | * those from all its superclasses. Courtesy of Duncan Babbage. 29 | * @param class The class for which you want to retrieve property information. 30 | **/ 31 | + (NSDictionary *)propertiesOfClass:(Class)class; 32 | 33 | 34 | /** 35 | * Returns a dictionary of all visible properties that are specific to 36 | * a subclass. Properties for its superclasses are not included. 37 | * Courtesy of Duncan Babbage. 38 | * @param class The class for which you want to retrieve property information. 39 | **/ 40 | + (NSDictionary *)propertiesOfSubclass:(Class)class; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /FragariaTests/ColorSchemeTestCases/ColorScheme_NotAPlist.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1561 2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;} 3 | {\colortbl;\red255\green255\blue255;} 4 | {\*\expandedcolortbl;;} 5 | \margl1440\margr1440\vieww9000\viewh8400\viewkind0 6 | \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0 7 | 8 | \f0\fs24 \cf0 This is not a plist\ 9 | } -------------------------------------------------------------------------------- /FragariaTests/ColorSchemeTestCases/ColorScheme_WrongRootObject.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | this shouldn't be an array! 6 | 7 | 8 | -------------------------------------------------------------------------------- /FragariaTests/ColorSchemeTestCases/ColorScheme_WrongType1.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | backgroundColor 6 | 7 | this should be a string 8 | 9 | colourForAttributes 10 | 0.647465 0.467514 0.018687 11 | colourForAutocomplete 12 | 0.741762 0.213253 0.073530 13 | colourForCommands 14 | 0.127549 0.462659 0.782314 15 | colourForComments 16 | 0.505992 0.564858 0.563637 17 | colourForInstructions 18 | 0.777389 0.108025 0.435166 19 | colourForKeywords 20 | 0.777389 0.108025 0.435166 21 | colourForNumbers 22 | 0.127549 0.462659 0.782314 23 | colourForStrings 24 | 0.819270 0.108407 0.141457 25 | colourForVariables 26 | 0.647465 0.467514 0.018687 27 | coloursAttributes 28 | 1 29 | coloursAutocomplete 30 | 0 31 | coloursCommands 32 | 1 33 | coloursComments 34 | 1 35 | coloursInstructions 36 | 1 37 | coloursKeywords 38 | 1 39 | coloursNumbers 40 | 1 41 | coloursStrings 42 | 1 43 | coloursVariables 44 | 1 45 | currentLineHighlightColour 46 | 0.916111 0.890012 0.797811 47 | defaultSyntaxErrorHighlightingColour 48 | 0.989434 0.810012 0.594155 49 | displayName 50 | Solarized Light 51 | insertionPointColor 52 | 0.000000 0.000000 0.000000 53 | textColor 54 | 0.324366 0.407177 0.438506 55 | textInvisibleCharactersColour 56 | 0.505992 0.564858 0.563637 57 | 58 | 59 | -------------------------------------------------------------------------------- /FragariaTests/ColorSchemeTestCases/ColorScheme_WrongType2.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | backgroundColor 6 | 0.989434 0.957944 0.864060 7 | colourForAttributes 8 | 0.647465 0.467514 0.018687 9 | colourForAutocomplete 10 | 0.741762 0.213253 0.073530 11 | colourForCommands 12 | 0.127549 0.462659 0.782314 13 | colourForComments 14 | 0.505992 0.564858 0.563637 15 | colourForInstructions 16 | 0.777389 0.108025 0.435166 17 | colourForKeywords 18 | 0.777389 0.108025 0.435166 19 | colourForNumbers 20 | 0.127549 0.462659 0.782314 21 | colourForStrings 22 | 0.819270 0.108407 0.141457 23 | colourForVariables 24 | 0.647465 0.467514 0.018687 25 | coloursAttributes 26 | 1 27 | coloursAutocomplete 28 | 0 29 | coloursCommands 30 | This should be a number 31 | coloursComments 32 | 1 33 | coloursInstructions 34 | 1 35 | coloursKeywords 36 | 1 37 | coloursNumbers 38 | 1 39 | coloursStrings 40 | 1 41 | coloursVariables 42 | 1 43 | currentLineHighlightColour 44 | 0.916111 0.890012 0.797811 45 | defaultSyntaxErrorHighlightingColour 46 | 0.989434 0.810012 0.594155 47 | displayName 48 | Solarized Light 49 | insertionPointColor 50 | 0.000000 0.000000 0.000000 51 | textColor 52 | 0.324366 0.407177 0.438506 53 | textInvisibleCharactersColour 54 | 0.505992 0.564858 0.563637 55 | 56 | 57 | -------------------------------------------------------------------------------- /FragariaTests/ColorSchemeTestCases/ColorScheme_WrongType3.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | backgroundColor 6 | 0.989434 0.957944 0.864060 7 | colourForAttributes 8 | 0.647465 0.467514 0.018687 9 | colourForAutocomplete 10 | 0.741762 0.213253 0.073530 11 | colourForCommands 12 | 0.127549 0.462659 0.782314 13 | colourForComments 14 | 0.505992 0.564858 0.563637 15 | colourForInstructions 16 | 0.777389 0.108025 0.435166 17 | colourForKeywords 18 | 0.777389 0.108025 0.435166 19 | colourForNumbers 20 | 0.127549 0.462659 0.782314 21 | colourForStrings 22 | 0.819270 0.108407 0.141457 23 | colourForVariables 24 | 0.647465 0.467514 0.018687 25 | coloursAttributes 26 | 1 27 | coloursAutocomplete 28 | 0 29 | coloursCommands 30 | 1 31 | coloursComments 32 | 1 33 | coloursInstructions 34 | 1 35 | coloursKeywords 36 | 1 37 | coloursNumbers 38 | 1 39 | coloursStrings 40 | 1 41 | coloursVariables 42 | 1 43 | currentLineHighlightColour 44 | 0.916111 0.890012 0.797811 45 | defaultSyntaxErrorHighlightingColour 46 | 0.989434 0.810012 0.594155 47 | displayName 48 | 12345 49 | insertionPointColor 50 | 0.000000 0.000000 0.000000 51 | textColor 52 | 0.324366 0.407177 0.438506 53 | textInvisibleCharactersColour 54 | 0.505992 0.564858 0.563637 55 | 56 | 57 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/actionscript3_1.as: -------------------------------------------------------------------------------- 1 | package code 2 | { 3 | /***************************************** 4 | * based on textmate actionscript bundle 5 | ****************************************/ 6 | 7 | import fl.events.SliderEvent; 8 | 9 | public class Foo extends MovieClip 10 | { 11 | //************************* 12 | // Properties: 13 | 14 | public var activeSwatch:MovieClip; 15 | 16 | // Color offsets 17 | public var c1:Number = 0; // R 18 | 19 | //************************* 20 | // Constructor: 21 | 22 | public function Foo() 23 | { 24 | // Respond to mouse events 25 | swatch1_btn.addEventListener(MouseEvent.CLICK,swatchHandler,false,0,false); 26 | previewBox_btn.addEventListener(MouseEvent.MOUSE_DOWN,dragPressHandler); 27 | 28 | // Respond to drag events 29 | red_slider.addEventListener(SliderEvent.THUMB_DRAG,sliderHandler); 30 | 31 | // Draw a frame later 32 | addEventListener(Event.ENTER_FRAME,draw); 33 | } 34 | 35 | protected function clickHandler(event:MouseEvent):void 36 | { 37 | car.transform.colorTransform = new ColorTransform(0,0,0,1,c1,c2,c3); 38 | } 39 | 40 | protected function changeRGBHandler(event:Event):void 41 | { 42 | c1 = Number(c1_txt.text); 43 | 44 | if(!(c1>=0)){ 45 | c1 = 0; 46 | } 47 | 48 | updateSliders(); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/ampl_1.mod: -------------------------------------------------------------------------------- 1 | # SETS 2 | 3 | set I; # Oil types 4 | set J; # gasoline types 5 | 6 | # PARAMS 7 | 8 | param c{I}; # cost of each oil type, in euro/barrel 9 | param b{I}; # availability of each oil type, in barrels 10 | param r{J}; # revenue for each gasoline type, in euro/barrel 11 | param q_max{I,J} default 1; # min proportion of oil for each type of gasoline 12 | param q_min{I,J} default 0; # max proportion of oil for each type of gasoline 13 | 14 | var ChosenQty{I, J} >= 0; # in gallons 15 | 16 | maximize Balance: 17 | sum {j in J} ( r[j] * (sum {i in I} ChosenQty[i, j]) 18 | - (sum {i in I} c[i] * ChosenQty[i, j])); 19 | 20 | subject to UseExactlyAllTheOil {i in I}: 21 | (sum {j in J} ChosenQty[i, j]) = b[i]; 22 | 23 | subject to MaximumOilQuantity {i in I, j in J}: 24 | ChosenQty[i, j] <= (sum {k in I} ChosenQty[k, j]) * q_max[i, j]; 25 | 26 | subject to MinimumOilQuantity {i in I, j in J}: 27 | ChosenQty[i, j] >= (sum {k in I} ChosenQty[k, j]) * q_min[i, j]; 28 | 29 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/apex_class_1.apex: -------------------------------------------------------------------------------- 1 | // 2 | // Generated by JSON2Apex http://json2apex.herokuapp.com/ 3 | // 4 | 5 | public class JSON2Apex { 6 | 7 | public class User { 8 | public String name {get;set;} 9 | public String twitter {get;set;} 10 | 11 | public User(JSONParser parser) { 12 | while (parser.nextToken() != System.JSONToken.END_OBJECT) { 13 | if (parser.getCurrentToken() == System.JSONToken.FIELD_NAME) { 14 | String text = parser.getText(); 15 | if (parser.nextToken() != System.JSONToken.VALUE_NULL) { 16 | if (text == 'name') { 17 | name = parser.getText(); 18 | } else if (text == 'twitter') { 19 | twitter = parser.getText(); 20 | } else { 21 | System.debug(LoggingLevel.WARN, 'User consuming unrecognized property: '+text); 22 | consumeObject(parser); 23 | } 24 | } 25 | } 26 | } 27 | } 28 | } 29 | 30 | public User user {get;set;} 31 | 32 | public JSON2Apex(JSONParser parser) { 33 | while (parser.nextToken() != System.JSONToken.END_OBJECT) { 34 | if (parser.getCurrentToken() == System.JSONToken.FIELD_NAME) { 35 | String text = parser.getText(); 36 | if (parser.nextToken() != System.JSONToken.VALUE_NULL) { 37 | if (text == 'user') { 38 | user = new User(parser); 39 | } else { 40 | System.debug(LoggingLevel.WARN, 'JSON2Apex consuming unrecognized property: '+text); 41 | consumeObject(parser); 42 | } 43 | } 44 | } 45 | } 46 | } 47 | 48 | 49 | public static JSON2Apex parse(String json) { 50 | System.JSONParser parser = System.JSON.createParser(json); 51 | return new JSON2Apex(parser); 52 | } 53 | 54 | public static void consumeObject(System.JSONParser parser) { 55 | Integer depth = 0; 56 | do { 57 | System.JSONToken curr = parser.getCurrentToken(); 58 | if (curr == System.JSONToken.START_OBJECT || 59 | curr == System.JSONToken.START_ARRAY) { 60 | depth++; 61 | } else if (curr == System.JSONToken.END_OBJECT || 62 | curr == System.JSONToken.END_ARRAY) { 63 | depth--; 64 | } 65 | } while (depth > 0 && parser.nextToken() != null); 66 | } 67 | 68 | 69 | 70 | 71 | } -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/apex_trigger_1.apex: -------------------------------------------------------------------------------- 1 | trigger AddRelatedRecord on Account(after insert, after update) { 2 | List oppList = new List(); 3 | 4 | // Get the related opportunities for the accounts in this trigger 5 | Map acctsWithOpps = new Map([SELECT Id,(SELECT Id FROM Opportunities) FROM Account WHERE Id IN :Trigger.New]); 6 | 7 | // Add an opportunity for each account if it doesn't already have one. 8 | // Iterate through each account. 9 | for(Account a : Trigger.New) { 10 | System.debug('acctsWithOpps.get(a.Id).Opportunities.size()=' + acctsWithOpps.get(a.Id).Opportunities.size()); 11 | // Check if the account already has a related opportunity. 12 | if (acctsWithOpps.get(a.Id).Opportunities.size() == 0) { 13 | // If it doesn't, add a default opportunity 14 | oppList.add(new Opportunity(Name=a.Name + ' Opportunity', 15 | StageName='Prospecting', 16 | CloseDate=System.today().addMonths(1), 17 | AccountId=a.Id)); 18 | } 19 | } 20 | if (oppList.size() > 0) { 21 | insert oppList; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/asm-x86_1.asm-nasm: -------------------------------------------------------------------------------- 1 | ; Example file for nasm.xml kate syntax file 2 | ; compile with `nasm example.asm -f elf -o example.o` 3 | ; and link with 'gcc example.o -o example` 4 | ; Public domain 5 | ; kate: hl Intel x86 (NASM); 6 | 7 | section .data 8 | 9 | hello dd 'Hello World', 0x0A, 0h 10 | printf_param dd '%s', 0q 11 | 12 | section .text 13 | 14 | extern printf 15 | 16 | global main 17 | main: 18 | push ebp 19 | mov ebp, esp 20 | 21 | push hello 22 | push printf_param 23 | call printf 24 | 25 | mov eax, 0b 26 | leave 27 | ret 28 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/asm-x86_2.asm: -------------------------------------------------------------------------------- 1 | section .text 2 | global main ;must be declared for using gcc 3 | 4 | main: ;tell linker entry point 5 | 6 | mov edx, len ;message length 7 | mov ecx, msg ;message to write 8 | mov ebx, 1 ;file descriptor (stdout) 9 | mov eax, 4 ;system call number (sys_write) 10 | int 0x80 ;call kernel 11 | 12 | mov eax, 1 ;system call number (sys_exit) 13 | int 0x80 ;call kernel 14 | 15 | section .data 16 | 17 | msg db 'Hello, world!',0xa ;our dear string 18 | len equ $ - msg ;length of our dear string 19 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/asp-vb_1.asp: -------------------------------------------------------------------------------- 1 | <% 'kate: hl ASP; 2 | if ( instr(request.servervariables("PATH_INFO"),"login.asp") <= 0 and instr(request.servervariables("PATH_INFO"),"inset") <= 0 and instr(request.servervariables("PATH_INFO"),"Data") <= 0 and instr(request.servervariables("PATH_INFO"),"dropDown") <= 0 ) then 3 | Session("originalRequestedPage") = Request.ServerVariables("PATH_INFO") & "?" & Request.ServerVariables("QUERY_STRING") 4 | end if 5 | 6 | function countRecords( rsToCount ) 7 | numRecs = 0 8 | 9 | do until rsToCount.eof 10 | numRecs = numRecs + 1 11 | 12 | rsToCount.movenext 13 | loop 14 | 15 | rsToCount.close ' just to make sure nobody 16 | ' tries to operate on the recordset, 17 | ' which has already reached eof 18 | 19 | countRecords = numRecs 20 | end function 21 | 22 | function unique( rs, sortColumn ) ' return unique instances of text in sortColumn within rs 23 | dim sorted() 24 | 25 | redim sorted(1) 26 | dim i 27 | i = 0 28 | do until rs.eof 29 | if (not find( rs(sortColumn), sorted )) then 30 | redim preserve sorted(i+1) 31 | sorted(i) = rs(sortColumn) 32 | i = i + 1 33 | end if 34 | rs.MoveNext 35 | loop 36 | 37 | redim preserve sorted(i-1) ' the function will add an extra blank entry to the array 38 | 39 | rs.Close ' close the recordset - we'll be using it again - and reset i - well be using it again, too 40 | 41 | unique = sorted 42 | end function 43 | 44 | sub testSub( variable ) ' do nothing impressive... 45 | dim newVar 46 | 47 | newVar = variable 48 | 49 | if ( variable = true ) 50 | response.end 51 | else %> 52 | 53 |

We are writing text.

54 |

<%=newVar%>

55 |

We have written text and outputted a variable.

56 | 57 | <% end if 58 | end sub %> -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/awk_1.awk: -------------------------------------------------------------------------------- 1 | #!/usr 2 | # AWK hl test 3 | 4 | # BEGIN and END are also matched as patterns 5 | BEGIN { 6 | p = 0; 7 | } 8 | 9 | /some pattern/ { 10 | p++; 11 | } 12 | 13 | # / inside brackets is not considered end of expression 14 | # a loose division operator (/) is not mismatched as a pattern. 15 | $1 =~ /[^abc/]def/ || b == 3 / 5 { 16 | 17 | gsub ( FILENAME ); 18 | 19 | } 20 | 21 | # TODO and FIXME also work in comments in Awk. 22 | 23 | # Also backslash in patterns works. 24 | /\/usr\/bin\/awk/ { print "This is me"; } 25 | 26 | END { 27 | print p; 28 | } 29 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/batch_1.bat: -------------------------------------------------------------------------------- 1 | :: batch file highlighting in Ace! 2 | @echo off 3 | 4 | CALL set var1=%cd% 5 | echo unhide everything in %var1%! 6 | 7 | :: FOR loop in bat is super strange! 8 | FOR /f "tokens=*" %%G IN ('dir /A:D /b') DO ( 9 | echo %var1%%%G 10 | attrib -r -a -h -s "%var1%%%G" /D /S 11 | ) 12 | 13 | pause 14 | 15 | REM that's all 16 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/c_1.c: -------------------------------------------------------------------------------- 1 | // NOTE: This is a test file for kate's LPC syntax highlighting. 2 | 3 | // This is a Single-Line Comment 4 | /* This is a Multi- 5 | Line Comment */ 6 | 7 | // This again is a Single-Line Comment which should end here /* 8 | 9 | // And this is an evil single line comment \ 10 | which should include this and the next line because of the \ 11 | Do not use this style at home, kids. 12 | // BEGIN region marker 13 | 14 | // END of region marker 15 | 16 | private void create() 17 | { 18 | // Some Preprocessor stuff: 19 | #define SOME_STUFF if(foo("bar")) \ 20 | { \ 21 | bar("foo"); \ 22 | } // Preprocessor, Keyword, Preprocessor-String, Multiline 23 | 24 | // Some closures: 25 | #'create; 26 | #'?!; 27 | 28 | 29 | /* Some other Data Types: */ 30 | 31 | int i = 1; // Integer. 32 | float b = 2.34; // Float. 33 | int c = 0b001; // Binary 34 | int e = 0x019Beef; // Hexadecimal 35 | int f = 0o2345; // Octal 36 | string a = "Wheee"; // String 37 | string x = "Wheee\ 38 | heee"; // Multi-Line String, again, don't use this. 39 | 40 | 41 | 42 | /* Some keywords: */ 43 | if(1) 44 | { 45 | switch(2) 46 | { 47 | case 3: 48 | 4; 49 | break; 50 | } 51 | } 52 | 53 | else 54 | { 55 | return 0; 56 | } 57 | } 58 | 59 | /* 60 | WARNING: If the above function is part of a multi-line comment, 61 | it's buggy. The WARNING: itself should be a comment-keyword. 62 | That's not actually part of the language, but simply used 63 | to highlight important stuff inside comments like TODO: etc. 64 | */ 65 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/coffeescript_1.coffee: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env coffee 2 | 3 | try 4 | throw URIError decodeURI(0xC0ffee * 123456.7e-8 / .9) 5 | catch e 6 | console.log 'qstring' + "qqstring" + ''' 7 | qdoc 8 | ''' + """ 9 | qqdoc 10 | """ 11 | 12 | do -> 13 | ### 14 | herecomment 15 | ### 16 | re = /regex/imgy.test /// 17 | heregex # comment 18 | ///imgy 19 | this isnt: `just JavaScript` 20 | undefined 21 | 22 | sentence = "#{ 22 / 7 } is a decent approximation of π" -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/coldfusion_1.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #welcome# -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/cpp_2.cpp: -------------------------------------------------------------------------------- 1 | // compound assignment operators 2 | 3 | #include 4 | 5 | #include \ 6 | 7 | 8 | #include \ 9 | \ 10 | 11 | 12 | #include \ 13 | \ 14 | "iostream" 15 | 16 | #include 17 | #include "boost/asio/io_service.hpp" 18 | 19 | #include \ 20 | \ 21 | "iostream" \ 22 | "string" \ 23 | 24 | 25 | using namespace std; 26 | 27 | // 28 | int main () 29 | { 30 | int a, b=3; /* foobar */ 31 | a = b; // single line comment\ 32 | continued 33 | a+=2; // equivalent to a=a+2 34 | cout << a; 35 | #if VERBOSE >= 2 36 | prints("trace message\n"); 37 | #endif 38 | return 0; 39 | } 40 | 41 | /* Print an error message and get out */ 42 | #define ABORT \ 43 | do { \ 44 | print( "Abort\n" ); \ 45 | exit(8); \ 46 | } while (0) /* Note: No semicolon */ -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/csharp_1.cs: -------------------------------------------------------------------------------- 1 | public void HelloWorld() { 2 | //Say Hello! 3 | Console.WriteLine("Hello World"); 4 | } -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/csound_1.csd: -------------------------------------------------------------------------------- 1 | text 2 | 3 | 4 | 0dbfs = 1 5 | prints "hello, world\n" 6 | 7 | 8 | i 1 0 0 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/css_1.css: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a pseudo CSS file to test Kate's CSS syntax highlighting. 3 | */ 4 | 5 | @import url("othersheet.css") screen, tv; 6 | 7 | body { 8 | font-size: 15pt; 9 | font-family: Verdana, Helvetica, "Bitstream Vera Sans", sans-serif; 10 | margin-top: 0px; /* yet another comment */ 11 | margin-bottom: 0px; 12 | // this is no comment, it's just broken! 13 | margin-left: 0px; 14 | margin-right: 0px; 15 | } 16 | 17 | .something 18 | { 19 | margin-right: 0px; 20 | color: #cdd; 21 | color: #AAFE04; 22 | color: rgb(10%,30%,43%); 23 | background: maroon; 24 | } 25 | 26 | a:hover { 27 | } 28 | 29 | #header, 30 | p.intro:first-letter, 31 | p:lang(nl), 32 | img[align="right"] 33 | { 34 | border: 1px solid Qt::red !important; 35 | -moz-border-radius: 15px; /* unknown properties render italic */ 36 | } 37 | 38 | @media print { 39 | 40 | #header 41 | { 42 | display: none; 43 | } 44 | 45 | } 46 | 47 | /* 48 | TODO: add more tests, e.g. media 49 | */ 50 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/css_2.css: -------------------------------------------------------------------------------- 1 | .text-layer { 2 | font: 12px Monaco, "Courier New", monospace; 3 | cursor: text; 4 | } 5 | 6 | .blinker { 7 | animation: blink 1s linear infinite alternate; 8 | } 9 | 10 | @keyframes blink { 11 | 0%, 40% { 12 | opacity: 0; /* 13 | */ 14 | opacity: 1 15 | } 16 | 17 | 40.5%, 100% { 18 | opacity: 1 19 | } 20 | } 21 | 22 | @document url(http://c9.io/), url-prefix(http://ace.c9.io/build/), 23 | domain(c9.io), regexp("https:.*") /**/ 24 | { 25 | /**/ 26 | img[title]:before 27 | { 28 | content: attr(title) "\AImage \ 29 | retrieved from" 30 | attr(src); /* 31 | */ 32 | white-space: pre; 33 | display: block; 34 | background: url(asdasd); "err 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/d_1.d: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rdmd 2 | // Computes average line length for standard input. 3 | import std.stdio; 4 | 5 | void main() { 6 | ulong lines = 0; 7 | double sumLength = 0; 8 | foreach (line; stdin.byLine()) { 9 | ++lines; 10 | sumLength += line.length; 11 | } 12 | writeln("Average line length: ", 13 | lines ? sumLength / lines : 0); 14 | } -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/eiffel_1.e: -------------------------------------------------------------------------------- 1 | note 2 | description: "Represents a person." 3 | 4 | class 5 | PERSON 6 | 7 | create 8 | make, make_unknown 9 | 10 | feature {NONE} -- Creation 11 | 12 | make (a_name: like name) 13 | -- Create a person with `a_name' as `name'. 14 | do 15 | name := a_name 16 | ensure 17 | name = a_name 18 | end 19 | 20 | make_unknown 21 | do ensure 22 | name = Void 23 | end 24 | 25 | feature -- Access 26 | 27 | name: detachable STRING 28 | -- Full name or Void if unknown. 29 | 30 | end -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/erl_2.erl: -------------------------------------------------------------------------------- 1 | %% A process whose only job is to keep a counter. 2 | %% First version 3 | -module(counter). 4 | -export([start/0, codeswitch/1]). 5 | 6 | start() -> loop(0). 7 | 8 | loop(Sum) -> 9 | receive 10 | {increment, Count} -> 11 | loop(Sum+Count); 12 | {counter, Pid} -> 13 | Pid ! {counter, Sum}, 14 | loop(Sum); 15 | code_switch -> 16 | ?MODULE:codeswitch(Sum) 17 | % Force the use of 'codeswitch/1' from the latest MODULE version 18 | end. 19 | 20 | codeswitch(Sum) -> loop(Sum). -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/fortran_2.f90: -------------------------------------------------------------------------------- 1 | #include "globalDefines.h" 2 | 3 | !========================================================= 4 | program main 5 | !========================================================= 6 | use params_module, only : nx, ny, nz 7 | 8 | implicit none 9 | 10 | integer, parameter :: g = 9.81 11 | real, allocatable, dimension(:,:,:) :: array 12 | integer :: a, b, c 13 | real*8 :: x, y, z 14 | 15 | b = 5 16 | c = 7 17 | 18 | #ifdef ARRAY_COMP 19 | allocate(array(10,10,10), status=a) 20 | 21 | write(c,'(i5.5)') b 22 | #endif 23 | 24 | if(x.lt.5.0) then 25 | array(:,:,:) = g 26 | else 27 | array(:,:,:) = x - y 28 | endif 29 | 30 | return 31 | !======================================================== 32 | end program main 33 | !======================================================== 34 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/haskell_2.hs: -------------------------------------------------------------------------------- 1 | -- Type annotation (optional) 2 | fib :: Int -> Integer 3 | 4 | -- With self-referencing data 5 | fib n = fibs !! n 6 | where fibs = 0 : scanl (+) 1 fibs 7 | -- 0,1,1,2,3,5,... 8 | 9 | -- Same, coded directly 10 | fib n = fibs !! n 11 | where fibs = 0 : 1 : next fibs 12 | next (a : t@(b:_)) = (a+b) : next t 13 | 14 | -- Similar idea, using zipWith 15 | fib n = fibs !! n 16 | where fibs = 0 : 1 : zipWith (+) fibs (tail fibs) 17 | 18 | -- Using a generator function 19 | fib n = fibs (0,1) !! n 20 | where fibs (a,b) = a : fibs (b,a+b) -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/html_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 |

Juhu Kinners

16 | 17 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/java_1.java: -------------------------------------------------------------------------------- 1 | public class InfiniteLoop { 2 | 3 | /* 4 | * This will cause the program to hang... 5 | * 6 | * Taken from: 7 | * http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/ 8 | */ 9 | public static void main(String[] args) { 10 | double d = Double.parseDouble("2.2250738585072012e-308"); 11 | 12 | // unreachable code 13 | System.out.println("Value: " + d); 14 | } 15 | } -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/javascript_2.js: -------------------------------------------------------------------------------- 1 | function foo(items, nada) { 2 | for (var i=0; i 2 | 3 | 8 | 13 | 14 |

15 | Today's date: <%= (new java.util.Date()).toLocaleString()%> 16 |

17 | <%! int i = 0; %> 18 | 19 | int j = 10; 20 | 21 | 22 | <%-- This is JSP comment --%> 23 | <%@ directive attribute="value" %> 24 | 25 |

Select Languages:

26 | 27 |
28 | Java
29 | .NET
30 | PHP
31 | C/C++
32 | PERL
33 | 34 |
35 | 36 | <% 37 | String select[] = request.getParameterValues("id"); 38 | if (select != null && select.length != 0) { 39 | out.println("You have selected: "); 40 | for (int i = 0; i < select.length; i++) { 41 | out.println(select[i]); 42 | } 43 | } 44 | %> 45 | 46 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/latex_1.tex: -------------------------------------------------------------------------------- 1 | % LaTeX test file for kate's syntax highlighting and code folding 2 | 3 | \ordinaryLaTeXcommandwithoption[10pt,a4paper]{article} 4 | % BEGIN region 5 | %comment, this is all ok % $ 6 | \%no comments please 7 | \\%comment 8 | % END of region 9 | 10 | \newcommand{\nohighlighting} 11 | 12 | \section{normal} 13 | 14 | \ref{blue} 15 | \pageref{blue} 16 | \cite{blue} 17 | 18 | \begin{environmentshavespecialcolors} 19 | normal 20 | \end{environmentshavespecialcolors} 21 | 22 | $equations are green, \commands somewhat darker$ 23 | normal 24 | $$equations are green, \commands somewhat darker$$ 25 | normal 26 | \( 27 | \frac{1}{2} 28 | \begin{test} 29 | \end{test} 30 | \) 31 | normal 32 | \[ 33 | %comment 34 | displaymath 35 | \] 36 | normal 37 | \begin{equation} 38 | green\darkergreen 39 | \begin{test} 40 | \test 41 | \end{test} 42 | \end{equation} 43 | 44 | \begin{equation*} 45 | green\darkergreen 46 | %comment 47 | \begin{test} 48 | \test 49 | \end{test} 50 | \%no comment 51 | \end{equation*} 52 | 53 | \{ %this should be comment 54 | 55 | \verb%this shouldn't be%and this should be normal text 56 | 57 | \begin{verbatim} 58 | text inside a verbatim environment is also treated special $ %, 59 | you can even put a \begin{verbatim} inside 60 | \end{verbatim} 61 | 62 | normal 63 | 64 | \begin{Verbatim} 65 | &@@#^%&^#$ 66 | \end{Verbatim} 67 | 68 | \begin{Verbatim*} 69 | @*&^#@*(^#(*@& 70 | \end{Verbatim*} 71 | 72 | normal 73 | 74 | % test alignat 75 | \begin{alignat}{2} 76 | A &= B &= C \\ 77 | A &= B &= C 78 | \end{alignat} 79 | normal text 80 | 81 | \iffalse 82 | \fill commented out text 83 | \fi 84 | 85 | 86 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/latex_2.tex: -------------------------------------------------------------------------------- 1 | \usepackage{amsmath} 2 | \title{\LaTeX} 3 | \date{} 4 | \begin{document} 5 | \maketitle 6 | \LaTeX{} is a document preparation system for the \TeX{} 7 | typesetting program. It offers programmable desktop publishing 8 | features and extensive facilities for automating most aspects of 9 | typesetting and desktop publishing, including numbering and 10 | cross-referencing, tables and figures, page layout, bibliographies, 11 | and much more. \LaTeX{} was originally written in 1984 by Leslie 12 | Lamport and has become the dominant method for using \TeX; few 13 | people write in plain \TeX{} anymore. The current version is 14 | \LaTeXe. 15 | 16 | % This is a comment; it will not be shown in the final output. 17 | % The following shows a little of the typesetting power of LaTeX: 18 | \begin{align} 19 | E &= mc^2 \\ 20 | m &= \frac{m_0}{\sqrt{1-\frac{v^2}{c^2}}} 21 | \end{align} 22 | \end{document} -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/lisp_2.lisp: -------------------------------------------------------------------------------- 1 | ;; This test file tests kates common lisp highlighting 2 | #| 3 | multilinecomment :) 4 | |# 5 | 6 | ;BEGIN region marker 7 | 8 | ;END end 9 | 10 | (defun bin-search (obj vec) 11 | (let ((len (length vec))) 12 | (and (not (zerop len)) 13 | (finder obj vec 0 (- len 1))))) 14 | 15 | (defun parse-date (str) 16 | (let ((toks (tokens str #'constituent 0))) 17 | (list (parse-integer (first toks)) 18 | (parse-month (second toks)) 19 | (parse-integer (third toks))))) 20 | 21 | (defconstant month-names 22 | #("jan" "feb" "mar" "apr" "may" "jun" 23 | "jul" "aug" "sep" "oct" "nov" "dec")) 24 | 25 | (defstruct buf 26 | vec (start -1) (used -1) (new -1) (end -1)) 27 | 28 | (defparameter *words* (make-hash-table :size 10000)) 29 | 30 | (defmacro while (test &rest body) 31 | `(do () 32 | ((not ,test)) 33 | ,@body)) 34 | 35 | (define-modify-macro append1f (val) 36 | (lambda (lst val) (append lst (list val)))) 37 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/lisp_3.lisp: -------------------------------------------------------------------------------- 1 | (defun prompt-for-cd () 2 | "Prompts 3 | for CD" 4 | (prompt-read "Title" 1.53 1 2/4 1.7 1.7e0 2.9E-4 +42 -7 #b001 #b001/100 #o777 #O777 #xabc55 #c(0 -5.6)) 5 | (prompt-read "Artist" &rest) 6 | (or (parse-integer (prompt-read "Rating") :junk-allowed t) 0) 7 | (if x (format t "yes") (format t "no" nil) ;and here comment 8 | ) 0xFFLL -23ull 9 | ;; second line comment 10 | '(+ 1 2) 11 | (defvar *lines*) ; list of all lines 12 | (position-if-not #'sys::whitespacep line :start beg)) 13 | (quote (privet 1 2 3)) 14 | '(hello world) 15 | (* 5 7) 16 | (1 2 34 5) 17 | (:use "aaaa") 18 | (let ((x 10) (y 20)) 19 | (print (+ x y)) 20 | ) LAmbDa 21 | 22 | "asdad\0eqweqe" -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/lua_1.lua: -------------------------------------------------------------------------------- 1 | --[[-- 2 | num_args takes in 5.1 byte code and extracts the number of arguments 3 | from its function header. 4 | --]]-- 5 | 6 | function int(t) 7 | return t:byte(1)+t:byte(2)*0x100+t:byte(3)*0x10000+t:byte(4)*0x1000000 8 | end 9 | 10 | function num_args(func) 11 | local dump = string.dump(func) 12 | local offset, cursor = int(dump:sub(13)), offset + 26 13 | --Get the params and var flag (whether there's a ... in the param) 14 | return dump:sub(cursor):byte(), dump:sub(cursor+1):byte() 15 | end 16 | 17 | -- Usage: 18 | num_args(function(a,b,c,d, ...) end) -- return 4, 7 19 | 20 | -- Python styled string format operator 21 | local gm = debug.getmetatable("") 22 | 23 | gm.__mod=function(self, other) 24 | if type(other) ~= "table" then other = {other} end 25 | for i,v in ipairs(other) do other[i] = tostring(v) end 26 | return self:format(unpack(other)) 27 | end 28 | 29 | print([===[ 30 | blah blah %s, (%d %d) 31 | ]===]%{"blah", num_args(int)}) 32 | 33 | --[=[-- 34 | table.maxn is deprecated, use # instead. 35 | --]=]-- 36 | print(table.maxn{1,2,[4]=4,[8]=8) -- outputs 8 instead of 2 37 | 38 | print(5 --[[ blah ]]) -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/matlab_1.m: -------------------------------------------------------------------------------- 1 | %%===================================================== 2 | % MATLAB test code for Kate/Kwrite syntax highlighting 3 | % kate: hl Matlab 4 | %%===================================================== 5 | 6 | % Numbers _____________________________________________ 7 | 5, 5.5, .1, 0.1, 0.4e5, 1.2e-5, 5i, 5.3i, 6j, .345+3i 8 | 5', 5.5', .1', 0.1', 0.4e5', 1.2e-5', 5i', 5.3i', 6j', .345+3i' 9 | 10 | % Operators ___________________________________________ 11 | % relational operators 12 | 'asdf'~=4, c<=4, d>=4, ab, a==b, b||c, b&&c 13 | % elementwise arithmetic operators 14 | a.^b, a.*b a./b, 1:4:5 15 | % single-character binary arithmetic 16 | a+3, a-3, a*2, a^3, a/3, a\3, a|b, a&b 17 | % unary operators 18 | a = ~g; g = @sfdgdsf(sdfsd,345); g.' + 1i.' - ('asdf').' 19 | % separators and delimiter 20 | (asd),[sadf];{asdf},;;,;;;() 21 | % continuation 22 | a = 1+ ... 23 | 2; 24 | 25 | % Strings and adjoint _________________________________ 26 | % incomplete strings 27 | 'string 28 | 'str'' 29 | 'str''ing 30 | % complete strings 31 | 'string' % simple string 32 | '''' % string containing ' 33 | 'str''ing' % one string containing ' 34 | 'string' 'string' % two strings 35 | 'asdf' 'asdf''' variable % two strings and a variable 36 | 'asdf''asdf'' fsgdfg' + (asdf)' - 'asdf'.' + []''''.';'' 37 | 'sadf'.' % string transpose 38 | % adjoint 39 | {'asdf'}' + 1 40 | ('asdf')' + 1 41 | ['asdf']' + 1 42 | '' var''' % empty string, var with >1 adjoints 43 | [5]'*{5}'*('asd')'.'+(5)'*6'*asdf'*asdf'.' % many adjoints 44 | A'*B + 1 % adjoint 45 | A.'*B + 1 % transpose 46 | A.'.'*B + 1 % double transpose 47 | A'.' + 1 % adjoint, then transpose 48 | A.'' % transpose, then adjoint 49 | 50 | % System command ______________________________________ 51 | !hostname 52 | !cp * /tmp 53 | 54 | % Reserved keywords ___________________________________ 55 | function, persistent, global 56 | switch, case, otherwise 57 | if, else, elseif 58 | try, catch 59 | for, while, break, continue 60 | end, return 61 | function, FUNCTION, Function % case sensitive! -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/matlab_2.matlab: -------------------------------------------------------------------------------- 1 | %{ 2 | %{ 3 | Ace Matlab demo 4 | %} 5 | %} 6 | 7 | classdef hello 8 | methods 9 | function greet(this) 10 | disp('Hello!') % say hi 11 | end 12 | end 13 | end 14 | 15 | % transpose 16 | a = [ 'x''y', "x\n\ 17 | y", 1' ]' + 2' -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/mel_1.mel: -------------------------------------------------------------------------------- 1 | // animated duplicates, instances script 2 | proc animatedDuplication (int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance) 3 | { 4 | int $range_start = $rangeStart; 5 | int $range_end = $rangeEnd; 6 | int $num_of_duplicates = $numOfDuplicates; 7 | int $step_size = ($range_end - $range_start) / $num_of_duplicates; 8 | int $i = 0; 9 | int $temp; 10 | 11 | currentTime $range_start; // set to range start 12 | 13 | string $selectedObjects[]; // to store selected objects 14 | $selectedObjects = `ls -sl`; // store selected objects 15 | select $selectedObjects; 16 | 17 | while ($i <= $num_of_duplicates) 18 | { 19 | $temp = $range_start + ($step_size * $i); 20 | currentTime ($temp); 21 | // seleced the objects to duplicate or instance 22 | select $selectedObjects; 23 | if($duplicateOrInstance == 0) 24 | { 25 | duplicate; 26 | } 27 | else 28 | { 29 | instance; 30 | } 31 | $i++; 32 | } 33 | } -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/objectivecaml_2.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * Example of early return implementation taken from 3 | * http://ocaml.janestreet.com/?q=node/91 4 | *) 5 | 6 | let with_return (type t) (f : _ -> t) = 7 | let module M = 8 | struct exception Return of t end 9 | in 10 | let return = { return = (fun x -> raise (M.Return x)); } in 11 | try f return with M.Return x -> x 12 | 13 | 14 | (* Function that uses the 'early return' functionality provided by `with_return` *) 15 | let sum_until_first_negative list = 16 | with_return (fun r -> 17 | List.fold list ~init:0 ~f:(fun acc x -> 18 | if x >= 0 then acc + x else r.return acc)) -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/pascal_1.pas: -------------------------------------------------------------------------------- 1 | (***************************************************************************** 2 | * A simple bubble sort program. Reads integers, one per line, and prints * 3 | * them out in sorted order. Blows up if there are more than 49. * 4 | *****************************************************************************) 5 | PROGRAM Sort(input, output); 6 | CONST 7 | (* Max array size. *) 8 | MaxElts = 50; 9 | TYPE 10 | (* Type of the element array. *) 11 | IntArrType = ARRAY [1..MaxElts] OF Integer; 12 | 13 | VAR 14 | (* Indexes, exchange temp, array size. *) 15 | i, j, tmp, size: integer; 16 | 17 | (* Array of ints *) 18 | arr: IntArrType; 19 | 20 | (* Read in the integers. *) 21 | PROCEDURE ReadArr(VAR size: Integer; VAR a: IntArrType); 22 | BEGIN 23 | size := 1; 24 | WHILE NOT eof DO BEGIN 25 | readln(a[size]); 26 | IF NOT eof THEN 27 | size := size + 1 28 | END 29 | END; 30 | 31 | BEGIN 32 | (* Read *) 33 | ReadArr(size, arr); 34 | 35 | (* Sort using bubble sort. *) 36 | FOR i := size - 1 DOWNTO 1 DO 37 | FOR j := 1 TO i DO 38 | IF arr[j] > arr[j + 1] THEN BEGIN 39 | tmp := arr[j]; 40 | arr[j] := arr[j + 1]; 41 | arr[j + 1] := tmp; 42 | END; 43 | 44 | (* Print. *) 45 | FOR i := 1 TO size DO 46 | writeln(arr[i]) 47 | END. 48 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/perl_1.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # This is a pseudo Perl file to test Kate's Perl syntax highlighting. 3 | # TODO: this is incomplete, add more syntax examples! 4 | 5 | sub prg($) 6 | { 7 | my $var = shift; 8 | 9 | $var =~ s/bla/foo/igs; 10 | $var =~ s!bla!foo!igs; 11 | $var =~ s#bla#foo#igs; 12 | $var =~ tr/a-z/A-Z/; 13 | ($match) = ($var =~ m/(.*?)/igs); 14 | 15 | $test = 2/453453.21; 16 | $test /= 2; 17 | 18 | print qq~d fsd fsdf sdfl sd~ 19 | 20 | $" = '/'; 21 | 22 | $foo = <<__EOF; 23 | d ahfdklf klsdfl sdf sd 24 | fsd sdf sdfsdlkf sd 25 | __EOF 26 | 27 | $x = "dasds"; 28 | 29 | next if( $match eq "two" ); 30 | next if( $match =~ /go/i ); 31 | 32 | @array = (1,2,3); # a comment 33 | @array = qw(apple foo bar); 34 | push(@array, 4); 35 | %hash = (red => 'rot', 36 | blue => 'blau'); 37 | print keys(%hash); 38 | } 39 | 40 | sub blah { 41 | my $str = << ' EOS'; 42 | this is my string 43 | and it's continuation 44 | EOS 45 | 46 | $str = "hello world"; 47 | 48 | $str = << " EOS"; 49 | this is my string 50 | and it's continuation 51 | EOS 52 | } 53 | 54 | &blah; 55 | prg("test"); 56 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/perl_2.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | =begin 3 | perl example code for Ace 4 | =cut 5 | 6 | use v5.10; 7 | use strict; 8 | use warnings; 9 | 10 | use List::Util qw(first); 11 | my @primes; 12 | 13 | # Put 2 as the first prime so we won't have an empty array 14 | push @primes, 2; 15 | 16 | for my $number_to_check (3 .. 200) { 17 | # Check if the current number is divisible by any previous prime 18 | # if it is, skip to the next number. Use first to bail out as soon 19 | # as we find a prime that divides it. 20 | next if (first {$number_to_check % $_ == 0} @primes); 21 | 22 | # If we reached this point it means $number_to_check is not 23 | # divisable by any prime number that came before it. 24 | push @primes, $number_to_check; 25 | } 26 | 27 | # List out all of the primes 28 | say join(', ', @primes); 29 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/php_1.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | test"; ?> 16 | 17 | 18 | some_var[$index]}\nin {$this->file} is missing.\nThis is bad."); 26 | ?> 27 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/php_2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/prolog_1.plg: -------------------------------------------------------------------------------- 1 | partition([], _, [], []). 2 | partition([X|Xs], Pivot, Smalls, Bigs) :- 3 | ( X @< Pivot -> 4 | Smalls = [X|Rest], 5 | partition(Xs, Pivot, Rest, Bigs) 6 | ; Bigs = [X|Rest], 7 | partition(Xs, Pivot, Smalls, Rest) 8 | ). 9 | 10 | quicksort([]) --> []. 11 | quicksort([X|Xs]) --> 12 | { partition(Xs, X, Smaller, Bigger) }, 13 | quicksort(Smaller), [X], quicksort(Bigger). 14 | 15 | perfect(N) :- 16 | between(1, inf, N), U is N // 2, 17 | findall(D, (between(1,U,D), N mod D =:= 0), Ds), 18 | sumlist(Ds, N). -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/python_1.py: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/python 2 | 3 | import string, sys 4 | 5 | # If no arguments were given, print a helpful message 6 | if len(sys.argv)==1: 7 | print '''Usage: 8 | celsius temp1 temp2 ...''' 9 | sys.exit(0) 10 | 11 | # Loop over the arguments 12 | for i in sys.argv[1:]: 13 | try: 14 | fahrenheit=float(string.atoi(i)) 15 | except string.atoi_error: 16 | print repr(i), "not a numeric value" 17 | else: 18 | celsius=(fahrenheit-32)*5.0/9.0 19 | print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/r_1.r: -------------------------------------------------------------------------------- 1 | Call: 2 | lm(formula = y ~ x) 3 | 4 | Residuals: 5 | 1 2 3 4 5 6 6 | 3.3333 -0.6667 -2.6667 -2.6667 -0.6667 3.3333 7 | 8 | Coefficients: 9 | Estimate Std. Error t value Pr(>|t|) 10 | (Intercept) -9.3333 2.8441 -3.282 0.030453 * 11 | x 7.0000 0.7303 9.585 0.000662 *** 12 | --- 13 | Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 14 | 15 | Residual standard error: 3.055 on 4 degrees of freedom 16 | Multiple R-squared: 0.9583, Adjusted R-squared: 0.9478 17 | F-statistic: 91.88 on 1 and 4 DF, p-value: 0.000662 18 | 19 | > par(mfrow=c(2, 2)) # Request 2x2 plot layout 20 | > plot(lm_1) # Diagnostic plot of regression model -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/rhtml_1.Rhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Title 5 | 6 | 7 | 8 | 9 |

This is an R HTML document. When you click the Knit HTML button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

10 | 11 | 14 | 15 |

You can also embed plots, for example:

16 | 17 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/ruby_2.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | # Program to find the factorial of a number 4 | def fact(n) 5 | if n == 0 6 | 1 7 | else 8 | n * fact(n-1) 9 | end 10 | end 11 | 12 | puts fact(ARGV[0].to_i) 13 | 14 | class Range 15 | def to_json(*a) 16 | { 17 | 'json_class' => self.class.name, # = 'Range' 18 | 'data' => [ first, last, exclude_end? ] 19 | }.to_json(*a) 20 | end 21 | end 22 | 23 | {:id => ?", :key => "value"} 24 | 25 | 26 | herDocs = [<<'FOO', < 32 | println("Ping: starting.") 33 | pong ! Ping 34 | pingsLeft = pingsLeft - 1 35 | case SendPing => 36 | pong ! Ping 37 | pingsLeft = pingsLeft - 1 38 | case Pong => 39 | if (pingsLeft % 1000 == 0) 40 | println("Ping: pong from: "+sender) 41 | if (pingsLeft > 0) 42 | self ! SendPing 43 | else { 44 | println("Ping: Stop.") 45 | pong ! Stop 46 | exit('stop) 47 | } 48 | } 49 | } 50 | } 51 | } 52 | 53 | class Pong extends Actor { 54 | def act() { 55 | var pongCount = 0 56 | loop { 57 | react { 58 | case Ping => 59 | if (pongCount % 1000 == 0) 60 | println("Pong: ping "+pongCount+" from "+sender) 61 | sender ! Pong 62 | pongCount = pongCount + 1 63 | case Stop => 64 | println("Pong: Stop.") 65 | exit('stop) 66 | } 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/shell_2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Script to open a browser to current branch 4 | # Repo formats: 5 | # ssh git@github.com:richo/gh_pr.git 6 | # http https://richoH@github.com/richo/gh_pr.git 7 | # git git://github.com/richo/gh_pr.git 8 | 9 | username=`git config --get github.user` 10 | 11 | get_repo() { 12 | git remote -v | grep ${@:-$username} | while read remote; do 13 | if repo=`echo $remote | grep -E -o "git@github.com:[^ ]*"`; then 14 | echo $repo | sed -e "s/^git@github\.com://" -e "s/\.git$//" 15 | exit 1 16 | fi 17 | if repo=`echo $remote | grep -E -o "https?://([^@]*@)?github.com/[^ ]*\.git"`; then 18 | echo $repo | sed -e "s|^https?://||" -e "s/^.*github\.com\///" -e "s/\.git$//" 19 | exit 1 20 | fi 21 | if repo=`echo $remote | grep -E -o "git://github.com/[^ ]*\.git"`; then 22 | echo $repo | sed -e "s|^git://github.com/||" -e "s/\.git$//" 23 | exit 1 24 | fi 25 | done 26 | 27 | if [ $? -eq 0 ]; then 28 | echo "Couldn't find a valid remote" >&2 29 | exit 1 30 | fi 31 | } 32 | 33 | echo ${#x[@]} 34 | 35 | if repo=`get_repo $@`; then 36 | branch=`git symbolic-ref HEAD 2>/dev/null` 37 | echo "http://github.com/$repo/pull/new/${branch##refs/heads/}" 38 | else 39 | exit 1 40 | fi 41 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/sql_1.sql: -------------------------------------------------------------------------------- 1 | SELECT city, COUNT(id) AS users_count 2 | FROM users 3 | WHERE group_name = 'salesman' 4 | AND created > '2011-05-21' 5 | GROUP BY 1 6 | ORDER BY 2 DESC -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/tcltk_1.tcl: -------------------------------------------------------------------------------- 1 | # tcl syntax highlighting sample script for Kate 2 | # 3 | # author: JM. Philippe 15/03/04 4 | 5 | # escaped characters 6 | set String \{ 7 | set String \{ 8 | set String \" 9 | set String " \" " 10 | set String " \{ " 11 | 12 | #comments and not comments 13 | # is comments 14 | ;#is comments 15 | # is comments 16 | #

is html comment

17 | puts ok; # is comments 18 | set String [string map { {»is not comments}} $String] 19 | set String \#not_a_comment 20 | 21 | # blocks 22 | proc test {arg1 {arg2 {}} {arg3 {fr fq r}}} { 23 | if {1} {; #comments 24 | set String \{; # not a block start 25 | } 26 | } 27 | 28 | proc test args { 29 | set String \}; # not a block end 30 | } 31 | 32 | # BEGIN - collapsable comments 33 | # blablabla 34 | # END 35 | 36 | # strings 37 | set String "feqr feqr $gqer gqe" 38 | set String "feqr 39 | feqr \" $gqer \ 40 | gqe 41 | " 42 | set String {feqr 43 | feqr \{ $gqer \ 44 | gqe 45 | } 46 | 47 | # variables 48 | set b+1 [incr b] 49 | set {incr-b} ${b+1} 50 | puts ${incr-b} 51 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/tcltk_2.tcl: -------------------------------------------------------------------------------- 1 | 2 | proc dijkstra {graph origin} { 3 | # Initialize 4 | dict for {vertex distmap} $graph { 5 | dict set dist $vertex Inf 6 | dict set path $vertex {} 7 | } 8 | dict set dist $origin 0 9 | dict set path $origin [list $origin] 10 | 11 | while {[dict size $graph]} { 12 | # Find unhandled node with least weight 13 | set d Inf 14 | dict for {uu -} $graph { 15 | if {$d > [set dd [dict get $dist $uu]]} { 16 | set u $uu 17 | set d $dd 18 | } 19 | } 20 | 21 | # No such node; graph must be disconnected 22 | if {$d == Inf} break 23 | 24 | # Update the weights for nodes\ 25 | lead to by the node we've picked 26 | dict for {v dd} [dict get $graph $u] { 27 | if {[dict exists $graph $v]} { 28 | set alt [expr {$d + $dd}] 29 | if {$alt < [dict get $dist $v]} { 30 | dict set dist $v $alt 31 | dict set path $v [list {*}[dict get $path $u] $v] 32 | } 33 | } 34 | } 35 | 36 | # Remove chosen node from graph still to be handled 37 | dict unset graph $u 38 | } 39 | return [list $dist $path] 40 | } -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/vb_1.vbs: -------------------------------------------------------------------------------- 1 | myfilename = "C:\Wikipedia - VBScript - Example - Hello World.txt" 2 | MakeHelloWorldFile myfilename 3 | 4 | Sub MakeHelloWorldFile (FileName) 5 | 'Create a new file in C: drive or overwrite existing file 6 | Set FSO = CreateObject("Scripting.FileSystemObject") 7 | If FSO.FileExists(FileName) Then 8 | Answer = MsgBox ("File " & FileName & " exists ... OK to overwrite?", vbOKCancel) 9 | 'If button selected is not OK, then quit now 10 | 'vbOK is a language constant 11 | If Answer <> vbOK Then Exit Sub 12 | Else 13 | 'Confirm OK to create 14 | Answer = MsgBox ("File " & FileName & " ... OK to create?", vbOKCancel) 15 | If Answer <> vbOK Then Exit Sub 16 | End If 17 | 'Create new file (or replace an existing file) 18 | Set FileObject = FSO.CreateTextFile (FileName) 19 | FileObject.WriteLine "Time ... " & Now() 20 | FileObject.WriteLine "Hello World" 21 | FileObject.Close() 22 | MsgBox "File " & FileName & " ... updated." 23 | End Sub -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/verilog_1.v: -------------------------------------------------------------------------------- 1 | always @(negedge reset or posedge clk) begin 2 | if (reset == 0) begin 3 | d_out <= 16'h0000; 4 | d_out_mem[resetcount] <= d_out; 5 | laststoredvalue <= d_out; 6 | end else begin 7 | d_out <= d_out + 1'b1; 8 | end 9 | end 10 | 11 | always @(bufreadaddr) 12 | bufreadval = d_out_mem[bufreadaddr]; -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/vhdl_1.vhd: -------------------------------------------------------------------------------- 1 | library IEEE 2 | user IEEE.std_logic_1164.all; 3 | use IEEE.numeric_std.all; 4 | 5 | entity COUNT16 is 6 | 7 | port ( 8 | cOut :out std_logic_vector(15 downto 0); -- counter output 9 | clkEn :in std_logic; -- count enable 10 | clk :in std_logic; -- clock input 11 | rst :in std_logic -- reset input 12 | ); 13 | 14 | end entity; 15 | 16 | architecture count_rtl of COUNT16 is 17 | signal count :std_logic_vector (15 downto 0); 18 | 19 | begin 20 | process (clk, rst) begin 21 | 22 | if(rst = '1') then 23 | count <= (others=>'0'); 24 | elsif(rising_edge(clk)) then 25 | if(clkEn = '1') then 26 | count <= count + 1; 27 | end if; 28 | end if; 29 | 30 | end process; 31 | cOut <= count; 32 | 33 | end architecture; 34 | -------------------------------------------------------------------------------- /FragariaTests/HighlightingTestSamples/xml_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | This is a pseudo XML file to test Kate's XML syntax highlighting. 7 | 8 | Doctype: 9 | 10 | 11 | Processing instruction: 12 | 13 | 14 | Comments: 15 | 16 | 18 | 19 | Comment inside element: 20 | content 21 | 22 | Markup inside comment: 23 | 27 | 28 | Empty element: 29 | 30 | 31 | 32 | Simple element plus content: 33 | some content 34 | some 35 | content 36 | 37 | Namespace for elements and attributes: 38 | content 39 | content 40 | 41 | Elements containing allowed characters: 42 | 43 | 44 | 45 | Elements containing allowed start characters: 46 | <:element foo="test"/> 47 | <_element foo="test"/> 48 | 49 | Single quotes (the same as double quotes): 50 | content 51 | 52 | Allowed Whitespace: 53 | 54 | content 55 | 56 | Entities: 57 |   58 | å 59 | å 60 | å 61 | И 62 | 水 63 | 64 | 65 | Illegal XML, should not be highlighted: 66 | <0foobar> -- no digit as first character 67 | <-foo> -- no dash as first character 68 | -------------------------------------------------------------------------------- /FragariaTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /FragariaTests/MGSColourToPlainTextTransformerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MGSColourToPlainTextTransformer.m 3 | // Fragaria 4 | // 5 | // Created by Jim Derry on 3/23/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import "MGSColourToPlainTextTransformer.h" 12 | 13 | 14 | @interface MGSColourToPlainTextTransformerTests : XCTestCase 15 | 16 | @end 17 | 18 | 19 | @implementation MGSColourToPlainTextTransformerTests 20 | 21 | 22 | /* 23 | * - setUp 24 | */ 25 | - (void)setUp 26 | { 27 | [super setUp]; 28 | // Put setup code here. This method is called before the invocation of each test method in the class. 29 | } 30 | 31 | 32 | /* 33 | * - tearDown 34 | */ 35 | - (void)tearDown 36 | { 37 | // Put teardown code here. This method is called after the invocation of each test method in the class. 38 | [super tearDown]; 39 | } 40 | 41 | 42 | /* 43 | * - test_transform_color_back_and_forth 44 | */ 45 | - (void)test_transform_color_back_and_forth 46 | { 47 | NSValueTransformer *xformer = [NSValueTransformer valueTransformerForName:@"MGSColourToPlainTextTransformer"]; 48 | 49 | NSColor *color = [NSColor colorWithCalibratedRed:0.1f green:0.35f blue:1.0f alpha:1.0f]; 50 | NSString *result = [xformer transformedValue:color]; 51 | XCTAssert([result isEqual:@"0.100000 0.350000 1.000000"]); 52 | 53 | result = @"0.0 0.501961 0.501961 1"; 54 | color = [xformer reverseTransformedValue:result]; 55 | XCTAssert([color.description isEqual:@"NSCalibratedRGBColorSpace 0 0.501961 0.501961 1"]); 56 | 57 | XCTAssert(YES, @"Pass"); 58 | } 59 | 60 | 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | #Todo 2 | 3 | 1. Syntax definitions conflate language keywords and function, class method names. Adding additional recolouring is not 4 | difficult but the syntax definitions would have to be carefully filtered for all languages. 5 | 6 | 1. Autocomplete keyword colouring. Autocomplete keywords can be specified and coloured separately to keywords. To me it 7 | seems that keywords should be defined by the language syntax. Autocomplete items should contain a list of available 8 | functions, names, constants and methods. At present, for most definitions, these items have been incorporated into 9 | the keyword list. Perhaps the name of this group is what has confused people in the past (it has certainly confused 10 | me). Another name? Perhaps ?. In my option true keywords should not autocomplete. 11 | 12 | 1. Unit tests. Define strings. Colour them and validate the colouring. 13 | 14 | 1. Define source files in the bundle for each supported language type. These can be loaded in the example app to 15 | validate colouring. An NSStepper might be useful too. 16 | 17 | 1. Would MGSTextView subclassing be beneficial? 18 | --------------------------------------------------------------------------------