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.

You can read the API documentation here.

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

ANSIEscapeHelper *ansiEscapeHelper =
    [[[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://hasseg.org/git-public/ansiEscapeHelper.git/

Repository web page:
http://hasseg.org/gitweb?p=ansiEscapeHelper.git

Example:
cd ~/mycode
git clone http://hasseg.org/git-public/ansiEscapeHelper.git/

 

Copyright © 2009-2010 Ali Rantakari