Haiku API Bindings
TextView
Not logged in

Documentation | InterfaceKit | TextView

SYNOPSIS

Perl

use HaikuR1::TextView;

my $textview = HaikuR1::TextView->new(
    frame => $frame,
    name => $name,
    textRect => $textRect,
    resizingMode => $resizingMode,
    flags => $flags,
);
$window->AddChild($textview);

Python

import HaikuR1.InterfaceKit.TextView

textview = TextView(
    frame = frame,
    name = name,
    textRect = textRect,
    resizingMode = resizingMode,
    flags = flags,
)
window.AddChild(textview)

DESCRIPTION

Exposes the BTextView object.

For more information on TextView, see the Be Book class description, the Be Book overview, and the Haiku Book class description.

METHODS

Constructor

Creates a TextView.

Perl

HaikuR1::TextView->new(
    frame => $frame,
    name => $name,
    textRect => $textRect,
    resizingMode => $resizingMode,
    flags => $flags,
);
HaikuR1::TextView->new(
    frame => $frame,
    name => $name,
    textRect => $textRect,
    font => $font,
    color => $color,
    resizingMode => $resizingMode,
    flags => $flags,
);
HaikuR1::TextView->new($archive);

Python

TextView(
    frame = frame,
    name = name,
    textRect = textRect,
    resizingMode = resizingMode,
    flags = flags,
)
TextView(
    frame = frame,
    name = name,
    textRect = textRect,
    font = font,
    color = color,
    resizingMode = resizingMode,
    flags = flags,
)
TextView(archive)

Edit operations

Cut

Copy

Paste

Clear

Undo

UndoState

These methods do what you expect. UndoState returns two values: one of the undo state constants and a boolean indicating whether the available operation is a redo.

Cut, Copy, Paste, and Undo can also be called as hooks.

Perl

$textview->Cut($clipboard);
$textview->Copy($clipboard);
$textview->Paste($clipboard);
$textview->Clear();
$textview->Undo($clipboard);
$textview->UndoState();

Python

textview.Cut(clipboard)
textview.Copy(clipboard)
textview.Paste(clipboard)
textview.Clear()
textview.Undo(clipboard)
textview.UndoState()

FindWord

Given an offset, returns the starting and ending offsets of the "word" at that offset. A "word" is a sequence of characters in the same category. TextView currenly recognizes the following categories:

This method can also be called as a hook.

Perl

$textview->FindWord($offset);

Python

textview.FindWord(offset)

Insets

GetInsets

SetInsets

These methods are used with Layout-enabled TextViews.

Perl

$textview->GetInsets();
$textview->SetInsets(
    left => $left,
    top => $top,
    right => $right,
    bottom => $bottom,
);

Python

textview.GetInsets()
textview.SetInsets(
    left = left,
    top = top,
    right = right,
    bottom = bottom,
)

Lines

CountLines

CurrentLine

GoToLine

LineWidth

LineHeight

CanEndLine

These functions do what you expect. Note that CurrentLine and GoToLine use a zero-based index.

CanEndLine can also be called as a hook.

Perl

$textview->CountLines();
$textview->CurrentLine();
$textview->GoToLine($lineIndex);
$textview->LineWidth($lineIndex);
$textview->LineHeight($lineIndex);
$textview->TextHeight($startLine, $endLine);
$textview->CanEndLine($offset);

Python

textview.CountLines()
textview.CurrentLine()
textview.GoToLine(lineIndex)
textview.LineWidth(lineIndex)
textview.LineHeight(lineIndex)
textview.TextHeight(startLine, endLine)
textview.CanEndLine(offset)

An integer offset in bytes (not characters).

Locations

LineAt

PointAt

OffsetAt

These methods do what you expect.

Perl

$textview->LineAt($offset);
$textview->LineAtPoint($point);
$textview->PointAt($offset);
$textview->OffsetAt($line);
$textview->OffsetAtPoint($point);

Python

textview.LineAt(offset)
textview.LineAtPoint(point)
textview.PointAt(offset)
textview.OffsetAt(line)
textview.OffsetAtPoint(point)

Properties

IsStylable

SetStylable

TabWidth

SetTabWidth

IsSelectable

MakeSelectable

IsEditable

MakeEditable

DoesWordWrap

SetWordWrap

MaxBytes

SetMaxBytes

DisallowChar

AllowChar

Alignment

SetAlignment

DoesAutoindent

SetAutoindent

ColorSpace

SetColorSpace

IsResizable

MakeResizable

DoesUndo

SetDoesUndo

IsTypingHidden

HideTyping

These methods do what you expect. By default, a TextView:

Perl

$textview->IsStylable();
$textview->SetStylable($stylable);
$textview->TabWidth();
$textview->SetTabWidth($width);
$textview->IsSelectable();
$textview->MakeSelectable($selectable);
$textview->IsEditable();
$textview->MakeEditable($editable);
$textview->DoesWordWrap();
$textview->SetWordWrap($wrap);
$textview->MaxBytes();
$textview->SetMaxBytes($max);
$textview->Alignment();
$textview->SetAlignment($flag);
$textview->DoesAutoindent();
$textview->SetAutoindent($state);
$textview->ColorSpace();
$textview->SetColorSpace($colors);
$textview->IsResizable();
$textview->MakeResizable($resize, $resizeView);
$textview->DoesUndo();
$textview->SetDoesUndo($undo);
$textview->IsTypingHidden();
$textview->HideTyping($enabled);

