• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
katetextline.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2001-2003 Christoph Cullmann <cullmann@kde.org>
3  Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
4 
5  Based on:
6  KateTextLine : Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License version 2 as published by the Free Software Foundation.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #ifndef __KATE_TEXTLINE_H__
24 #define __KATE_TEXTLINE_H__
25 
26 #include <ksharedptr.h>
27 
28 #include <tqmemarray.h>
29 #include <tqstring.h>
30 
31 class KateRenderer;
32 class TQTextStream;
33 
41 class KateTextLine : public TDEShared
42 {
43  public:
47  typedef TDESharedPtr<KateTextLine> Ptr;
48 
49  public:
53  enum Flags
54  {
55  flagNoOtherData = 1, // ONLY INTERNAL USE, NEVER EVER SET THAT !!!!
56  flagHlContinue = 2,
57  flagAutoWrapped = 4,
58  flagFoldingColumnsOutdated = 8,
59  flagNoIndentationBasedFolding = 16,
60  flagNoIndentationBasedFoldingAtStart = 32
61  };
62 
63  public:
69  KateTextLine ();
70 
74  ~KateTextLine ();
75 
79  public:
83  inline void setFoldingColumnsOutdated(bool set) { if (set) m_flags |= KateTextLine::flagFoldingColumnsOutdated; else m_flags&=
84  (~KateTextLine::flagFoldingColumnsOutdated);}
85 
90  inline bool foldingColumnsOutdated() { return m_flags & KateTextLine::flagFoldingColumnsOutdated; }
91 
92 
97  inline uint length() const { return m_text.length(); }
98 
103  inline bool hlLineContinue () const { return m_flags & KateTextLine::flagHlContinue; }
104 
109  inline bool isAutoWrapped () const { return m_flags & KateTextLine::flagAutoWrapped; }
110 
115  int firstChar() const;
116 
121  int lastChar() const;
122 
129  int nextNonSpaceChar(uint pos) const;
130 
137  int previousNonSpaceChar(uint pos) const;
138 
145  inline TQChar getChar (uint pos) const { return m_text[pos]; }
146 
151  inline const TQChar *text() const { return m_text.unicode(); }
152 
167  inline uchar *attributes () const { return m_attributes.data(); }
168 
173  inline const TQString& string() const { return m_text; }
174 
181  inline TQString string(uint startCol, uint length) const
182  { return m_text.mid(startCol, length); }
183 
188  const TQChar *firstNonSpace() const;
189 
195  uint indentDepth (uint tabwidth) const;
196 
204  int cursorX(uint pos, uint tabChars) const;
205 
211  uint lengthWithTabs (uint tabChars) const;
212 
219  bool stringAtPos(uint pos, const TQString& match) const;
220 
226  bool startingWith(const TQString& match) const;
227 
233  bool endingWith(const TQString& match) const;
234 
245  bool searchText (uint startCol, const TQString &text,
246  uint *foundAtCol, uint *matchLen,
247  bool casesensitive = true,
248  bool backwards = false);
249 
259  bool searchText (uint startCol, const TQRegExp &regexp,
260  uint *foundAtCol, uint *matchLen,
261  bool backwards = false);
262 
271  inline uchar attribute (uint pos) const
272  {
273  if (pos < m_attributes.size()) return m_attributes[pos];
274  return 0;
275  }
276 
281  inline const TQMemArray<short> &ctxArray () const { return m_ctx; };
282 
286  inline const bool noIndentBasedFolding() const { return m_flags & KateTextLine::flagNoIndentationBasedFolding; };
287  inline const bool noIndentBasedFoldingAtStart() const { return m_flags & KateTextLine::flagNoIndentationBasedFoldingAtStart; };
292  inline const TQMemArray<uint> &foldingListArray () const { return m_foldingList; };
293 
298  inline const TQMemArray<unsigned short> &indentationDepthArray () const { return m_indentationDepth; };
299 
307  void insertText (uint pos, uint insLen, const TQChar *insText, uchar *insAttribs = 0);
308 
314  void removeText (uint pos, uint delLen);
315 
320  void truncate(uint newLen);
321 
326  inline void setHlLineContinue (bool cont)
327  {
328  if (cont) m_flags = m_flags | KateTextLine::flagHlContinue;
329  else m_flags = m_flags & ~ KateTextLine::flagHlContinue;
330  }
331 
336  inline void setAutoWrapped (bool wrapped)
337  {
338  if (wrapped) m_flags = m_flags | KateTextLine::flagAutoWrapped;
339  else m_flags = m_flags & ~ KateTextLine::flagAutoWrapped;
340  }
341 
346  inline void setContext (TQMemArray<short> &val) { m_ctx.assign (val); }
347 
351  inline void setNoIndentBasedFolding(bool val)
352  {
353  if (val) m_flags = m_flags | KateTextLine::flagNoIndentationBasedFolding;
354  else m_flags = m_flags & ~ KateTextLine::flagNoIndentationBasedFolding;
355  }
356 
357  inline void setNoIndentBasedFoldingAtStart(bool val)
358  {
359  if (val) m_flags = m_flags | KateTextLine::flagNoIndentationBasedFoldingAtStart;
360  else m_flags = m_flags & ~ KateTextLine::flagNoIndentationBasedFoldingAtStart;
361  }
362 
367  inline void setFoldingList (TQMemArray<uint> &val) { m_foldingList.assign (val); m_foldingList.detach(); }
368 
373  inline void setIndentationDepth (TQMemArray<unsigned short> &val) { m_indentationDepth.assign (val); }
374 
378  public:
384  inline uint dumpSize (bool withHighlighting) const
385  {
386  return ( 1
387  + sizeof(uint)
388  + (m_text.length() * sizeof(TQChar))
389  + ( withHighlighting ?
390  ( (3 * sizeof(uint))
391  + (m_text.length() * sizeof(uchar))
392  + (m_ctx.size() * sizeof(short))
393  + (m_foldingList.size() * sizeof(uint))
394  + (m_indentationDepth.size() * sizeof(unsigned short))
395  ) : 0
396  )
397  );
398  }
399 
407  char *dump (char *buf, bool withHighlighting) const;
408 
415  char *restore (char *buf);
416 
420  private:
424  TQString m_text;
425 
431  TQMemArray<uchar> m_attributes;
432 
436  TQMemArray<short> m_ctx;
437 
441  TQMemArray<uint> m_foldingList;
442 
446  TQMemArray<unsigned short> m_indentationDepth;
447 
451  uchar m_flags;
452 };
453 
454 #endif
KateTextLine::cursorX
int cursorX(uint pos, uint tabChars) const
Returns the x position of the cursor at the given position, which depends on the number of tab charac...
Definition: katetextline.cpp:237
KateTextLine::hlLineContinue
bool hlLineContinue() const
has the line the hl continue flag set
Definition: katetextline.h:103
KateTextLine::endingWith
bool endingWith(const TQString &match) const
Is the line ending with the given string.
Definition: katetextline.cpp:219
KateTextLine::Ptr
TDESharedPtr< KateTextLine > Ptr
Define a Shared-Pointer type.
Definition: katetextline.h:47
KateTextLine::ctxArray
const TQMemArray< short > & ctxArray() const
context stack
Definition: katetextline.h:281
KateTextLine::text
const TQChar * text() const
Gets the text as a unicode representation.
Definition: katetextline.h:151
KateTextLine::getChar
TQChar getChar(uint pos) const
Gets the char at the given position.
Definition: katetextline.h:145
KateTextLine::dump
char * dump(char *buf, bool withHighlighting) const
Dumps the line to *buf and counts buff dumpSize bytes up as return value.
Definition: katetextline.cpp:335
KateTextLine::searchText
bool searchText(uint startCol, const TQString &text, uint *foundAtCol, uint *matchLen, bool casesensitive=true, bool backwards=false)
search given string
Definition: katetextline.cpp:273
KateTextLine::indentationDepthArray
const TQMemArray< unsigned short > & indentationDepthArray() const
indentation stack
Definition: katetextline.h:298
KateTextLine::setNoIndentBasedFolding
void setNoIndentBasedFolding(bool val)
sets if for the next line indent based folding should be disabled
Definition: katetextline.h:351
KateTextLine::length
uint length() const
Returns the length.
Definition: katetextline.h:97
KateTextLine::lengthWithTabs
uint lengthWithTabs(uint tabChars) const
Returns the text length with tabs calced in.
Definition: katetextline.cpp:256
KateTextLine::removeText
void removeText(uint pos, uint delLen)
remove text at given position
Definition: katetextline.cpp:76
KateTextLine::setFoldingColumnsOutdated
void setFoldingColumnsOutdated(bool set)
Methods to get data.
Definition: katetextline.h:83
KateTextLine::setFoldingList
void setFoldingList(TQMemArray< uint > &val)
update folding list
Definition: katetextline.h:367
KateTextLine::setAutoWrapped
void setAutoWrapped(bool wrapped)
auto-wrapped
Definition: katetextline.h:336
KateTextLine::restore
char * restore(char *buf)
Restores the line from *buf and counts buff dumpSize bytes up as return value.
Definition: katetextline.cpp:383
KateTextLine::nextNonSpaceChar
int nextNonSpaceChar(uint pos) const
Find the position of the next char that is not a space.
Definition: katetextline.cpp:110
KateRenderer
Handles all of the work of rendering the text (used for the views and printing)
Definition: katerenderer.h:42
KateTextLine::insertText
void insertText(uint pos, uint insLen, const TQChar *insText, uchar *insAttribs=0)
insert text into line
Definition: katetextline.cpp:39
KateTextLine::lastChar
int lastChar() const
Returns the position of the last non-whitespace character.
Definition: katetextline.cpp:147
KateTextLine::string
TQString string(uint startCol, uint length) const
Gets a substring.
Definition: katetextline.h:181
KateTextLine::previousNonSpaceChar
int previousNonSpaceChar(uint pos) const
Find the position of the previous char that is not a space.
Definition: katetextline.cpp:124
TDEShared
KateTextLine::firstNonSpace
const TQChar * firstNonSpace() const
Gets a null terminated pointer to first non space char.
Definition: katetextline.cpp:152
KateTextLine::setIndentationDepth
void setIndentationDepth(TQMemArray< unsigned short > &val)
update indentation stack
Definition: katetextline.h:373
KateTextLine::isAutoWrapped
bool isAutoWrapped() const
was this line automagically wrapped
Definition: katetextline.h:109
KateTextLine::KateTextLine
KateTextLine()
Constructor Creates an empty text line with given attribute and syntax highlight context.
Definition: katetextline.cpp:30
KateTextLine::string
const TQString & string() const
Gets a QString.
Definition: katetextline.h:173
KateTextLine::attribute
uchar attribute(uint pos) const
Gets the attribute at the given position use KRenderer::attributes to get the KTextAttribute for this...
Definition: katetextline.h:271
KateTextLine::setContext
void setContext(TQMemArray< short > &val)
Sets the syntax highlight context number.
Definition: katetextline.h:346
KateTextLine::foldingColumnsOutdated
bool foldingColumnsOutdated()
folding columns outdated ?
Definition: katetextline.h:90
KateTextLine::Flags
Flags
Used Flags.
Definition: katetextline.h:53
KateTextLine::noIndentBasedFolding
const bool noIndentBasedFolding() const
Definition: katetextline.h:286
KateTextLine::stringAtPos
bool stringAtPos(uint pos, const TQString &match) const
Can we find the given string at the given position.
Definition: katetextline.cpp:180
KateTextLine::startingWith
bool startingWith(const TQString &match) const
Is the line starting with the given string.
Definition: katetextline.cpp:202
KateTextLine::setHlLineContinue
void setHlLineContinue(bool cont)
set hl continue flag
Definition: katetextline.h:326
KateTextLine::attributes
uchar * attributes() const
Highlighting array The size of this is string().length()
Definition: katetextline.h:167
KateTextLine::foldingListArray
const TQMemArray< uint > & foldingListArray() const
folding list
Definition: katetextline.h:292
KateTextLine
The KateTextLine represents a line of text.
Definition: katetextline.h:41
KateTextLine::firstChar
int firstChar() const
Returns the position of the first non-whitespace character.
Definition: katetextline.cpp:142
KateTextLine::dumpSize
uint dumpSize(bool withHighlighting) const
Methodes for dump/restore of the line in the buffer.
Definition: katetextline.h:384
TDESharedPtr
KateTextLine::~KateTextLine
~KateTextLine()
Destructor.
Definition: katetextline.cpp:35
KateTextLine::truncate
void truncate(uint newLen)
Truncates the textline to the new length.
Definition: katetextline.cpp:101
KateTextLine::indentDepth
uint indentDepth(uint tabwidth) const
indentation depth of this line
Definition: katetextline.cpp:158

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.8.8
This website is maintained by Timothy Pearson.