Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Jumping fork ahead to nvALT2 HEAD

  • Loading branch information...
commit b637fb764dc417644ee7d341909cc6be4868b994 1 parent a0befe3
@ttscoff authored
Showing with 37,828 additions and 4,150 deletions.
  1. +0 −4 .gitattributes
  2. +51 −13 .gitignore
  3. +301 −40 Acknowledgments.txt
  4. +3 −3 AlienNoteImporter.h
  5. +145 −129 AlienNoteImporter.m
  6. +109 −48 AppController.h
  7. +1,752 −490 AppController.m
  8. +28 −0 AppController_Importing.h
  9. +336 −0 AppController_Importing.m
  10. +1 −1  AppController_Preview.m
  11. +8 −3 AttributedPlainText.h
  12. +178 −52 AttributedPlainText.m
  13. +34 −0 AugmentedScrollView.h
  14. +125 −0 AugmentedScrollView.m
  15. +10 −4 BTTransparentScroller.h
  16. +59 −45 BTTransparentScroller.m
  17. +1 −1  BlorPasswordRetriever.h
  18. +3 −4 BlorPasswordRetriever.m
  19. +5 −1 BookmarksController.h
  20. +22 −2 BookmarksController.m
  21. +157 −29 BufferUtils.c
  22. +25 −1 BufferUtils.h
  23. +674 −0 COPYING.txt
  24. +8 −0 Credits.html
  25. +18 −0 DFView.h
  26. +59 −0 DFView.m
  27. +8 −6 DeletionManager.h
  28. +74 −53 DeletionManager.m
  29. +31 −0 DiskUUIDEntry.h
  30. +90 −0 DiskUUIDEntry.m
  31. +15 −2 DualField.h
  32. +68 −33 DualField.m
  33. +18 −0 ETContentView.h
  34. +54 −0 ETContentView.m
  35. +15 −0 ETScrollView.h
  36. +94 −0 ETScrollView.m
  37. +18 −0 ETTransparentButton.h
  38. +32 −0 ETTransparentButton.m
  39. +19 −0 ETTransparentButtonCell.h
  40. +122 −0 ETTransparentButtonCell.m
  41. +40 −0 ETTransparentScroller.h
  42. +246 −0 ETTransparentScroller.m
  43. +2 −0  EmptyView.h
  44. +33 −9 EmptyView.m
  45. +5 −17 EncodingsManager.m
  46. 0  English.lproj/BlorPasswordRetriever.nib/designable.nib
  47. 0  English.lproj/BlorPasswordRetriever.nib/keyedobjects.nib
  48. +3 −3 English.lproj/Contact Information.nvhelp
  49. +208 −659 English.lproj/DeletionManager.nib/designable.nib
  50. BIN  English.lproj/DeletionManager.nib/keyedobjects.nib
  51. 0  English.lproj/EncodingsManager.nib/designable.nib
  52. 0  English.lproj/EncodingsManager.nib/keyedobjects.nib
  53. +8 −3 English.lproj/Excruciatingly Useful Shortcuts.nvhelp
  54. +26 −0 English.lproj/FindPanel.nib/classes.nib
  55. +2 −2 English.lproj/{TagEditingManager.nib → FindPanel.nib}/info.nib
  56. BIN  English.lproj/FindPanel.nib/keyedobjects.nib
  57. 0  English.lproj/ImporterAccessory.nib/classes.nib
  58. 0  English.lproj/ImporterAccessory.nib/info.nib
  59. 0  English.lproj/ImporterAccessory.nib/keyedobjects.nib
  60. BIN  English.lproj/InfoPlist.strings
  61. 0  English.lproj/KeyDerivationManager.nib/designable.nib
  62. 0  English.lproj/KeyDerivationManager.nib/keyedobjects.nib
  63. BIN  English.lproj/Localizable.strings
  64. BIN  English.lproj/MainMenu.nib/keyedobjects.nib
  65. +6,113 −0 English.lproj/MainMenu.xib
  66. +1,211 −0 English.lproj/MarkupPreview.xib
  67. +136 −377 English.lproj/NotationPrefsView.nib/designable.nib
  68. BIN  English.lproj/NotationPrefsView.nib/keyedobjects.nib
  69. 0  English.lproj/PassphraseChanger.nib/designable.nib
  70. 0  English.lproj/PassphraseChanger.nib/keyedobjects.nib
  71. 0  English.lproj/PassphrasePicker.nib/designable.nib
  72. 0  English.lproj/PassphrasePicker.nib/keyedobjects.nib
  73. +77 −635 English.lproj/PassphraseRetriever.nib/designable.nib
  74. BIN  English.lproj/PassphraseRetriever.nib/keyedobjects.nib
  75. BIN  English.lproj/Preferences.nib/keyedobjects.nib
  76. +4,701 −0 English.lproj/Preferences.xib
  77. +462 −0 English.lproj/SaveHTMLPreview.nib/designable.nib
  78. BIN  English.lproj/SaveHTMLPreview.nib/keyedobjects.nib
  79. +337 −1,263 English.lproj/SavedSearches.nib/designable.nib
  80. BIN  English.lproj/SavedSearches.nib/keyedobjects.nib
  81. +0 −19 English.lproj/TagEditingManager.nib/classes.nib
  82. BIN  English.lproj/TagEditingManager.nib/keyedobjects.nib
  83. +630 −0 English.lproj/TagEditingManager.xib
  84. +4 −2 English.lproj/This is the title of a note.nvhelp
  85. 0  English.lproj/URLGetter.nib/designable.nib
  86. 0  English.lproj/URLGetter.nib/keyedobjects.nib
  87. +1 −4 ExporterManager.m
  88. +0 −22 FSExchangeObjectsCompat.c
  89. +9 −0 FastListDataSource.h
  90. +5 −2 FastListDataSource.m
  91. +2 −3 FrozenNotation.h
  92. +50 −29 GlobalPrefs.h
  93. +274 −97 GlobalPrefs.m
  94. 0  Images/Clear.tif
  95. 0  Images/ClearPressed.tif
  96. 0  Images/DFCapLeftRounded.png
  97. 0  Images/DFCapLeftRoundedInactive.png
  98. 0  Images/DFCapRight.png
  99. 0  Images/DFCapRightInactive.png
  100. BIN  Images/Editing.tiff
  101. BIN  Images/Fonts & Colors.tiff
  102. BIN  Images/General.tiff
  103. BIN  Images/HUDIconLock.png
  104. BIN  Images/HUDIconPrint.png
  105. BIN  Images/HUDIconSave.png
  106. BIN  Images/HUDIconShare.png
  107. BIN  Images/IBeamInverted.png
  108. BIN  Images/LinkBack.tif
  109. BIN  Images/LinkBackPressed.tif
  110. BIN  Images/ListDividerDrag.png
  111. BIN  Images/MakeDefault.tiff
  112. BIN  Images/MakeDefault_Pressed.tiff
  113. BIN  Images/Notes.tiff
  114. 0  Images/Pencil.png
  115. 0  Images/Search.png
  116. 0  Images/SnapBack.tif
  117. 0  Images/SnapBackPressed.tif
  118. 0  Images/TBAlert.png
  119. 0  Images/TBAlertWhite.png
  120. 0  Images/TBDownArrow.png
  121. 0  Images/TBDownArrowWhite.png
  122. 0  Images/TBMousedownBG.png
  123. 0  Images/TBRolloverBG.png
  124. 0  Images/TBSynchronizing.png
  125. 0  Images/TBSynchronizingWhite.png
  126. 0  Images/TinyAlert.tif
  127. BIN  Images/nvMenu.bak.png
  128. BIN  Images/nvMenu.png
  129. BIN  Images/nvMenuC.bak.png
  130. BIN  Images/nvMenuC.png
  131. BIN  Images/nvMenuDark.bak.png
  132. BIN  Images/nvMenuDark.png
  133. 0  Images/statusError.png
  134. 0  Images/statusInProgress.png
  135. 0  Images/statusValidated.png
  136. +43 −39 Info.plist
  137. 0  InvocationRecorder.h
  138. +1 −1  InvocationRecorder.m
  139. +641 −0 Italian.lproj/BlorPasswordRetriever.nib/designable.nib
  140. BIN  Italian.lproj/BlorPasswordRetriever.nib/keyedobjects.nib
  141. +166 −0 Italian.lproj/CarbonErrorStrings.plist
  142. +24 −0 Italian.lproj/Come funziona questa cosa?.nvhelp
  143. +19 −0 Italian.lproj/Contatti.nvhelp
  144. +779 −0 Italian.lproj/DeletionManager.nib/designable.nib
  145. BIN  Italian.lproj/DeletionManager.nib/keyedobjects.nib
  146. +825 −0 Italian.lproj/EncodingsManager.nib/designable.nib
  147. BIN  Italian.lproj/EncodingsManager.nib/keyedobjects.nib
  148. +1,023 −0 Italian.lproj/ExporterManager.nib/designable.nib
  149. BIN  Italian.lproj/ExporterManager.nib/keyedobjects.nib
  150. +471 −0 Italian.lproj/FindPanel.nib/designable.nib
  151. BIN  Italian.lproj/FindPanel.nib/keyedobjects.nib
  152. BIN  Italian.lproj/FindPanel.strings
  153. +177 −0 Italian.lproj/ImporterAccessory.nib/designable.nib
  154. BIN  Italian.lproj/ImporterAccessory.nib/keyedobjects.nib
  155. BIN  Italian.lproj/InfoPlist.strings
  156. +540 −0 Italian.lproj/KeyDerivationManager.nib/designable.nib
  157. BIN  Italian.lproj/KeyDerivationManager.nib/keyedobjects.nib
  158. BIN  Italian.lproj/Localizable.strings
  159. +5,135 −0 Italian.lproj/MainMenu.nib/designable.nib
  160. BIN  Italian.lproj/MainMenu.nib/keyedobjects.nib
  161. +4,215 −0 Italian.lproj/NotationPrefsView.nib/designable.nib
  162. BIN  Italian.lproj/NotationPrefsView.nib/keyedobjects.nib
  163. +1,371 −0 Italian.lproj/PTKeyComboPanel.nib/designable.nib
  164. BIN  Italian.lproj/PTKeyComboPanel.nib/keyedobjects.nib
  165. +1,182 −0 Italian.lproj/PassphraseChanger.nib/designable.nib
  166. BIN  Italian.lproj/PassphraseChanger.nib/keyedobjects.nib
  167. +1,110 −0 Italian.lproj/PassphrasePicker.nib/designable.nib
  168. BIN  Italian.lproj/PassphrasePicker.nib/keyedobjects.nib
  169. +751 −0 Italian.lproj/PassphraseRetriever.nib/designable.nib
  170. BIN  Italian.lproj/PassphraseRetriever.nib/keyedobjects.nib