Python

textview.IsStylable()
textview.SetStylable(stylable)
textview.TabWidth()
textview.SetTabWidth(width)
textview.IsSelectable()
textview.MakeSelectable(selectable)
textview.IsEditable()
textview.MakeEditable(editable)
textview.DoesWordWrap()
textview.SetWordWrap(wrap)
textview.MaxBytes()
textview.SetMaxBytes(max)
textview.Alignment()
textview.SetAlignment(alignment)
textview.DoesAutoindent()
textview.SetAutoindent(state)
textview.ColorSpace()
textview.SetColorSpace(colors)
textview.IsResizable()
textview.MakeResizable(resize, resizeView)
textview.DoesUndo()
textview.SetDoesUndo(undo)
textview.IsTypingHidden()
textview.HideTyping(enabled)

Scrolling

ScrollToSelection

ScrollToOffset

These methods do what you expect.

Perl

$textview->ScrollToSelection();
$textview->ScrollToOffset($offset);

Python

textview.ScrollToSelection()
textview.ScrollToOffset(offset)

Select

SelectAll

GetSelection

Highlight

Thse functions do what you expect. Select can also be called as a hook.

Perl

$textview->Select($startOffset, $endOffset);
$textview->SelectAll();
$textview->GetSelection();
$textview->Highlight($startOffset, $endOffset);

Python

textview.Select(startOffset, endOffset)
textview.SelectAll()
textview.GetSelection()
textview.Highlight(startOffset, endOffset)

Styles

GetFontAndColor

SetFontAndColor

RunArray

SetRunArray

FlattenRunArray

UnflattenRunArray

Set the styles, either via passing a font and color or by passing a list of styles.

Perl

$textview->GetFontAndColor($offset);
$textview->SetFontAndColor($start, $end, $font, $mode, $color);
$textview->SetFontAndColor($font, $mode, $color);
$textview->SetRunArray($start, $end, $runs);
$textview->FlattenRunArray($inArray);
$textview->UnflattenRunArray($data);

Python

textview.GetFontAndColor(offset)
textview.SetFontAndColor(start, end, font, mode, color)
textview.SetFontAndColor(font, mode, color)
textview.SetRunArray(start, end, runs)
textview.FlattenRunArray(runs)
textview.UnflattenRunArray(data)

Text

GetText

ByteAt

TextLength

SetText

Insert

Delete

These functions do what you expect. Text and SetText operate on the entire text of the TextView; the others specify portions of text.

Perl

$textview->Text();
$textview->GetText($offset, $length);
$textview->ByteAt($offset);
$textview->TextLength();
$textview->SetText(
    text => $text,
    runs => $runs,
);
$textview->SetText(
    file => $file,
    runs => $runs,
);
$textview->SetText(
    filename => $filename,
    offset   => $offset,
    length   => $length,
    runs     => $runs,
);
$textview->Insert($offset, $text, $runs);
$textview->Insert($text, $runs);
$textview->Delete($startOffset, $endOffset);
$textview->Delete();
$textview->DisallowChar($char);
$textview->AllowChar($char);

Python

textview.Text()
textview.GetText(offset, length)
textview.ByteAt(offset)
textview.TextLength()
textview.SetText(
    text = text,
    runs = runs,
)
textview.SetText(
    file = file,
    runs = runs,
)
textview.SetText(
    filename = filename,
    offset   = offset,
    length   = length,
    runs     = runs,
)
textview.Insert(offset, text, runs)
textview.Insert(text, runs)
textview.Delete(startOffset, endOffset)
textview.Delete()
textview.DisallowChar(char)
textview.AllowChar(char)

TextRect

SetTextRect

GetTextRegion

These functions do what you expect.

Perl

$textview->TextRect();
$textview->SetTextRect($rect);
$textview->GetTextRegion($startOffset, $endOffset);

Python

textview.TextRect()
textview.SetTextRect(rect)
textview.GetTextRegion(startOffset, endOffset)

HOOKS

AcceptsPaste

This is called when text is pasted into the TextView. Return true to allow, false to disallow.

(Currently, this hook is not called by the system.)

Perl

$textview->AcceptsPaste($clipboard);

Python

textview.AcceptsPaste(clipboard)

AcceptsDrop

This is called when something is dropped into the TextView. Return true to allow, false to disallow.

Perl

$textview->AcceptsDrop($archive);

Python

textview.AcceptsDrop(archive)

DeleteText

Caled when text is deleted. You should call the base class version to do the actual deletion.

Perl

$textview->DeleteText($fromOffset, $toOffset);

Python

textview.DeleteText(fromOffset, toOffset)

GetDragParameters

Called when the TextView is about to be dragged. You should return three things: a Bitmap, a Point, and a Handler. These will be passed to View.DragMessage.

Perl

$textview->GetDragParameters();

Python

textview.GetDragParameters()

InsertText

Called when text is inserted. You should call the base class version to do the actual insertion.

Perl

$textview->InsertText($text, $offset, $runs);

Python

textview.InsertText(text, offset, runs)

CONSTANTS

undo_state

Perl

use HaikuR1::TextView qw(:undo_state)

Python

Python does not support export tags.

SCRIPTING SUITE

The name of TextView's scripting suite is suite/vnd.Be-text-view.

TextView also inherits the following suites: