This file is indexed.

/usr/include/cwidget/widgets/text_layout.h is in libcwidget-dev 0.5.16-3.5ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// text_layout.h                     -*-c++-*-
//
//   Copyright (C) 2004-2005, 2007 Daniel Burrows
//
//   This program is free software; you can redistribute it and/or
//   modify it under the terms of the GNU General Public License as
//   published by the Free Software Foundation; either version 2 of
//   the License, or (at your option) any later version.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//   General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; see the file COPYING.  If not, write to
//   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
//   Boston, MA 02111-1307, USA.


#ifndef TEXT_LAYOUT_H
#define TEXT_LAYOUT_H

#include "widget.h"
#include <cwidget/fragment_contents.h>

namespace cwidget
{
  class fragment;

  namespace widgets
  {
    /** Code to display formatted text.
     *
     *  The text to display is composed of a tree of "fragments".  A
     *  fragment stores some amount of text; at any time, it can be
     *  formatted to a particular width.  The main layout mechanisms
     *  provided are flowboxes and clipboxes: flowboxes word-wrap their
     *  contents to a particular width, while clipboxes clip their
     *  contents to a particular width.  These boxes can be nested, if the
     *  user feels like it for some reason or other, although some
     *  nestings are non-sensical (for instance, placing a flowbox inside
     *  a smaller flowbox is likely to lead to really ugly text).
     *
     *  This provides some primitive layout mechanisms; higher-level
     *  layouts can be expressed in terms of these.
     */
    class text_layout : public widget
    {
    protected:
      text_layout();
      text_layout(fragment *f);
    public:
      /** Create an empty text_layout. */
      static util::ref_ptr<text_layout> create()
      {
	util::ref_ptr<text_layout> rval(new text_layout);
	rval->decref();
	return rval;
      }

      /** Create a text_layout with the given root fragment.
       *
       *  All fragments are implicitly placed within a clipbox of width
       *  equal to the width of this widget.
       */
      static util::ref_ptr<text_layout> create(fragment *f)
      {
	util::ref_ptr<text_layout> rval(new text_layout(f));
	rval->decref();
	return rval;
      }

      /** Handle the given keypress.  Returns \b true if the keystroke
       *  was "consumed" by this widget.
       */
      bool handle_key(const config::key &k);

      void dispatch_mouse(short id, int x, int y, int z, mmask_t bstate);

      /** Change the fragment being displayed in this layout widget. */
      void set_fragment(fragment *f);

      /** Append the given fragment to the current fragment.
       *
       *  \note this is slightly less efficient than placing the two
       *  fragments into the text_layout up-front via a single
       *  sequence_fragment.  Normally this isn't a problem, but if you
       *  want to append hundreds of fragments this way, it might be.
       *
       *  \todo this is only needed for memory-management reasons
       *  (otherwise I could safely extract the current fragment and
       *  create my own sequence).  Would refcounting help?
       *
       *  \todo if this becomes very useful, it would be better to just
       *  explicitly store a sequence of fragments in the layout.
       */
      void append_fragment(fragment *f);

      /** Return the requested width of this widget.  The requested width
       *  will be the largest possible width of any line.
       */
      int width_request();

      /** Return the requested height of this widget given its width, by
       *  running the fragment-layout algorithm.
       */
      int height_request(int w);

      /** Return \b true iff the cursor is visible in this widget. */
      bool get_cursorvisible();

      /** Return the location of the cursor in this widget. */
      point get_cursorloc();

      /** Return \b true iff this widget should be given focus. */
      bool focus_me();

      /** Paint this widget. */
      void paint(const style &st);

      /** Move the view one line down. */
      void line_down();

      /** Move the view one line up. */
      void line_up();

      /** Move the view to the top of the widget. */
      void move_to_top();

      /** Move the view to the bottom of the widget. */
      void move_to_bottom();

      /** Move a page forward. */
      void page_down();

      /** Move a page back. */
      void page_up();

      /** Search either forwards or backwards for the string s.  The
       *  search will start on either the next or the previous line
       *  from the top of the screen.
       */
      void search_for(const std::wstring &s,
		      bool search_forwards);

      /** Page based on a scrollbar signal.
       *
       *  \param dir the direction to page: if \b true, call page_up();
       *       else call page_down().
       */
      void scroll(bool dir);

      /** Delete the root fragment. */
      ~text_layout();

      /** A signal that is called whenever the "location" of the view
       *  within the text changes.
       */
      sigc::signal2<void, int, int> location_changed;

      static config::keybindings *bindings;

      static void init_bindings();
    private:
      /** Move the starting location of the widget. */
      void set_start(unsigned int new_start);

      /** Update the cached contents of the widget, if necessary. */
      void freshen_contents(const style &st);

      /** Called when this needs layout. */
      void layout_me();

      /** Emits the above signal based on the present location of the display. */
      void do_signal();

      /** The line which is currently at the top of the widget. */
      size_t start;

      /** The root fragment of this layout.  This is always a clipbox. */
      fragment *f;

      /** Cache the current contents of the widget. */
      fragment_contents contents;

      /** If \b true, the current cached contents need to be updated. */
      bool stale;

      /** The width of the widget the last time we updated the cached contents. */
      int lastw;

      /** The enclosing display style the last time we updated the cached contents. */
      style lastst;
    };

    typedef util::ref_ptr<text_layout> text_layout_ref;
  }
}

#endif