Sorry, we could not display the entire diff because too many files (1,071) changed.
View
4 .gitattributes
@@ -1,5 +1 @@
*.pbxproj -crlf -diff -merge
-build export-ignore
-.gitattributes export-ignore
-.gitignore export-ignore
-dsa_pub.pem export-ignore
View
64 .gitignore
@@ -1,15 +1,53 @@
-# Xcode user-settings files
-build/*
-*.pbxuser
-*.mode1v3
-*.mode1
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
-# Mac OS X specific
+# Packages #
+############
+# it's better to unpack these files and commit the raw source
+# git has its own built in compression methods
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sql
+*.sqlite
+*.pbxproj
+*.xcworkspace
+*.xcuserdatad
+*.xcuserstate
+
+# OS generated files #
+######################
+.DS_Store?
+thumbs.db
+Icon?
+Thumbs.db
+Notation.xcodeproj/xcuserdata/*
+Notation.xcodeproj/project.xcworkspace/*
+Loren.*
+ttscoff.*
+UserInterfaceState.xcuserstate
.DS_Store
-profile
-English.lproj/MainMenu~.nib/classes.nib
-English.lproj/MainMenu~.nib/data.dependency
-English.lproj/MainMenu~.nib/info.nib
-English.lproj/MainMenu~.nib/keyedobjects.nib
-scrollbar.acorn
-scrollbar2.acorn
+<<<<<<< HEAD
+
+/.DS_Store
+=======
+<<<<<<< HEAD
+/.DS_Store
+=======
+>>>>>>> 1d5018bacb5c01a694493aca06192b4a5096d9ef
+>>>>>>> mmd3
View
341 Acknowledgments.txt 100755 → 100644
@@ -1,9 +1,17 @@
-nvALT is built on Notational Velocity, copyright Zachary Schneirov, Christian Tietze, the use of which is hereby acknowledged.
-
Portions of Notational Velocity contain the following copyrighted materials, the use of which is hereby acknowledged.
--
+Notational Velocity Icon
+
+Copyright (c) 2011 Taylor Carrigan. All rights reserved.
+
+http://taylorcarrigan.com/
+
+This icon may not be used for commercial purposes.
+
+--
+
Sparkle Framework
Copyright (c) 2006 Andy Matuschak
@@ -42,36 +50,6 @@ Copyright 2004-2006 Rainer Brockerhoff.
Some Rights Reserved under the Creative Commons Attribution License,
version 2.5, and/or the MIT License.
-
---
-
-BWToolkit
-
-Copyright (c) 2010, Brandon Walkin
-All rights reserved.
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-* Neither the name of the Brandon Walkin nor the names of its contributors may
- be used to endorse or promote products derived from this software without
- specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--
CiphSafe NSData compression category methods
@@ -370,13 +348,296 @@ http://www.opensource.org/licenses/bsd-license.php
--
-FullscreenImage
+AutoHyperlinks framework
+
+(c) 2004-2008 by the following:
+
+Colin Barrett
+Graham Booker
+Jorge Salvador Caffarena
+Evan Schoenberg
+Augie Fackler
+Stephen Holt
+Peter Hosey
+Adam Iser
+Jeffrey Melloy
+Toby Peterson
+Eric Richie
+David Smith
+
+/*
+ * The AutoHyperlinks Framework is the legal property of its developers (DEVELOPERS), whose names are listed in the
+ * copyright file included with this source distribution.
+ *
+ * Copyright (c) 2004-2008
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the AutoHyperlinks Framework nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ITS DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ITS DEVELOPERS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+--
+ElasticThreads' contributions, including (but not limited to) the fullscreen mode, color scheming, the status bar icon, and the ability to open notes in other text editors are released under the "new" BSD license:
+
+http://elasticthreads.tumblr.com/nv/
+
+Copyright (c) 2011, ElasticThreads
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+• Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+• Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+• Neither the name of the ElasticThreads nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+This is the standard "new" BSD license:
+http://www.opensource.org/licenses/bsd-license.php
+
+--
+Some UI elements (the scrollers, and also the buttons in the markdown preview) are from BWToolkit.
+
+BWToolKit
+http://www.brandonwalkin.com/bwtoolkit/
+
+Copyright (c) 2010, Brandon Walkin
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+• Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+• Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+• Neither the name of the Brandon Walkin nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+This is the standard "new" BSD license:
+http://www.opensource.org/licenses/bsd-license.php
+
+--
-Created by Matt Gallagher on 2009/08/14.
-Copyright 2009 Matt Gallagher. All rights reserved.
+ETTransparentScroller
+The main window uses a scroller class are based on the BWTransparentScroller from BWToolKit
+http://www.brandonwalkin.com/bwtoolkit/
+(modifications by ElasticThreads on 10/19/2010)
+
+see BWToolkit above
+--
+
+BTTransparentScroller
+The Markdown preview pane uses a scroller class are based on the BWTransparentScroller from BWToolKit
+http://www.brandonwalkin.com/bwtoolkit/
+(but modified by Brett Terpstra on 12/8/10 and again by ElasticThreads on 03/10/11)
+
+see BWToolkit above
+
+--
+
+The markdown preview uses a popover type window MAAttachedWindow.m
+Which was created by Matt Gemmell
+
+
+--
+The markdown preview is based on code from Christian Tietze
+
+--
+Beautiful Soup
+Elixir and Tonic
+"The Screen-Scraper's Friend"
+http://www.crummy.com/software/BeautifulSoup/
+
+Beautiful Soup parses a (possibly invalid) XML or HTML document into a
+tree representation. It provides methods and Pythonic idioms that make
+it easy to navigate, search, and modify the tree.
+
+A well-formed XML/HTML document yields a well-formed data
+structure. An ill-formed XML/HTML document yields a correspondingly
+ill-formed data structure. If your document is only locally
+well-formed, you can use this library to find and process the
+well-formed part of it.
+
+Beautiful Soup works with Python 2.2 and up. It has no external
+dependencies, but you'll have more success at converting data to UTF-8
+if you also install these three packages:
+
+* chardet, for auto-detecting character encodings
+ http://chardet.feedparser.org/
+* cjkcodecs and iconv_codec, which add more encodings to the ones supported
+ by stock Python.
+ http://cjkpython.i18n.org/
+
+Beautiful Soup defines classes for two main parsing strategies:
+
+ * BeautifulStoneSoup, for parsing XML, SGML, or your domain-specific
+ language that kind of looks like XML.
+
+ * BeautifulSoup, for parsing run-of-the-mill HTML code, be it valid
+ or invalid. This class has web browser-like heuristics for
+ obtaining a sensible parse tree in the face of common HTML errors.
+
+Beautiful Soup also defines a class (UnicodeDammit) for autodetecting
+the encoding of an HTML or XML document, and converting it to
+Unicode. Much of this code is taken from Mark Pilgrim's Universal Feed Parser.
+
+For more than you ever wanted to know about Beautiful Soup, see the
+documentation:
+http://www.crummy.com/software/BeautifulSoup/documentation.html
+
+Here, have some legalese:
+
+Copyright (c) 2004-2009, Leonard Richardson
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of the the Beautiful Soup Consortium and All
+ Night Kosher Bakery nor the names of its contributors may be
+ used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE, DAMMIT.
+
+--
+
+html2text: Turn HTML into equivalent Markdown-structured text.
+__version__ = "2.39"
+__author__ = "Aaron Swartz (me@aaronsw.com)"
+__copyright__ = "(C) 2004-2008 Aaron Swartz. GNU GPL 3."
+__contributors__ = ["Martin 'Joey' Schulze", "Ricardo Reyes", "Kevin Jay North"]
+
+--
+
+Markdown is
+Copyright (c) 2004, John Gruber
+<http://daringfireball.net/>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+* Neither the name "Markdown" nor the names of its contributors may
+ be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+This software is provided by the copyright holders and contributors "as
+is" and any express or implied warranties, including, but not limited
+to, the implied warranties of merchantability and fitness for a
+particular purpose are disclaimed. In no event shall the copyright owner
+or contributors be liable for any direct, indirect, incidental, special,
+exemplary, or consequential damages (including, but not limited to,
+procurement of substitute goods or services; loss of use, data, or
+profits; or business interruption) however caused and on any theory of
+liability, whether in contract, strict liability, or tort (including
+negligence or otherwise) arising in any way out of the use of this
+software, even if advised of the possibility of such damage.
+
+--
+
+MultiMarkdown changes Copyright (c) 2005-2009 Fletcher T. Penney
+ <http://fletcherpenney.net/> All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name "Markdown" nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
-Permission is given to use this source code file, free of charge, in any
-project, commercial or otherwise, entirely at your risk, with the condition
-that any redistribution (in part or whole) of source code must retain
-this copyright and permission notice. Attribution in compiled projects is
-appreciated but not required.
+ This software is provided by the copyright holders and contributors "as
+ is" and any express or implied warranties, including, but not limited
+ to, the implied warranties of merchantability and fitness for a
+ particular purpose are disclaimed. In no event shall the copyright owner
+ or contributors be liable for any direct, indirect, incidental, special,
+ exemplary, or consequential damages (including, but not limited to,
+ procurement of substitute goods or services; loss of use, data, or
+ profits; or business interruption) however caused and on any theory of
+ liability, whether in contract, strict liability, or tort (including
+ negligence or otherwise) arising in any way out of the use of this
+ software, even if advised of the possibility of such damage.
View
6 AlienNoteImporter.h
@@ -36,8 +36,8 @@ extern NSString *RetrievedPasswordKey;
id source;
NSMutableDictionary *documentSettings;
BOOL shouldGrabCreationDates;
-
- BOOL shouldUseReadability;
+
+ BOOL shouldUseReadability;
}
//a directory containing notes, a custom bundle, or custom file format in which more than one note could be expected
@@ -73,4 +73,4 @@ extern NSString *RetrievedPasswordKey;
@interface AlienNoteImporter (DialogDelegate)
- (void)noteImporter:(AlienNoteImporter*)importer importedNotes:(NSArray*)notes;
-@end
+@end
View
274 AlienNoteImporter.m
@@ -23,7 +23,9 @@
#import "GlobalPrefs.h"
#import "AttributedPlainText.h"
#import "NSData_transformations.h"
+#import "NSCollection_utils.h"
#import "NSString_NV.h"
+#import "NSFileManager_NV.h"
#import "NotationPrefs.h"
#import "NotationController.h"
#import "NoteObject.h"
@@ -46,7 +48,6 @@ - (id)init {
if ([super init]) {
shouldGrabCreationDates = NO;
documentSettings = [[NSMutableDictionary alloc] init];
- shouldUseReadability = NO;
}
return self;
}
@@ -131,6 +132,7 @@ - (id)initWithStoragePath:(NSString*)filename {
- (void)dealloc {
[documentSettings release];
[source release];
+
[super dealloc];
}
@@ -225,16 +227,21 @@ - (void)URLGetter:(URLGetter*)getter returnedDownloadedFile:(NSString*)filename
if (filename) {
NSArray *notes = [self notesInFile:filename];
if ([notes count]) {
-
- NSMutableAttributedString *content = [[[[notes lastObject] contentString] mutableCopy] autorelease];
+ NSMutableAttributedString *content = [[[GlobalPrefs defaultPrefs] pastePreservesStyle] ? [[[notes lastObject] contentString] mutableCopy] :
+ [[NSMutableAttributedString alloc] initWithString:[[[notes lastObject] contentString] string]] autorelease];
if ([[[content string] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length]) {
//only add string if it has at least one non-whitespace character
- [content prefixWithSourceString:[[getter url] absoluteString]];
+ NSUInteger prefixedSourceLength = [[content prefixWithSourceString:[[getter url] absoluteString]] length];
[content santizeForeignStylesForImporting];
[[notes lastObject] setContentString:content];
if ([getter userData]) [[notes lastObject] setTitleString:[getter userData]];
+ //prefixing should push existing selections forward:
+ NSRange selRange = [[notes lastObject] lastSelectedRange];
+ if (selRange.length && prefixedSourceLength)
+ [[notes lastObject] setSelectedRange:NSMakeRange(selRange.location + prefixedSourceLength, selRange.length)];
+
[receptionDelegate noteImporter:self importedNotes:notes];
foundNotes = YES;
@@ -249,7 +256,7 @@ - (void)URLGetter:(URLGetter*)getter returnedDownloadedFile:(NSString*)filename
[newString santizeForeignStylesForImporting];
NoteObject *noteObject = [[NoteObject alloc] initWithNoteBody:newString title:[getter userData] ? [getter userData] : urlString
- uniqueFilename:nil format:SingleDatabaseFormat];
+ delegate:nil format:SingleDatabaseFormat labels:nil];
[receptionDelegate noteImporter:self importedNotes:[NSArray arrayWithObject:noteObject]];
[noteObject autorelease];
@@ -310,113 +317,6 @@ - (NSArray*)notesWithPaths:(NSArray*)paths {
return nil;
}
-- (NSString *) contentUsingReadability: (NSString *)htmlFile
-{
- NSBundle *bundle = [NSBundle mainBundle];
- NSString *readabilityPath;
- readabilityPath = [bundle pathForAuxiliaryExecutable: @"readability.py"];
-
- NSTask *task = [[NSTask alloc] init];
- [task setLaunchPath: readabilityPath];
-
- NSArray *arguments;
- arguments = [NSArray arrayWithObjects: htmlFile, nil];
- [task setArguments: arguments];
-
- NSPipe *rpipe;
- rpipe = [NSPipe pipe];
- [task setStandardOutput: rpipe];
-
- NSFileHandle *file;
- file = [rpipe fileHandleForReading];
-
- [task launch];
-
- NSData *data;
- data = [file readDataToEndOfFile];
-
- NSString *string;
- string = [[NSString alloc] initWithData: data
- encoding: NSUTF8StringEncoding];
-
- return [self markdownFromSource:string];
-}
-
-- (NSString *) markdownFromHTMLFile: (NSString *)htmlFile
-{
- NSBundle *bundle = [NSBundle mainBundle];
- NSString *readabilityPath;
- readabilityPath = [bundle pathForAuxiliaryExecutable: @"html2text.py"];
-
- NSTask *task = [[NSTask alloc] init];
- [task setLaunchPath: readabilityPath];
-
- NSArray *arguments;
- arguments = [NSArray arrayWithObjects: htmlFile, nil];
- [task setArguments: arguments];
-
- NSPipe *rpipe;
- rpipe = [NSPipe pipe];
- [task setStandardOutput: rpipe];
-
- NSFileHandle *file;
- file = [rpipe fileHandleForReading];
-
- [task launch];
-
- NSData *data;
- data = [file readDataToEndOfFile];
-
- NSString *string;
- string = [[NSString alloc] initWithData: data
- encoding: NSUTF8StringEncoding];
-
- return string;
-}
-
-- (NSString *) markdownFromSource: (NSString *)htmlString
-{
- NSBundle *bundle = [NSBundle mainBundle];
- NSString *readabilityPath;
- readabilityPath = [bundle pathForAuxiliaryExecutable: @"html2text.py"];
-
- NSTask *task = [[NSTask alloc] init];
- [task setLaunchPath: readabilityPath];
-
- NSPipe *readPipe = [NSPipe pipe];
- NSFileHandle *readHandle = [readPipe fileHandleForReading];
-
- NSPipe *writePipe = [NSPipe pipe];
- NSFileHandle *writeHandle = [writePipe fileHandleForWriting];
-
- [task setStandardInput: writePipe];
- [task setStandardOutput: readPipe];
-
- [task launch];
-
- [writeHandle writeData: [htmlString dataUsingEncoding: NSASCIIStringEncoding]];
- [writeHandle closeFile];
-
- NSMutableData *data = [[NSMutableData alloc] init];
- NSData *readData;
-
- while ((readData = [readHandle availableData])
- && [readData length]) {
- [data appendData: readData];
- }
-
- NSString *strippedString;
- strippedString = [[NSString alloc]
- initWithData: data
- encoding: NSASCIIStringEncoding];
-
- [task release];
- [data release];
- [strippedString autorelease];
-
- return (strippedString);
-}
-
//auto-detect based on file type/extension/header
//if unable to find, revert to spotlight importer
- (NoteObject*)noteWithFile:(NSString*)filename {
@@ -427,9 +327,10 @@ - (NoteObject*)noteWithFile:(NSString*)filename {
NSString *sourceIdentifierString = nil;
NSMutableAttributedString *attributedStringFromData = nil;
+
if (fileType == HTML_TYPE_ID || [extension isEqualToString:@"htm"] || [extension isEqualToString:@"html"] || [extension isEqualToString:@"shtml"]) {
- // convert to text with markdown here
- if ([[GlobalPrefs defaultPrefs] useMarkdownImport]) {
+ //should convert to text with markdown here
+ if ([[GlobalPrefs defaultPrefs] useMarkdownImport]) {
if ([[GlobalPrefs defaultPrefs] useReadability] || [self shouldUseReadability]) {
attributedStringFromData = [[NSMutableAttributedString alloc] initWithString:[self contentUsingReadability:filename]
attributes:[[GlobalPrefs defaultPrefs] noteBodyAttributes]];
@@ -437,9 +338,10 @@ - (NoteObject*)noteWithFile:(NSString*)filename {
attributedStringFromData = [[NSMutableAttributedString alloc] initWithString:[self markdownFromHTMLFile:filename]
attributes:[[GlobalPrefs defaultPrefs] noteBodyAttributes]];
}
- } else {
- attributedStringFromData = [[NSMutableAttributedString alloc] initWithHTML:[NSData uncachedDataFromFile:filename] documentAttributes:NULL];
- }
+ } else {
+ attributedStringFromData = [[NSMutableAttributedString alloc] initWithHTML:[NSData uncachedDataFromFile:filename]
+ options:[NSDictionary optionsDictionaryWithTimeout:10.0] documentAttributes:NULL];
+ }
} else if (fileType == RTF_TYPE_ID || [extension isEqualToString:@"rtf"] || [extension isEqualToString:@"nvhelp"] || [extension isEqualToString:@"rtx"]) {
attributedStringFromData = [[NSMutableAttributedString alloc] initWithRTF:[NSData uncachedDataFromFile:filename] documentAttributes:NULL];
@@ -505,28 +407,34 @@ - (NoteObject*)noteWithFile:(NSString*)filename {
if (attributedStringFromData) {
[attributedStringFromData trimLeadingWhitespace];
[attributedStringFromData removeAttachments];
- [attributedStringFromData santizeForeignStylesForImporting];
-
NSString *processedFilename = [[filename lastPathComponent] stringByDeletingPathExtension];
-
- NSUInteger bodyLoc = 0;
- NSString *title = [[attributedStringFromData string] syntheticTitleAndSeparatorWithContext:NULL bodyLoc:&bodyLoc oldTitle:nil];
+ NSUInteger bodyLoc = 0, prefixedSourceLength = 0;
+ NSString *title = [[attributedStringFromData string] syntheticTitleAndSeparatorWithContext:NULL bodyLoc:&bodyLoc maxTitleLen:36];
//if the synthetic title (generally the first line of the content) is shorter than the filename itself, just use the filename as the title
//(or if this is a special case and we know the filename should be used)
- if ([processedFilename length] > [title length] || [extension isEqualToString:@"nvhelp"]) {
+ if ([processedFilename length] > [title length] || [extension isEqualToString:@"nvhelp"] || [title isAMachineDirective] ||
+ [title isEqualToString:NSLocalizedString(@"Untitled Note", @"Title of a nameless note")]) {
title = processedFilename;
+ bodyLoc = 0;
} else {
- if (bodyLoc > 0 && [attributedStringFromData length] >= bodyLoc) [attributedStringFromData deleteCharactersInRange:NSMakeRange(0, bodyLoc)];
+ title = [title stringByAppendingFormat:@" (%@)", processedFilename];
}
if ([sourceIdentifierString length])
- [attributedStringFromData prefixWithSourceString:sourceIdentifierString];
+ prefixedSourceLength = [[attributedStringFromData prefixWithSourceString:sourceIdentifierString] length];
+ [attributedStringFromData santizeForeignStylesForImporting];
+
[attributedStringFromData autorelease];
+ //transfer any openmeta tags associated with this file as tags for the new note
+ NSArray *openMetaTags = [[NSFileManager defaultManager] getOpenMetaTagsAtFSPath:[filename fileSystemRepresentation]];
+
//we do not also use filename as uniqueFilename, as we are only importing--not taking ownership
- NoteObject *noteObject = [[NoteObject alloc] initWithNoteBody:attributedStringFromData title:title uniqueFilename:nil format:SingleDatabaseFormat];
+ NoteObject *noteObject = [[NoteObject alloc] initWithNoteBody:attributedStringFromData title:title delegate:nil
+ format:SingleDatabaseFormat labels:[openMetaTags componentsJoinedByString:@" "]];
if (noteObject) {
+ if (bodyLoc > 0 && [attributedStringFromData length] >= bodyLoc + prefixedSourceLength) [noteObject setSelectedRange:NSMakeRange(prefixedSourceLength, bodyLoc)];
if (shouldGrabCreationDates) {
[noteObject setDateAdded:CFDateGetAbsoluteTime((CFDateRef)[attributes objectForKey:NSFileCreationDate])];
}
@@ -587,6 +495,112 @@ - (NSArray*)notesInFile:(NSString*)filename {
return nil;
}
+- (NSString *) contentUsingReadability: (NSString *)htmlFile
+{
+ NSBundle *bundle = [NSBundle mainBundle];
+ NSString *readabilityPath;
+ readabilityPath = [bundle pathForAuxiliaryExecutable: @"readability.py"];
+
+ NSTask *task = [[NSTask alloc] init];
+ [task setLaunchPath: readabilityPath];
+
+ NSArray *arguments;
+ arguments = [NSArray arrayWithObjects: htmlFile, nil];
+ [task setArguments: arguments];
+
+ NSPipe *rpipe;
+ rpipe = [NSPipe pipe];
+ [task setStandardOutput: rpipe];
+
+ NSFileHandle *file;
+ file = [rpipe fileHandleForReading];
+
+ [task launch];
+
+ NSData *data;
+ data = [file readDataToEndOfFile];
+
+ NSString *string;
+ string = [[NSString alloc] initWithData: data
+ encoding: NSUTF8StringEncoding];
+
+ return [self markdownFromSource:string];
+}
+
+- (NSString *) markdownFromHTMLFile: (NSString *)htmlFile
+{
+ NSBundle *bundle = [NSBundle mainBundle];
+ NSString *readabilityPath;
+ readabilityPath = [bundle pathForAuxiliaryExecutable: @"html2text.py"];
+
+ NSTask *task = [[NSTask alloc] init];
+ [task setLaunchPath: readabilityPath];
+
+ NSArray *arguments;
+ arguments = [NSArray arrayWithObjects: htmlFile, nil];
+ [task setArguments: arguments];
+
+ NSPipe *rpipe;
+ rpipe = [NSPipe pipe];
+ [task setStandardOutput: rpipe];
+
+ NSFileHandle *file;
+ file = [rpipe fileHandleForReading];
+
+ [task launch];
+
+ NSData *data;
+ data = [file readDataToEndOfFile];
+
+ NSString *string;
+ string = [[NSString alloc] initWithData: data
+ encoding: NSUTF8StringEncoding];
+
+ return string;
+}
+
+- (NSString *) markdownFromSource: (NSString *)htmlString
+{
+ NSBundle *bundle = [NSBundle mainBundle];
+ NSString *readabilityPath;
+ readabilityPath = [bundle pathForAuxiliaryExecutable: @"html2text.py"];
+
+ NSTask *task = [[NSTask alloc] init];
+ [task setLaunchPath: readabilityPath];
+
+ NSPipe *readPipe = [NSPipe pipe];
+ NSFileHandle *readHandle = [readPipe fileHandleForReading];
+
+ NSPipe *writePipe = [NSPipe pipe];
+ NSFileHandle *writeHandle = [writePipe fileHandleForWriting];
+
+ [task setStandardInput: writePipe];
+ [task setStandardOutput: readPipe];
+
+ [task launch];
+
+ [writeHandle writeData: [htmlString dataUsingEncoding: NSASCIIStringEncoding]];
+ [writeHandle closeFile];
+
+ NSMutableData *data = [[NSMutableData alloc] init];
+ NSData *readData;
+
+ while ((readData = [readHandle availableData])
+ && [readData length]) {
+ [data appendData: readData];
+ }
+
+ NSString *strippedString;
+ strippedString = [[NSString alloc]
+ initWithData: data
+ encoding: NSASCIIStringEncoding];
+
+ [task release];
+ [data release];
+ [strippedString autorelease];
+
+ return (strippedString);
+}
-(BOOL)shouldUseReadability
{
return shouldUseReadability;
@@ -624,9 +638,10 @@ - (NSArray*)_importStickies:(NSString*)filename {
NSMutableAttributedString *attributedString = [[[NSMutableAttributedString alloc] initWithRTFD:[doc RTFDData] documentAttributes:NULL] autorelease];
[attributedString removeAttachments];
[attributedString santizeForeignStylesForImporting];
- NSString *syntheticTitle = [attributedString getLeadingSyntheticTitle];
+ NSString *syntheticTitle = [attributedString trimLeadingSyntheticTitle];
- NoteObject *noteObject = [[[NoteObject alloc] initWithNoteBody:attributedString title:syntheticTitle uniqueFilename:nil format:SingleDatabaseFormat] autorelease];
+ NoteObject *noteObject = [[[NoteObject alloc] initWithNoteBody:attributedString title:syntheticTitle
+ delegate:nil format:SingleDatabaseFormat labels:nil] autorelease];
if (noteObject) {
[noteObject setDateAdded:CFDateGetAbsoluteTime((CFDateRef)[doc creationDate])];
[noteObject setDateModified:CFDateGetAbsoluteTime((CFDateRef)[doc modificationDate])];
@@ -741,8 +756,9 @@ - (NSArray*)_importDelimitedFile:(NSString*)filename withDelimiter:(NSString*)de
NSString *title = [fields objectAtIndex:0];
NSMutableAttributedString *attributedBody = [[[NSMutableAttributedString alloc] initWithString:s attributes:[[GlobalPrefs defaultPrefs] noteBodyAttributes]] autorelease];
[attributedBody addLinkAttributesForRange:NSMakeRange(0, [attributedBody length])];
+ [attributedBody addStrikethroughNearDoneTagsForRange:NSMakeRange(0, [attributedBody length])];
- NoteObject *note = [[[NoteObject alloc] initWithNoteBody:attributedBody title:title uniqueFilename:nil format:SingleDatabaseFormat] autorelease];
+ NoteObject *note = [[[NoteObject alloc] initWithNoteBody:attributedBody title:title delegate:nil format:SingleDatabaseFormat labels:nil] autorelease];
if (note) {
now += 1.0; //to ensure a consistent sort order
[note setDateAdded:now];
View
157 AppController.h
@@ -16,8 +16,7 @@
#import "NotationController.h"
#import "NotesTableView.h"
-#import "WhiteTransparentScroller.h"
-#import "BlueTransparentScroller.h"
+#import "Spaces.h"
@class LinkingEditor;
@class EmptyView;
@@ -29,9 +28,13 @@
@class RBSplitSubview;
@class TitlebarButton;
@class LinearDividerShader;
+@class TagEditingManager;
+@class StatusItemView;
+@class DFView;
@class PreviewController;
-@class WhiteTransparentScroller;
-@class BlueTransparentScroller;
+@class WordCountToken;
+@class AugmentedScrollView;
+@class ETContentView;
#ifndef MarkdownPreview
#define MarkdownPreview 13371
@@ -45,56 +48,78 @@
#define TextilePreview 13373
#endif
-@interface AppController : NSObject {
- IBOutlet DualField *field;
- IBOutlet RBSplitSubview *splitSubview;
- IBOutlet RBSplitView *splitView;
- IBOutlet RBSplitSubview *notesList;
- IBOutlet NotesTableView *notesTableView;
- IBOutlet NSBox *horizontalRule;
- IBOutlet NSBox *verticalRule;
- IBOutlet LinkingEditor *textView;
+@interface AppController : NSObject
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+<NSToolbarDelegate, NSTableViewDelegate, NSWindowDelegate, NSTextFieldDelegate, NSTextViewDelegate>
+#endif
+{
+ //NSMenuItem *fsMenuItem;
+ BOOL wasVert;
+ BOOL isAutocompleting;
+ BOOL wasDeleting;
+ IBOutlet ETContentView *mainView;
+ DFView *dualFieldView;
+ StatusItemView *cView;
+ NSStatusItem *statusItem;
+ IBOutlet NSMenu *statBarMenu;
+ TagEditingManager *TagEditer;
+ NSColor *backgrndColor;
+ NSColor *foregrndColor;
+ int userScheme;
+ NSString *noteFormat;
+ NSTextView *theFieldEditor;
+ NSDictionary *fieldAttributes;
+ NSTimer *modifierTimer;
+ IBOutlet WordCountToken *wordCounter;
+ IBOutlet DualField *field;
+ RBSplitSubview *splitSubview;
+ RBSplitSubview *notesSubview;
+ RBSplitView *splitView;
+ IBOutlet AugmentedScrollView *notesScrollView;
+ IBOutlet NSScrollView *textScrollView;
+ IBOutlet NotesTableView *notesTableView;
+ IBOutlet LinkingEditor *textView;
IBOutlet EmptyView *editorStatusView;
IBOutlet NSMenuItem *sparkleUpdateItem;
- IBOutlet NSWindow *window;
+ IBOutlet NSWindow *window;
IBOutlet NSPanel *syncWaitPanel;
IBOutlet NSProgressIndicator *syncWaitSpinner;
- IBOutlet NSMenuItem *widescreenToggle;
- IBOutlet NSMenuItem *collapseToggle;
- IBOutlet WhiteTransparentScroller *otherScroller;
- IBOutlet BlueTransparentScroller *noteScroller;
NSToolbar *toolbar;
NSToolbarItem *dualFieldItem;
TitlebarButton *titleBarButton;
BOOL waitedForUncommittedChanges;
+ NSImage *verticalDividerImg;
LinearDividerShader *dividerShader;
- NSString *URLToSearchOnLaunch;
+ NSString *URLToInterpretOnLaunch;
NSMutableArray *pathsToOpenOnLaunch;
- NSUndoManager *windowUndoManager;
- PrefsWindowController *prefsWindowController;
- GlobalPrefs *prefsController;
- NotationController *notationController;
+ NSUndoManager *windowUndoManager;
+ PrefsWindowController *prefsWindowController;
+ GlobalPrefs *prefsController;
+ NotationController *notationController;
+ SpaceSwitchingContext spaceSwitchCtx;
ViewLocationContext listUpdateViewCtx;
BOOL isFilteringFromTyping, typedStringIsCached;
BOOL isCreatingANote;
NSString *typedString;
+ NSArray *cTags;
NoteObject *currentNote;
NSArray *savedSelectedNotes;
-
- PreviewController *previewController;
- IBOutlet NSMenuItem *markdownPreview;
- IBOutlet NSMenuItem *multiMarkdownPreview;
- IBOutlet NSMenuItem *textilePreview;
- NSInteger currentPreviewMode;
-
- IBOutlet NSWindow *mainWindow;
- NSWindow *fullscreenWindow;
+
+ PreviewController *previewController;
+ // IBOutlet NSMenuItem *markdownPreview;
+ IBOutlet NSMenuItem *multiMarkdownPreview;
+ IBOutlet NSMenuItem *textilePreview;
+ IBOutlet NSMenuItem *previewToggler;
+ IBOutlet NSMenuItem *lockNoteItem;
+ IBOutlet NSMenuItem *printPreviewItem;
+ IBOutlet NSMenuItem *savePreviewItem;
+ NSInteger currentPreviewMode;
}
void outletObjectAwoke(id sender);
@@ -106,25 +131,29 @@ void outletObjectAwoke(id sender);
- (void)runDelayedUIActionsAfterLaunch;
- (void)updateNoteMenus;
-- (BOOL)addNotesFromPasteboard:(NSPasteboard*)pasteboard;
- (IBAction)renameNote:(id)sender;
- (IBAction)deleteNote:(id)sender;
+- (IBAction)copyNoteLink:(id)sender;
- (IBAction)exportNote:(id)sender;
+- (IBAction)revealNote:(id)sender;
- (IBAction)printNote:(id)sender;
- (IBAction)tagNote:(id)sender;
- (IBAction)importNotes:(id)sender;
+- (IBAction)switchViewLayout:(id)sender;
- (IBAction)fieldAction:(id)sender;
- (NoteObject*)createNoteIfNecessary;
- (void)searchForString:(NSString*)string;
-- (NSUInteger)_revealNote:(NoteObject*)note options:(NSUInteger)opts;
+- (NSUInteger)revealNote:(NoteObject*)note options:(NSUInteger)opts;
- (BOOL)displayContentsForNoteAtIndex:(int)noteIndex;
- (void)processChangedSelectionForTable:(NSTableView*)table;
- (void)setEmptyViewState:(BOOL)state;
- (void)cancelOperation:(id)sender;
- (void)_setCurrentNote:(NoteObject*)aNote;
-- (void)_expandToolbar;
-- (void)_collapseToolbar;
+//- (void)_expandToolbar;
+//- (void)_collapseToolbar;
+- (void)_forceRegeneratePreviewsForTitleColumn;
+- (void)_configureDividerForCurrentLayout;
- (NoteObject*)selectedNoteObject;
- (void)restoreListStateUsingPreferences;
@@ -144,19 +173,51 @@ void outletObjectAwoke(id sender);
- (IBAction)bringFocusToControlField:(id)sender;
- (NSWindow*)window;
--(IBAction)togglePreview:(id)sender;
--(void)postTextUpdate;
--(IBAction)selectPreviewMode:(id)sender;
--(IBAction)toggleSourceView:(id)sender;
+//elasticwork
+- (void)setIsEditing:(BOOL)inBool inCell:(NSCell *)theCell;
+- (void)setIsEditing:(BOOL)inBool;
+//- (void)focusOnCtrlFld:(id)sender;
+- (void)drawNotesTable;
+- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
+- (NSMenu *)statBarMenu;
+- (BOOL)toggleAttachedWindow:(id)sender;
+- (BOOL)toggleAttachedMenu:(id)sender;
+- (NSArray *)commonLabels;
+- (IBAction)multiTag:(id)sender;
+- (void)setDualFieldInToolbar;
+- (void)setDualFieldInView;
+- (void)setDualFieldIsVisible:(BOOL)isVis;
+//- (void)hideDualFieldView;
+//- (void)showDualFieldView;
+- (BOOL)dualFieldIsVisible;
+- (IBAction)toggleCollapse:(id)sender;
+- (void)setMaxNoteBodyWidth;
+- (IBAction)toggleFullscreen:(id)sender;
+- (IBAction)openFileInEditor:(id)sender;
+- (NSArray *)getTxtAppList;
+- (void)updateTextApp:(id)sender;
+- (IBAction)setBWColorScheme:(id)sender;
+- (IBAction)setLCColorScheme:(id)sender;
+- (IBAction)setUserColorScheme:(id)sender;
+- (void)updateFieldAttributes;
+- (void)updateColorScheme;
+- (NSColor*)_selectionColor;
+- (void)setBackgrndColor:(NSColor *)inColor;
+- (void)setForegrndColor:(NSColor *)inColor;
+- (NSColor *)backgrndColor;
+- (NSColor *)foregrndColor;
+- (void)updateWordCount:(BOOL)doIt;
+- (void)ensurePreviewIsVisible;
+- (IBAction)toggleWordCount:(id)sender;
+- (IBAction)togglePreview:(id)sender;
+- (IBAction)toggleSourceView:(id)sender;
- (IBAction)savePreview:(id)sender;
- (IBAction)sharePreview:(id)sender;
+- (IBAction)lockPreview:(id)sender;
+- (IBAction)printPreview:(id)sender;
+- (void)postTextUpdate;
+- (IBAction)selectPreviewMode:(id)sender;
--(void)setMenuItemStates;
--(IBAction)toggleLayout:(id)sender;
--(IBAction)collapseNotes:(id)sender;
-
--(void)updateScheme;
--(void)updateRTL;
-
-- (IBAction)toggleFullscreen:(id)sender;
+- (void)updateRTL;
+- (void)refreshNotesList;
@end
View
2,242 AppController.m
1,752 additions, 490 deletions not shown
View
28 AppController_Importing.h
@@ -0,0 +1,28 @@
+//
+// AppController_Importing.h
+// Notation
+//
+// Created by Zachary Schneirov on 1/14/11.
+
+/*Copyright (c) 2010, Zachary Schneirov. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modification, are permitted
+ provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright notice, this list of conditions
+ and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice, this list of
+ conditions and the following disclaimer in the documentation and/or other materials provided with
+ the distribution.
+ - Neither the name of Notational Velocity nor the names of its contributors may be used to endorse
+ or promote products derived from this software without specific prior written permission. */
+
+
+#import <Cocoa/Cocoa.h>
+#import "AppController.h"
+
+@interface AppController (Importing)
+
+- (BOOL)addNotesFromPasteboard:(NSPasteboard*)pasteboard;
+- (BOOL)interpretNVURL:(NSURL*)aURL;
+- (NSString*)stringWithNoteURLsOnPasteboard:(NSPasteboard*)pboard;
+
+@end
View
336 AppController_Importing.m
@@ -0,0 +1,336 @@
+//
+// AppController_Importing.m
+// Notation
+//
+// Created by Zachary Schneirov on 1/14/11.
+
+/*Copyright (c) 2010, Zachary Schneirov. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modification, are permitted
+ provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright notice, this list of conditions
+ and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice, this list of
+ conditions and the following disclaimer in the documentation and/or other materials provided with
+ the distribution.
+ - Neither the name of Notational Velocity nor the names of its contributors may be used to endorse
+ or promote products derived from this software without specific prior written permission. */
+
+
+#import "AppController_Importing.h"
+#import "NotationController.h"
+#import "NotationFileManager.h"
+#import "BookmarksController.h"
+#import "DualField.h"
+#import "SyncSessionController.h"
+#import "NotationSyncServiceManager.h"
+#import "NotationDirectoryManager.h"
+#import "AlienNoteImporter.h"
+#import "NSString_NV.h"
+#import <WebKit/WebArchive.h>
+#import "GlobalPrefs.h"
+#import "NSData_transformations.h"
+#import "AttributedPlainText.h"
+#import "NSCollection_utils.h"
+#import "NoteObject.h"
+#import "NotationPrefs.h"
+
+@implementation AppController (Importing)
+
+- (BOOL)addNotesFromPasteboard:(NSPasteboard*)pasteboard {
+
+ NSArray *types = [pasteboard types];
+ NSMutableAttributedString *newString = nil;
+ NSData *data = nil;
+ BOOL pbHasPlainText = [types containsObject:NSStringPboardType];
+
+ if ([types containsObject:NSFilenamesPboardType]) {
+ NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType];
+ if ([files isKindOfClass:[NSArray class]]) {
+ if ([notationController openFiles:files]) return YES;
+ }
+ }
+
+ NSString *sourceIdentifierString = nil;
+
+ //webkit URL!
+ if ([types containsObject:WebArchivePboardType]) {
+ sourceIdentifierString = [[pasteboard dataForType:WebArchivePboardType] pathURLFromWebArchive];
+ //gecko URL!
+ } else if ([types containsObject:[NSString customPasteboardTypeOfCode:0x4D5A0003]]) {
+ //lazilly use syntheticTitle to get first line, even though that's not how our API is documented
+ sourceIdentifierString = [[pasteboard stringForType:[NSString customPasteboardTypeOfCode:0x4D5A0003]] syntheticTitleAndTrimmedBody:NULL];
+ unichar nullChar = 0x0;
+ sourceIdentifierString = [sourceIdentifierString stringByReplacingOccurrencesOfString:
+ [NSString stringWithCharacters:&nullChar length:1] withString:@""];
+ }
+
+ if ([types containsObject:NSURLPboardType] || (pbHasPlainText && [[pasteboard stringForType:NSStringPboardType] superficiallyResemblesAnHTTPURL])) {
+ NSURL *url = [NSURL URLFromPasteboard:pasteboard];
+ if (!url) url = [NSURL URLWithString:[pasteboard stringForType:NSStringPboardType]];
+
+ NSString *potentialURLString = pbHasPlainText ? [pasteboard stringForType:NSStringPboardType] : nil;
+ if (potentialURLString && [[url absoluteString] isEqualToString:potentialURLString]) {
+ //only begin downloading if we know that there's no other useful string data
+ //because we've already checked NSFilenamesPboardType
+
+ if ([[url scheme] caseInsensitiveCompare:@"http"] == NSOrderedSame ||
+ [[url scheme] caseInsensitiveCompare:@"https"] == NSOrderedSame ||
+ [[url scheme] caseInsensitiveCompare:@"ftp"] == NSOrderedSame) {
+ NSString *linkTitleType = [NSString customPasteboardTypeOfCode:0x75726C6E];
+ NSString *linkTitle = [types containsObject:linkTitleType] ? [[pasteboard stringForType:linkTitleType] syntheticTitleAndTrimmedBody:NULL] : nil;
+ if (!linkTitle) {
+ //try urld instead of urln
+ linkTitleType = [NSString customPasteboardTypeOfCode:0x75726C64];
+ linkTitle = [types containsObject:linkTitleType] ? [[pasteboard stringForType:linkTitleType] syntheticTitleAndTrimmedBody:NULL] : nil;
+ }
+ [[[[AlienNoteImporter alloc] init] autorelease] importURLInBackground:url linkTitle:linkTitle receptionDelegate:self];
+ return YES;
+ }
+ }
+ }
+
+ //safari on 10.5 does not seem to provide a plain-text equivalent, so we must be able to dumb-down RTF data as well
+ //should fall-back to plain text if 1) user doesn't want styles and 2) plain text is actually available
+ BOOL shallUsePlainTextFallback = pbHasPlainText && ![prefsController pastePreservesStyle];
+ BOOL hasRTFData = NO;
+
+ if ([types containsObject:NVPTFPboardType]) {
+ if ((data = [pasteboard dataForType:NVPTFPboardType]))
+ newString = [[NSMutableAttributedString alloc] initWithRTF:data documentAttributes:NULL];
+
+ } else if ([types containsObject:NSRTFPboardType] && !shallUsePlainTextFallback) {
+ if ((data = [pasteboard dataForType:NSRTFPboardType]))
+ newString = [[NSMutableAttributedString alloc] initWithRTF:data documentAttributes:NULL];
+ hasRTFData = YES;
+ } else if ([types containsObject:NSRTFDPboardType] && !shallUsePlainTextFallback) {
+ if ((data = [pasteboard dataForType:NSRTFDPboardType]))
+ newString = [[NSMutableAttributedString alloc] initWithRTFD:data documentAttributes:NULL];
+ hasRTFData = YES;
+ } else if ([types containsObject:WebArchivePboardType] && !shallUsePlainTextFallback) {
+ if ((data = [pasteboard dataForType:WebArchivePboardType])) {
+ //set a timeout because -[NSHTMLReader _loadUsingWebKit] can sometimes hang
+ newString = [[NSMutableAttributedString alloc] initWithData:data options:[NSDictionary optionsDictionaryWithTimeout:10.0]
+ documentAttributes:NULL error:NULL];
+ }
+ hasRTFData = YES;
+
+ } else if ([types containsObject:NSHTMLPboardType] && !shallUsePlainTextFallback) {
+ if ((data = [pasteboard dataForType:NSHTMLPboardType]))
+ newString = [[NSMutableAttributedString alloc] initWithHTML:data documentAttributes:NULL];
+ hasRTFData = YES;
+ } else if (pbHasPlainText) {
+
+ NSString *pboardString = [pasteboard stringForType:NSStringPboardType];
+ if (pboardString) newString = [[NSMutableAttributedString alloc] initWithString:pboardString];
+ }
+
+ [newString autorelease];
+ if ([newString length] > 0) {
+ [newString removeAttachments];
+
+ if (hasRTFData && ![prefsController pastePreservesStyle]) //fallback scenario
+ newString = [[[NSMutableAttributedString alloc] initWithString:[newString string]] autorelease];
+
+ NSUInteger bodyLoc = 0, prefixedSourceLength = 0;
+ NSString *noteTitle = [[newString string] syntheticTitleAndSeparatorWithContext:NULL bodyLoc:&bodyLoc maxTitleLen:36];
+ if ([sourceIdentifierString length] > 0) {
+ //add the URL or wherever it was that this piece of text came from
+ prefixedSourceLength = [[newString prefixWithSourceString:sourceIdentifierString] length];
+ }
+ [newString santizeForeignStylesForImporting];
+
+ NoteObject *note = [[[NoteObject alloc] initWithNoteBody:newString title:noteTitle delegate:notationController
+ format:[notationController currentNoteStorageFormat] labels:nil] autorelease];
+ if (bodyLoc > 0 && [newString length] >= bodyLoc + prefixedSourceLength) [note setSelectedRange:NSMakeRange(prefixedSourceLength, bodyLoc)];
+ [notationController addNewNote:note];
+
+ return note != nil;
+ }
+
+ return NO;
+}
+
+- (BOOL)interpretNVURL:(NSURL*)aURL {
+ // currently supported:
+ // hostname -> command
+ // first level -> search term / title
+ // second level -> sync keys as parameters
+ // example: nv://find/url%20test/?SN=agtzaW1wbGUtbm90ZXINCxIETm90ZRiY-dEFDA&NV=5WJ0eP3YRaCjyQn%2F8p62iQ%3D%3D
+
+ NSUInteger j, i = 0;
+
+ if ([[aURL host] isEqualToString:@"find"]) {
+ //dispatch searchForString: and revealNote:options: as appropriate
+
+ //add currentNote to the snapback button back-stack
+ if (currentNote) {
+ [field pushFollowedLink:[[[NoteBookmark alloc] initWithNoteObject:currentNote searchString:[self fieldSearchString]] autorelease]];
+ }
+
+ NSString *terms = [aURL path];
+ [self searchForString:([terms length] && [terms characterAtIndex:0] == '/') ? [terms substringFromIndex:1] : terms];
+
+ NSArray *params = [[aURL query] componentsSeparatedByString:@"&"];
+ NSArray *svcs = [[SyncSessionController class] allServiceNames];
+ NoteObject *foundNote = nil;
+
+ for (i=0; i<[params count]; i++) {
+ NSString *idStr = [params objectAtIndex:i];
+
+ if ([idStr hasPrefix:@"NV="] && [idStr length] > 3) {
+ NSData *uuidData = [[[idStr substringFromIndex:3] stringByReplacingPercentEscapes] decodeBase64WithNewlines:NO];
+ if ((foundNote = [notationController noteForUUIDBytes:(CFUUIDBytes*)[uuidData bytes]]))
+ goto handleFound;
+ }
+
+ for (j=0; j<[svcs count]; j++) {
+ NSString *serviceName = [svcs objectAtIndex:j];
+ if ([idStr hasPrefix:[NSString stringWithFormat:@"%@=", serviceName]] && [idStr length] > [serviceName length] + 1) {
+ //lookup note with identical key for this service
+ NSString *key = [[idStr substringFromIndex:[serviceName length] + 1] stringByReplacingPercentEscapes];
+ if ((foundNote = [notationController noteForKey:key ofServiceClass:[[SyncSessionController allServiceClasses] objectAtIndex:j]]))
+ goto handleFound;
+ }
+ }
+ }
+ handleFound:
+ //if this search had initiated a clearing of the history, then make sure it doesn't happen
+ [NSObject cancelPreviousPerformRequestsWithTarget:field selector:@selector(clearFollowedLinks) object:nil];
+
+ if (foundNote) [self revealNote:foundNote options:NVOrderFrontWindow];
+ return YES;
+
+ } else if ([[aURL host] isEqualToString:@"make"]) {
+
+ NSArray *params = [[aURL query] componentsSeparatedByString:@"&"];
+
+ //parameters: "title" and one of the following for the body: "txt", "html" (maybe "md" for markdown in the future)
+ //if title is missing, add the body via -[addNotesFromPasteboard:]
+ NSString *title = nil, *txtBody = nil, *htmlBody = nil, *tags = nil, *urlTxt = nil;
+ for (i=0; i<[params count]; i++) {
+ NSString *compStr = [params objectAtIndex:i];
+ if ([compStr hasPrefix:@"title="] && [compStr length] > 6) {
+ title = [[compStr substringFromIndex:6] stringByReplacingPercentEscapes];
+ } else if ([compStr hasPrefix:@"txt="] && [compStr length] > 4) {
+ txtBody = [[compStr substringFromIndex:4] stringByReplacingPercentEscapes];
+ } else if ([compStr hasPrefix:@"html="] && [compStr length] > 5) {
+ htmlBody = [[compStr substringFromIndex:5] stringByReplacingPercentEscapes];
+ } else if ([compStr hasPrefix:@"tags="] && [compStr length] > 5) {
+ tags = [[compStr substringFromIndex:5] stringByReplacingPercentEscapes];
+ }else if ([compStr hasPrefix:@"url="] && [compStr length] > 4) {
+ urlTxt = [[compStr substringFromIndex:4] stringByReplacingPercentEscapes];
+ txtBody = nil;
+ htmlBody = nil;
+ }
+ }
+ if (urlTxt) {
+ // NSPasteboard *pboard = [NSPasteboard pasteboardWithUniqueName];
+ NSURL *theURL = [NSURL URLWithString:urlTxt];
+ // NSData *data = [urlTxt dataUsingEncoding:NSUTF8StringEncoding];
+ if (theURL) {
+ // [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
+ //[pboard setData:data forType:NSStringPboardType];
+ NSString *linkTitle = nil;
+ if (title) {
+ linkTitle = title;
+ }
+ [[[[AlienNoteImporter alloc] init] autorelease] importURLInBackground:theURL linkTitle:linkTitle receptionDelegate:self];
+ }
+ return;
+ }else{
+ if (title && (txtBody || htmlBody)) {
+ NSMutableAttributedString *attributedContents = nil;
+
+ if (htmlBody) {
+ attributedContents = [[NSMutableAttributedString alloc] initWithHTML:[htmlBody dataUsingEncoding:NSUTF8StringEncoding]
+ options:[NSDictionary optionsDictionaryWithTimeout:10.0] documentAttributes:NULL];
+ } else {
+ attributedContents = [[NSMutableAttributedString alloc] initWithString:txtBody attributes:[prefsController noteBodyAttributes]];
+ }
+ [attributedContents removeAttachments];
+ [attributedContents santizeForeignStylesForImporting];
+
+ NoteObject *note = [[[NoteObject alloc] initWithNoteBody:[attributedContents autorelease] title:title delegate:notationController
+ format:[notationController currentNoteStorageFormat] labels:tags] autorelease];
+ [notationController addNewNote:note];
+ return YES;
+ } else if (txtBody || htmlBody) {
+ NSPasteboard *pboard = [NSPasteboard pasteboardWithUniqueName];
+ NSData *data = [htmlBody dataUsingEncoding:NSUTF8StringEncoding];
+ [pboard declareTypes:[NSArray arrayWithObject: data ? NSHTMLPboardType : NSStringPboardType] owner:nil];
+ if (data) {
+ [pboard setData:data forType:NSHTMLPboardType];
+ } else if (txtBody) {
+ [pboard setString:txtBody forType:NSStringPboardType];
+ } else {
+ NSLog(@"no txt or html to add to pboard");
+ return NO;
+ }
+ return [self addNotesFromPasteboard:pboard];
+ }
+ }
+ } else if ([[aURL host] length]) {
+ //assume find by default
+ if (currentNote) {
+ [field pushFollowedLink:[[[NoteBookmark alloc] initWithNoteObject:currentNote searchString:[self fieldSearchString]] autorelease]];
+ }
+ [self searchForString:[aURL host]];
+ return YES;
+ }
+
+ return NO;
+}
+
+- (NSString*)stringWithNoteURLsOnPasteboard:(NSPasteboard*)pboard {
+ //paste as a file:// URL, so that it can be linked
+
+ NSMutableString *allURLsString = [NSMutableString string];
+
+ NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
+ if ([files isKindOfClass:[NSArray class]]) {
+ NSArray *unknownPaths = files;
+ NSUInteger i;
+
+ if ([notationController currentNoteStorageFormat] != SingleDatabaseFormat) {
+ //notes are stored as separate files, so if these paths are in the notes folder then NV can create double-bracketed-links to them instead
+
+ NSSet *existingNotes = [notationController notesWithFilenames:files unknownFiles:&unknownPaths];
+ if ([existingNotes count]) {
+ //create double-bracketed links using these notes' titles
+ NSArray *existingArray = [existingNotes allObjects];
+ for (i=0; i<[existingArray count]; i++) {
+ [allURLsString appendFormat:@"[[%@]]%s", titleOfNote([existingArray objectAtIndex:i]),
+ (i < [existingArray count] - 1) || [unknownPaths count] ? "\n" : ""];
+ }
+ }
+ }
+ //NSLog(@"paths not found in DB: %@", unknownPaths);
+
+ for (i=0; i<[unknownPaths count]; i++) {
+ NSURL *url = [NSURL fileURLWithPath:[unknownPaths objectAtIndex:i]];
+ if (url) {
+ NSString *linkFormat = @"<%@>%s";
+ NSString *pathString = [url absoluteString];
+ NSLog(@"%s",pathString);
+ if ([pathString hasSuffix:@"jpg"] ||
+ [pathString hasSuffix:@"jpeg"] ||
+ [pathString hasSuffix:@"gif"] ||
+ [pathString hasSuffix:@"png"])
+ {
+ currentPreviewMode = [[NSUserDefaults standardUserDefaults] integerForKey:@"markupPreviewMode"];
+ if (currentPreviewMode == MarkdownPreview || currentPreviewMode == MultiMarkdownPreview) {
+ linkFormat = @"![](%@)%s";
+ } else if (currentPreviewMode == TextilePreview) {
+ linkFormat = @"!%@()!%s";
+ }
+ }
+ [allURLsString appendFormat:linkFormat,
+ [pathString stringByReplacingOccurrencesOfString:@"file://localhost" withString:@"file://"],
+ (i < [unknownPaths count] - 1) ? "\n" : ""];
+ }
+ }
+ }
+ return allURLsString;
+}
+
+@end
View
2  AppController_Preview.m
@@ -15,7 +15,7 @@ -(NSString *)noteContent
}
-(NSInteger)currentPreviewMode
-{
+{
return currentPreviewMode;
}
View
11 AttributedPlainText.h
@@ -20,20 +20,24 @@
#define SEPARATE_ATTRS 0
+extern NSString *NVHiddenDoneTagAttributeName;
+extern NSString *NVHiddenBulletIndentAttributeName;
+
@interface NSMutableAttributedString (AttributedPlainText)
- (void)trimLeadingWhitespace;
- (void)removeAttachments;
-- (void)prefixWithSourceString:(NSString*)source;
+- (NSString*)prefixWithSourceString:(NSString*)source;
- (NSString*)trimLeadingSyntheticTitle;
-- (NSString*)getLeadingSyntheticTitle;
#if SEPARATE_ATTRS
+ (NSMutableAttributedString*)attributedStringWithString:(NSString*)text attributesByRange:(NSDictionary*)attributes font:(NSFont*)font;
#endif
- (void)santizeForeignStylesForImporting;
- (void)addLinkAttributesForRange:(NSRange)changedRange;
+- (void)_addDoubleBracketedNVLinkAttributesForRange:(NSRange)changedRange;
+- (void)addStrikethroughNearDoneTagsForRange:(NSRange)changedRange;
- (BOOL)restyleTextToFont:(NSFont*)currentFont usingBaseFont:(NSFont*)baseFont;
@end
@@ -41,7 +45,8 @@
@interface NSAttributedString (AttributedPlainText)
-+ (NSCharacterSet*)antiURLCharacterSet;
+- (BOOL)attribute:(NSString*)anAttribute existsInRange:(NSRange)aRange;
+
- (NSArray*)allLinks;
- (id)findNextLinkAtIndex:(unsigned int)startIndex effectiveRange:(NSRange *)range;
#if SEPARATE_ATTRS
View
230 AttributedPlainText.m
@@ -20,6 +20,13 @@
#import "NSCollection_utils.h"
#import "GlobalPrefs.h"
#import "NSString_NV.h"
+#import <AutoHyperlinks/AutoHyperlinks.h>
+
+
+NSString *NVHiddenDoneTagAttributeName = @"NVDoneTag";
+NSString *NVHiddenBulletIndentAttributeName = @"NVBulletIndentTag";
+
+static BOOL _StringWithRangeIsProbablyObjC(NSString *string, NSRange blockRange);
@implementation NSMutableAttributedString (AttributedPlainText)
@@ -64,24 +71,17 @@ - (void)removeAttachments {
- (NSString*)trimLeadingSyntheticTitle {
NSUInteger bodyLoc = 0;
- NSString *title = [[self string] syntheticTitleAndSeparatorWithContext:NULL bodyLoc:&bodyLoc oldTitle:nil];
+ NSString *title = [[self string] syntheticTitleAndSeparatorWithContext:NULL bodyLoc:&bodyLoc maxTitleLen:60];
if (bodyLoc > 0 && [self length] >= bodyLoc) [self deleteCharactersInRange:NSMakeRange(0, bodyLoc)];
return title;
}
-- (NSString*)getLeadingSyntheticTitle {
- NSUInteger bodyLoc = 0;
-
- NSString *title = [[self string] syntheticTitleAndSeparatorWithContext:NULL bodyLoc:&bodyLoc oldTitle:nil];
-
- return title;
-}
-
-- (void)prefixWithSourceString:(NSString*)source {
- source = [NSString stringWithFormat:@"From <%@>:\n\n", source];
- [self insertAttributedString:[[[NSAttributedString alloc] initWithString:source] autorelease] atIndex:0];
+- (NSString*)prefixWithSourceString:(NSString*)source {
+ NSString *sourceWContext = [NSString stringWithFormat:@"%@ <%@>:\n\n", NSLocalizedString(@"From", @"prefix for source-URLs inserted into imported notes; e.g., 'From <http://www.apple.com>: ...'"), source];
+ [self insertAttributedString:[[[NSAttributedString alloc] initWithString:sourceWContext] autorelease] atIndex:0];
+ return sourceWContext;
}
- (void)santizeForeignStylesForImporting {
@@ -89,6 +89,7 @@ - (void)santizeForeignStylesForImporting {
[self removeAttribute:NSLinkAttributeName range:range];
[self restyleTextToFont:[[GlobalPrefs defaultPrefs] noteBodyFont] usingBaseFont:nil];
[self addLinkAttributesForRange:range];
+ [self addStrikethroughNearDoneTagsForRange:range];
}
- (BOOL)restyleTextToFont:(NSFont*)currentFont usingBaseFont:(NSFont*)baseFont {
@@ -100,7 +101,7 @@ - (BOOL)restyleTextToFont:(NSFont*)currentFont usingBaseFont:(NSFont*)baseFont {
NSAssert(currentFont != nil, @"restyleTextToFont needs a current font!");
- NS_DURING
+ @try {
while (NSMaxRange(effectiveRange) < stringLength) {
// Get the attributes for the current range
@@ -163,55 +164,178 @@ - (BOOL)restyleTextToFont:(NSFont*)currentFont usingBaseFont:(NSFont*)baseFont {
rangesChanged++;
}
-
- NS_HANDLER
- NSLog(@"Error trying to re-style text (%@, %@)", [localException name], [localException reason]);
- NS_ENDHANDLER
+ }
+ @catch (NSException *e) {
+ NSLog(@"Error trying to re-style text (%@, %@)", [e name], [e reason]);
+ }
return rangesChanged > 0;
}
- (void)addLinkAttributesForRange:(NSRange)changedRange {
- NSCharacterSet *antiURLSpace = [NSAttributedString antiURLCharacterSet];
- NSString *string = [self string];
- NSRange totalRange = NSMakeRange(0, [string length]);
- NSString *substring = string;
- if (!NSEqualRanges(totalRange, changedRange)) {
- substring = [string substringWithRange:changedRange];
+ if (!changedRange.length)
+ return;
+
+ //lazily loads Adium's BSD-licensed Auto-Hyperlinks:
+ //http://trac.adium.im/wiki/AutoHyperlinksFramework
+
+ static Class AHHyperlinkScanner = Nil;
+ static Class AHMarkedHyperlink = Nil;
+ if (!AHHyperlinkScanner || !AHMarkedHyperlink) {
+ if (![[NSBundle bundleWithPath:[[[NSBundle mainBundle] privateFrameworksPath] stringByAppendingPathComponent:@"AutoHyperlinks.framework"]] load]) {
+ NSLog(@"Could not load AutoHyperlinks framework");
+ return;
+ }
+ AHHyperlinkScanner = NSClassFromString(@"AHHyperlinkScanner");
+ AHMarkedHyperlink = NSClassFromString(@"AHMarkedHyperlink");
}
+
+ id scanner = [AHHyperlinkScanner hyperlinkScannerWithString:[[self string] substringWithRange:changedRange]];
+ id markedLink = nil;
+ while ((markedLink = [scanner nextURI])) {
+ NSURL *markedLinkURL = nil;
+ if ((markedLinkURL = [markedLink URL]) && !([markedLinkURL isFileURL] && [[markedLinkURL absoluteString]
+ rangeOfString:@"/.file/" options:NSLiteralSearch].location != NSNotFound)) {
+ [self addAttribute:NSLinkAttributeName value:markedLinkURL
+ range:NSMakeRange([markedLink range].location + changedRange.location, [markedLink range].length)];
+ }
+ }
+
+ //also detect double-bracketed URLs here
+ [self _addDoubleBracketedNVLinkAttributesForRange:changedRange];
+}
+
+- (void)_addDoubleBracketedNVLinkAttributesForRange:(NSRange)changedRange {
+ //add link attributes for [[wiki-style links to other notes or search terms]]
+
+ static NSMutableCharacterSet *antiInteriorSet = nil;
+ if (!antiInteriorSet) {
+ antiInteriorSet = [[NSMutableCharacterSet characterSetWithCharactersInString:@"[]"] retain];
+ [antiInteriorSet formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]];
+ [antiInteriorSet formUnionWithCharacterSet:[NSCharacterSet illegalCharacterSet]];
+ [antiInteriorSet formUnionWithCharacterSet:[NSCharacterSet controlCharacterSet]];
+ }
+
+ NSString *string = [self string];
+ NSUInteger nextScanLoc = 0;
+ NSRange scanRange = changedRange;
+
+ while (NSMaxRange(scanRange) <= NSMaxRange(changedRange)) {
- if ([substring rangeOfCharacterFromSet:antiURLSpace options:NSLiteralSearch].location == NSNotFound)
- substring = [substring stringByAppendingString:@" "];
+ NSUInteger begin = [string rangeOfString:@"[[" options:NSLiteralSearch range:scanRange].location;
+ if (begin == NSNotFound) break;
+ begin += 2;
+ NSUInteger end = [string rangeOfString:@"]]" options:NSLiteralSearch
+ range:NSMakeRange(begin, changedRange.length - (begin - changedRange.location))].location;
+ if (end == NSNotFound) break;
+
+ NSRange blockRange = NSMakeRange(begin, (end - begin));
+
+ //double-braces must directly abut the search terms
+ //capture inner invalid "[["s, but not inner invalid "]]"s;
+ //because scanning, which is left to right, could be cancelled prematurely otherwise
+ if ([antiInteriorSet characterIsMember:[string characterAtIndex:begin]]) {
+ nextScanLoc = begin;
+ goto nextBlock;
+ }
+ //when encountering a newline in the midst of opposing double-brackets,
+ //continue scanning after the newline instead of after the end-brackets; avoid certain traps that change the behavior of multi- vs single-line scans
+ NSRange newlineRange = [string rangeOfCharacterFromSet:[NSCharacterSet newlineCharacterSet] options:NSLiteralSearch range:blockRange];
+ if (newlineRange.location != NSNotFound) {
+ nextScanLoc = newlineRange.location + 1;
+ goto nextBlock;
+ }
+
+ if (![antiInteriorSet characterIsMember:[string characterAtIndex:NSMaxRange(blockRange) - 1]] && !_StringWithRangeIsProbablyObjC(string, blockRange)) {
+
+ [self addAttribute:NSLinkAttributeName value:
+ [NSURL URLWithString:[@"nv://find/" stringByAppendingString:[[string substringWithRange:blockRange] stringWithPercentEscapes]]] range:blockRange];
+ }
+ //continue the scan starting at the end of the current block
+ nextScanLoc = NSMaxRange(blockRange) + 2;
+
+ nextBlock:
+ scanRange = NSMakeRange(nextScanLoc, changedRange.length - (nextScanLoc - changedRange.location));
+ }
+}
+
+static BOOL _StringWithRangeIsProbablyObjC(NSString *string, NSRange blockRange) {
+ //assuming this range is bookended with matching double-brackets,
+ //does the block contain unbalanced inner square brackets?
+ NSUInteger rightBracketLoc = [string rangeOfString:@"]" options:NSLiteralSearch range:blockRange].location;
+ NSUInteger leftBracketLoc = [string rangeOfString:@"[" options:NSLiteralSearch range:blockRange].location;
- NSScanner *wordScanner = [NSScanner scannerWithString:substring];
+ //no brackets of either variety
+ if (rightBracketLoc == NSNotFound && leftBracketLoc == NSNotFound) return NO;
- //loop until end of string
- while (![wordScanner isAtEnd]) {
- NSRange wordRange = NSMakeRange(NSNotFound, 0);
- NSString *word = nil;
+ //has balanced inner brackets; right bracket exists and is actually to the right of the left bracket
+ if (rightBracketLoc != NSNotFound && rightBracketLoc > leftBracketLoc) return NO;
+
+ //no right bracket or no left bracket
+ return YES;
+
+ //this still doesn't catch something like "[[content prefixWithSourceString:[[getter url] absoluteString]] length];"
+ //an improvement would be to use rangeOfCharacterFromSet:@"[]" to count all the left and right brackets from left to right;
+ //a leftbracket would increment a count, a right bracket would decrement it; at the end of blockRange, the count should be 0
+ //this is left as an exercise to the anal-retentive reader
+}
+
+- (void)addStrikethroughNearDoneTagsForRange:(NSRange)changedRange {
+ //scan line by line
+ //if the line ends in " @done", then strikethrough everything prior and add NVHiddenDoneTagAttributeName
+ //if the line doesn't end in " @done", and it has NVHiddenDoneTagAttributeName + NSStrikethroughStyleAttributeName,
+ // then remove both attributes
+ //all other NSStrikethroughStyleAttributeName by itself will be ignored
+
+ if (![[GlobalPrefs defaultPrefs] autoFormatsDoneTag])
+ return;
- while ([wordScanner scanUpToCharactersFromSet:antiURLSpace intoString:&word]) {
- if (word) {
- wordRange.length = [word length];
- wordRange.location = changedRange.location + [wordScanner scanLocation] - wordRange.length;
+ NSString *doneTag = @" @done";
+ NSCharacterSet *newlineSet = [NSCharacterSet newlineCharacterSet];
+
+ NSRange lineEndRange, scanRange = changedRange;
+
+ @try {
+ do {
+ if ((lineEndRange = [[self string] rangeOfCharacterFromSet:newlineSet options:NSLiteralSearch range:scanRange]).location == NSNotFound) {
+ //no newline; this is the end of the range, so set line-end to an imaginary position there
+ lineEndRange = NSMakeRange(NSMaxRange(scanRange), 1);
+ }
+
+ NSRange thisLineRange = NSMakeRange(scanRange.location, lineEndRange.location - scanRange.location);
+
+ //this detection is not good enough; it can't handle the case of @done(date)
+ if ([[[self string] substringWithRange:thisLineRange] hasSuffix:doneTag]) {
- NSAssert([word isEqualToString:[string substringWithRange:wordRange]], @"derived range is wrong!");
+ //add strikethrough and NVHiddenDoneTagAttributeName attributes, because this line ends in @done
+ [self addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:NSUnderlineStyleSingle],
+ NSStrikethroughStyleAttributeName, [NSNull null], NVHiddenDoneTagAttributeName, nil]
+ range:NSMakeRange(thisLineRange.location, thisLineRange.length - [doneTag length])];
+ //and the done tag itself should never be struck-through; remove that just in case typing attributes had carried over from elsewhere
+ [self removeAttribute:NSStrikethroughStyleAttributeName range:NSMakeRange(NSMaxRange(thisLineRange) - [doneTag length], [doneTag length])];
- NSURL *url = nil;
- if (wordRange.length && NSMaxRange(wordRange) <= [string length] && (url = [word linkForWord])) {
- if (url) [self addAttribute:NSLinkAttributeName value:url range:wordRange];
- }
+ } else if ([self attribute:NVHiddenDoneTagAttributeName existsInRange:thisLineRange]) {
+
+ //assume that this line was previously struck-through by NV due to the presence of a @done tag; remove those attrs now
+ [self removeAttribute:NVHiddenDoneTagAttributeName range:thisLineRange];
+ [self removeAttribute:NSStrikethroughStyleAttributeName range:thisLineRange];
}
- }
- unsigned int newLocation = [wordScanner scanLocation] + 1;
- if (newLocation >= [substring length])
- break;
- [wordScanner setScanLocation:newLocation];
+ //if scanRange has a non-zero length, then advance it further
+ if ((scanRange = NSMakeRange(NSMaxRange(thisLineRange), changedRange.length - (NSMaxRange(thisLineRange) - changedRange.location))).length)
+ scanRange = NSMakeRange(scanRange.location + 1, scanRange.length - 1);
+ else {
+ break;
+ }
+ } while (NSMaxRange(scanRange) <= NSMaxRange(changedRange));
+ }
+ @catch (NSException *e) {
+ NSLog(@"_%s(%@): %@", _cmd, NSStringFromRange(changedRange), e);
}
}
+
#if SEPARATE_ATTRS
#define VLISTBUFCOUNT 32
@@ -259,16 +383,18 @@ + (NSMutableAttributedString*)attributedStringWithString:(NSString*)text attribu
@implementation NSAttributedString (AttributedPlainText)
-+ (NSCharacterSet*)antiURLCharacterSet {
- static NSMutableCharacterSet *antiURLSpace = nil;
- if (!antiURLSpace) {
- antiURLSpace = [[NSMutableCharacterSet alloc] init];
- [antiURLSpace formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- [antiURLSpace addCharactersInString:@"<>[]\"()"];
+
+- (BOOL)attribute:(NSString*)anAttribute existsInRange:(NSRange)aRange {
+ NSRange effectiveRange = NSMakeRange(aRange.location, 0);
+
+ while (NSMaxRange(effectiveRange) < NSMaxRange(aRange)) {
+ if ([self attribute:anAttribute atIndex:NSMaxRange(effectiveRange) effectiveRange:&effectiveRange]) {
+ return YES;
+ }
}
- return antiURLSpace;
-}
+ return NO;
+}
- (NSArray*)allLinks {
NSRange range;
View
34 AugmentedScrollView.h
@@ -0,0 +1,34 @@
+/* AugmentedScrollView */
+
+/*Copyright (c) 2010, Zachary Schneirov. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modification, are permitted
+ provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright notice, this list of conditions
+ and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice, this list of
+ conditions and the following disclaimer in the documentation and/or other materials provided with
+ the distribution.
+ - Neither the name of Notational Velocity nor the names of its contributors may be used to endorse
+ or promote products derived from this software without specific prior written permission. */
+
+
+#import <Cocoa/Cocoa.h>
+/*
+@interface DragSquareView : NSView
+{
+ NSImage *dragImage;
+}
+
+@end
+*/
+
+@interface AugmentedScrollView : NSScrollView
+{
+ //BOOL showDragSquare;
+ //DragSquareView *dragSquare;
+}
+
+//- (BOOL)shouldDragWithPoint:(NSPoint)point sender:(id)sender;
+//- (void)_positionDragSquare;
+
+@end
View
125 AugmentedScrollView.m
@@ -0,0 +1,125 @@
+/*Copyright (c) 2010, Zachary Schneirov. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modification, are permitted
+ provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright notice, this list of conditions
+ and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice, this list of
+ conditions and the following disclaimer in the documentation and/or other materials provided with
+ the distribution.
+ - Neither the name of Notational Velocity nor the names of its contributors may be used to endorse
+ or promote products derived from this software without specific prior written permission. */
+
+#import "ETTransparentScroller.h"
+#import "AugmentedScrollView.h"
+#import "GlobalPrefs.h"
+
+
+
+/*
+@implementation DragSquareView
+
+- (id)initWithFrame:(NSRect)frameRect {
+ if ((self = [super initWithFrame:frameRect]) != nil) {
+ dragImage = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:@"ListDividerDrag.png"]];
+ }
+ return self;
+}
+
+- (void)drawRect:(NSRect)rect {
+ [dragImage compositeToPoint:rect.origin operation:NSCompositeCopy];
+
+}
+
+- (void)resetCursorRects {
+ [self addCursorRect:[self bounds] cursor: [NSCursor resizeLeftRightCursor]];
+}
+
+- (BOOL)isOpaque {
+ return YES;
+}
+
+- (void)dealloc {
+ [dragImage release];
+ [super dealloc];
+}
+
+@end
+*/
+
+@implementation AugmentedScrollView
+
+
+- (void)awakeFromNib {
+
+ //dragSquare = [[DragSquareView alloc] initWithFrame:NSMakeRect(0, 0, 15.0, 15.0)];
+ [[GlobalPrefs defaultPrefs] registerForSettingChange:@selector(setHorizontalLayout:sender:) withTarget:self];
+ if (!IsLionOrLater) {
+ [self setVerticalScroller:[[ETTransparentScroller alloc]init]];
+ }
+ /*
+ if ((showDragSquare = [[GlobalPrefs defaultPrefs] horizontalLayout])) {
+ //add dragsquare subview to this view
+ [self addSubview:dragSquare positioned:NSWindowAbove relativeTo:self];
+ [self _positionDragSquare];
+ }*/
+}
+
+- (void)settingChangedForSelectorString:(NSString*)selectorString {
+
+ if ([selectorString isEqualToString:SEL_STR(setHorizontalLayout:sender:)]) {
+
+ /*if ((showDragSquare = [[GlobalPrefs defaultPrefs] horizontalLayout])) {
+ //add drag square
+ [self addSubview:dragSquare positioned:NSWindowAbove relativeTo:self];
+ } else {
+ //remove drag square
+ [dragSquare removeFromSuperview];
+ }*/
+ [self tile];
+ }
+}
+
+- (void)dealloc {
+
+ //[dragSquare release];
+ [super dealloc];
+}
+/*
+- (BOOL)shouldDragWithPoint:(NSPoint)point sender:(id)sender {
+ BOOL inRect = NSMouseInRect([dragSquare convertPoint:point fromView:sender],
+ [dragSquare bounds], [dragSquare isFlipped]);
+
+ return showDragSquare && inRect;
+}
+
+- (void)_positionDragSquare {
+ NSSize oldSize = [[self verticalScroller] frame].size;
+ NSSize dragSize = [dragSquare frame].size;
+
+ [[self verticalScroller] setFrameSize:NSMakeSize(oldSize.width, oldSize.height - dragSize.height)];
+
+ NSRect newFrame = [[self verticalScroller] frame];
+ [dragSquare setFrameOrigin:NSMakePoint(NSMaxX(newFrame) - dragSize.width, NSMaxY(newFrame))];
+
+
+}*/
+
+- (void)tile {
+ [super tile];
+ if (![[self verticalScroller] isHidden]) {
+ NSRect vsRect = [[self verticalScroller] frame];
+ NSRect conRect = [[self contentView] frame];
+ NSView *wdContent = [[self contentView] retain];
+ conRect.size.width = conRect.size.width + vsRect.size.width;
+ [wdContent setFrame:conRect];
+ [wdContent release];
+ [[self verticalScroller] setFrame:vsRect];
+
+ }
+ /*if (showDragSquare) {
+ [self _positionDragSquare];
+ }*/
+}
+
+
+@end
View
14 BTTransparentScroller.h
@@ -1,14 +1,20 @@
//
-// BTTransparentScroller.h
-// Modified from BWToolkit by Brandon Walkin (www.brandonwalkin.com)
+// BTTransparentScroller.m
+//
+// Created by Brandon Walkin (www.brandonwalkin.com)
// All code is provided under the New BSD license.
//
+// Modified by Brett Terpstra on 12/8/10.
+// Copyright 2010 Circle Six Design. All rights reserved.
+//
+// Modified again by ElasticThreads on 03/10/11
#import <Cocoa/Cocoa.h>
-@interface BTTransparentScroller : NSScroller
-{
+@interface BTTransparentScroller : NSScroller {
BOOL isVertical;
+
}
+-(void)setBackgroundColor:(NSColor*)bgcolor;
@end
View
104 BTTransparentScroller.m
@@ -1,28 +1,33 @@
//
// BTTransparentScroller.m
-// BWToolkit
//
// Created by Brandon Walkin (www.brandonwalkin.com)
// All code is provided under the New BSD license.
//
+// Modified by Brett Terpstra on 12/8/10.
+// Copyright 2010 Circle Six Design. All rights reserved.
+//
+// Modified again by ElasticThreads on 03/10/11
+
#import "BTTransparentScroller.h"
+
// Vertical scroller
static NSImage *knobTop, *knobVerticalFill, *knobBottom, *slotTop, *slotVerticalFill, *slotBottom;
-static float verticalPaddingLeft = 6.0;
-static float verticalPaddingRight = 2.0;
-static float verticalPaddingTop = 4.0;
-static float verticalPaddingBottom = 4.0;
+static float verticalPaddingLeft = 4.0f;
+static float verticalPaddingRight = 5.0f;
+static float verticalPaddingTop = 8.0f;
+static float verticalPaddingBottom = 8.0f;
static float minKnobHeight;
// Horizontal scroller
-static NSImage *knobLeft, *knobHorizontalFill, *knobRight, *slotLeft, *slotHorizontalFill, *slotRight;
+/*static NSImage *knobLeft, *knobHorizontalFill, *knobRight, *slotLeft, *slotHorizontalFill, *slotRight;
static float horizontalPaddingLeft = 2.0;
static float horizontalPaddingRight = 2.0;
static float horizontalPaddingTop = 0.0;
static float horizontalPaddingBottom = 1.0;
-static float minKnobWidth;
+static float minKnobWidth;*/
static NSColor *backgroundColor;
@@ -41,24 +46,22 @@ + (void)initialize
NSBundle *bundle = [NSBundle mainBundle];
// Vertical scroller
- knobTop = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerKnobTop.tif"]];
- knobVerticalFill = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerKnobVerticalFill.tif"]];
- knobBottom = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerKnobBottom.tif"]];
+ knobTop = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"greyscrollerverttop3.tif"]];
+ knobVerticalFill = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"greyscrollervertfill3.tif"]];
+ knobBottom = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"greyscrollervertbottom3.tif"]];
slotTop = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerSlotTop.tif"]];
- slotVerticalFill = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerSlotVerticalFill.tif"]];
+ slotVerticalFill = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"scrollbarblue.tif"]];
slotBottom = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerSlotBottom.tif"]];
- // Horizontal scroller
- knobLeft = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerKnobLeft.tif"]];
- knobHorizontalFill = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerKnobHorizontalFill.tif"]];
- knobRight = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerKnobRight.tif"]];
- slotLeft = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerSlotLeft.tif"]];
- slotHorizontalFill = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerSlotHorizontalFill.tif"]];
- slotRight = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"BTransparentScrollerSlotRight.tif"]];
-
- backgroundColor = [[NSColor colorWithCalibratedRed:0.931 green:0.909 blue:0.884 alpha:1.000] retain];
+ backgroundColor = [[NSColor whiteColor] retain];
minKnobHeight = knobTop.size.height + knobVerticalFill.size.height + knobBottom.size.height + 40;
- minKnobWidth = knobLeft.size.width + knobHorizontalFill.size.width + knobRight.size.width + 10;
+ //minKnobWidth = knobLeft.size.width + knobHorizontalFill.size.width + knobRight.size.width + 10;
+}
+
+- (void)setBackgroundColor:(NSColor*)bgcolor;
+{
+ [backgroundColor release];
+ backgroundColor = [bgcolor retain];
}
- (id)initWithFrame:(NSRect)frameRect;
@@ -71,8 +74,10 @@ - (id)initWithFrame:(NSRect)frameRect;
isVertical = YES;
else
isVertical = NO;
+
+ // NSLog(@"isVertical1 is :%d",isVertical);
}
-
+
return self;
}
@@ -86,6 +91,8 @@ - (id)initWithCoder:(NSCoder *)decoder;
isVertical = YES;
else
isVertical = NO;
+
+ // NSLog(@"isVertical2 is :%d",isVertical);
}
return self;
@@ -114,33 +121,36 @@ - (void)drawRect:(NSRect)aRect;
if ([self knobProportion] > 0.0)
[self drawKnob];
}
- else if (!isVertical && ([self bounds].size.width - horizontalPaddingLeft - horizontalPaddingRight + 1) > minKnobWidth)
+ /*else if (!isVertical && ([self bounds].size.width - horizontalPaddingLeft - horizontalPaddingRight + 1) > minKnobWidth)
{
[self drawKnobSlot];
-
+
if ([self knobProportion] > 0.0)