All Projects → IvanoBilenchi → Ictextview

IvanoBilenchi / Ictextview

Licence: mit
UITextView subclass supporting string/regex search and highlighting

Projects that are alternatives of or similar to Ictextview

Notepad
[iOS] A fully themeable markdown editor with live syntax highlighting.
Stars: ✭ 705 (+119.63%)
Mutual labels:  regex, uitextview
core
🌈 light, fast, and easy to use, dependencies free javascript syntax highlighter, with automatic language detection
Stars: ✭ 40 (-87.54%)
Mutual labels:  regex, highlighting
Anyformatkit
Simple text formatting in Swift
Stars: ✭ 296 (-7.79%)
Mutual labels:  regex, uitextview
Pyregex
pyregex is a Python Regular Expression Online Tester
Stars: ✭ 282 (-12.15%)
Mutual labels:  regex
Rex
Your RegEx companion.
Stars: ✭ 283 (-11.84%)
Mutual labels:  regex
Hyperscan
High-performance regular expression matching library
Stars: ✭ 3,427 (+967.6%)
Mutual labels:  regex
Solarized
Solarized color scheme for Sublime Text 3
Stars: ✭ 314 (-2.18%)
Mutual labels:  highlighting
Kind Of
Get the native JavaScript type of a value, fast. Used by superstruct, micromatch and many others!
Stars: ✭ 268 (-16.51%)
Mutual labels:  regex
Regex
Regular expressions for swift
Stars: ✭ 306 (-4.67%)
Mutual labels:  regex
Attributedstring
基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
Stars: ✭ 294 (-8.41%)
Mutual labels:  regex
Python Syntax
Python syntax highlighting for Vim
Stars: ✭ 297 (-7.48%)
Mutual labels:  highlighting
Url Regex
Regular expression for matching URLs
Stars: ✭ 286 (-10.9%)
Mutual labels:  regex
React Native Walkthrough Tooltip
An inline wrapper for calling out React Native components via tooltip
Stars: ✭ 299 (-6.85%)
Mutual labels:  highlighting
Nomino
Batch rename utility for developers
Stars: ✭ 282 (-12.15%)
Mutual labels:  regex
Regex
The Hoa\Regex library.
Stars: ✭ 308 (-4.05%)
Mutual labels:  regex
Re Flex
The regex-centric, fast lexical analyzer generator for C++ with full Unicode support. Faster than Flex. Accepts Flex specifications. Generates reusable source code that is easy to understand. Introduces indent/dedent anchors, lazy quantifiers, functions for lex/syntax error reporting, and more. Seamlessly integrates with Bison and other parsers.
Stars: ✭ 274 (-14.64%)
Mutual labels:  regex
Markserv
🏁 serve markdown as html (GitHub style), index directories, live-reload as you edit
Stars: ✭ 304 (-5.3%)
Mutual labels:  highlighting
Vue Highlightjs
Syntax highlighting with highlight.js for Vue.js 2.x
Stars: ✭ 295 (-8.1%)
Mutual labels:  highlighting
Idiosyncratic Ruby.com
Documenting All Ruby Specialities 💎︎
Stars: ✭ 292 (-9.03%)
Mutual labels:  regex
Generex
A Java library for generating String from a regular expression.
Stars: ✭ 316 (-1.56%)
Mutual labels:  regex

ICTextView

Screenshot

Authors

Description

ICTextView is a UITextView subclass with optimized support for string/regex search and highlighting.

It also features some iOS 7+ specific improvements and bugfixes to the standard UITextView.

Features

  • Support for string literals and regular expression search.
  • Match highlighting.
  • Highly customizable.
  • Doesn't use delegate methods (you can still implement your own).
  • Methods to account for contentInset and textContainerInset in iOS 7+.
  • Contains workarounds for many known iOS 7+ UITextView bugs.

Compatibility

Supported iOS versions: 4.x and above (match highlighting starting from iOS 5.x).

Supported iOS SDKs: 5.x and above.

Installation

ICTextView can be installed via Cocoapods (just add pod 'ICTextView' to your Podfile, then run pod install) or as a Git submodule.

Alternatively, you can clone this repo, or even just grab the ICTextView folder and put it somewhere in your project.

ICTextView requires the QuartzCore framework, so make sure to link against it in your build settings.

It is an ARC only project, meaning you must compile it with ARC enabled (either globally or specifically for every .m source file in the ICTextView folder).

#import "ICTextView.h" and you're ready to go.

Configuration

See comments in the #pragma mark - Configuration section of the ICTextView.h header file.

Usage

Search

Searches can be performed via the scrollToMatch: and scrollToString: methods. scrollToMatch: performs regular expression searches, while scrollToString: searches for string literals.

Both search methods are regex-powered, and therefore make use of NSRegularExpressionOptions. They both support animation, range restriction, custom end scroll positioning and forward/backward search direction.

If a match is found, ICTextView highlights a primary match, and starts highlighting other matches while the user scrolls. Searching for the same pattern multiple times automatically matches the next result.

The rangeOfFoundString property contains the range of the current search match. You can get the actual string by calling the foundString method.

The resetSearch method lets you restore the search variables to their starting values, effectively resetting the search. Calls to resetSearch cause the highlights to be deallocated, regardless of the maxHighlightedMatches property.

After this method has been called, ICTextView stops highlighting results until a new search is performed.

Content insets methods

The scrollRangeToVisible:consideringInsets:[...] and scrollRectToVisible:animated:consideringInsets:[...] methods let you scroll until a certain range or rect is visible, eventually accounting for content insets.

This was the default behavior for scrollRangeToVisible: before iOS 7, but it has changed since (possibly because of a bug). These methods support animation and scroll positioning, similarly to the search methods.

The other methods are pretty much self-explanatory. See the #pragma mark - Misc section of the ICTextView.h header file for further info.

iOS 7 UITextView Bugfixes

Long story short, iOS 7 completely broke UITextView. ICTextView contains fixes for some very common issues:

  • NSTextContainer bug: UITextView initialized via initWithFrame: had an erratic behavior due to an uninitialized or wrong NSTextContainer.
  • Caret bug: the caret didn't consider contentInset nor textContainerInset and often went out of the visible area.
  • characterRangeAtPoint: bug: characterRangeAtPoint: always returned nil.
  • becomeFirstResponder bug: UITextView scrolled to a bogus location when becoming first responder in some circumstances.

These fixes, combined with the custom methods to account for contentInset and textContainerInset, should make working with ICTextView much more bearable than working with the standard UITextView.

Bugfixes introduced by ICTextView will be removed (or isolated) as soon as they are fixed by Apple.

License

ICTextView is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].