Other Pages

Other Software/Code by Me

Unmaintained Software

ANSIEscapeHelper

ANSIEscapeHelper is an Objective-C class for dealing with ANSI escape sequences. Its main purpose is to translate between NSStrings that contain ANSI escape sequences and similarly formatted NSAttributedStrings.

Here's a quick and simple example of how you'd most likely want to use this class:

AMR_ANSIEscapeHelper *ansiEscapeHelper =
    [[[AMR_ANSIEscapeHelper alloc] init] autorelease];

// display an ANSI-escaped string in a text view:
NSString *ansiEscapedStr =
    @"Let's pretend this string contains ANSI escape sequences";
NSAttributedString *attrStr = [ansiEscapeHelper
     attributedStringWithANSIEscapedString:ansiEscapedStr];
[[nsTextViewInstance textStorage] setAttributedString:attrStr];

// get an ANSI-escaped string from a text view:
NSAttributedString *attrStr = [nsTextViewInstance textStorage];
NSString *ansiEscapedStr = [ansiEscapeHelper
     ansiEscapedStringWithAttributedString:attrStr];

Check out the GitWeb repository browser (see below) if you want to get the code and be informed of new developments (I'll add new tags for any new versions that seem stable). If you fix something in this code or use it in your software, please let me know. Thanks.

Source code is available in a Git repository (click here to show/hide):

Repository URL:
http://github.com/ali-rantakari/ansiEscapeHelper

Repository web page:
http://github.com/ali-rantakari/ansiEscapeHelper

Example:
cd ~/mycode
git clone http://github.com/ali-rantakari/ansiEscapeHelper

Copyright © 2009-2010 Ali Rantakari