ReactOS 0.4.16-dev-847-g386fccd
row.c
Go to the documentation of this file.
1/*
2 * RichEdit - Operations on rows of text (rows are recreated during
3 * wrapping and are used for displaying the document, they don't keep any
4 * true document content; delete all rows, rewrap all paragraphs and
5 * you get them back).
6 *
7 * Copyright 2004 by Krzysztof Foltman
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
25#include "editor.h"
26
28{
30
32 if (!item || item->type != diStartRow) return NULL;
33 return &item->member.row;
34}
35
37{
39
41 if (!item) return NULL;
42 return &item->member.row;
43}
44
46{
48
50 if (!item) return NULL;
51 return &item->member.row;
52}
53
55{
57
59 assert( item->type == diRun );
60 return &item->member.run;
61}
62
64{
66
68
70 if (!item || item->type == diStartRow) return NULL;
71 return &item->member.run;
72}
73
75{
77
79 return &item->member.row;
80}
81
83{
85
87 cursor->run = &item->member.run;
88 cursor->para = cursor->run->para;
89 cursor->nOffset = 0;
90}
91
93{
94 ME_DisplayItem *item, *run;
95
97 run = ME_FindItemBack( item, diRun );
98 cursor->run = &run->member.run;
99 cursor->para = cursor->run->para;
100 cursor->nOffset = (item->type == diStartRow || include_eop) ? cursor->run->len : 0;
101}
102
104{
106
108 return cursor.para;
109}
110
112{
113 ME_Paragraph *para = editor_first_para( editor );
114 ME_Row *row;
115 int count = 0;
116
117 while (para_next( para ) && count + para->nRows <= row_num)
118 {
119 count += para->nRows;
120 para = para_next( para );
121 }
122 if (!para_next( para )) return NULL;
123
124 for (row = para_first_row( para ); row && count < row_num; count++)
125 row = row_next( row );
126
127 return row;
128}
129
130
132{
133 ME_Paragraph *para = editor_first_para( editor );
134 ME_Row *row;
136 int row_num = 0;
137
138 while (para_next( para ) && para_next( para )->nCharOfs <= ofs)
139 {
140 row_num += para->nRows;
141 para = para_next( para );
142 }
143
144 if (para_next( para ))
145 {
146 for (row = para_first_row( para ); row; row = row_next( row ))
147 {
149 if (ME_GetCursorOfs( &cursor ) > ofs ) break;
150 row_num++;
151 }
152 }
153
154 return row_num;
155}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
int ME_GetCursorOfs(const ME_Cursor *cursor)
Definition: caret.c:889
ME_Paragraph * editor_first_para(ME_TextEditor *editor)
Definition: editor.c:279
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
#define assert(x)
Definition: debug.h:53
ME_Row * para_first_row(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:132
ME_DisplayItem * ME_FindItemBack(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
Definition: list.c:66
ME_Paragraph * para_next(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:57
static ME_DisplayItem * run_get_di(ME_Run *run)
Definition: editor.h:163
static ME_DisplayItem * row_get_di(ME_Row *row)
Definition: editor.h:126
ME_DisplayItem * ME_FindItemFwd(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
Definition: list.c:89
@ diStartRow
Definition: editstr.h:87
@ diRun
Definition: editstr.h:86
@ diStartRowOrParagraphOrEnd
Definition: editstr.h:92
@ diRunOrStartRow
Definition: editstr.h:94
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei count
Definition: gl.h:1545
const char cursor[]
Definition: icontest.c:13
static ATOM item
Definition: dde.c:856
ME_Row * row_from_cursor(ME_Cursor *cursor)
Definition: row.c:74
int row_number_from_char_ofs(ME_TextEditor *editor, int ofs)
Definition: row.c:131
ME_Paragraph * row_para(ME_Row *row)
Definition: row.c:103
void row_first_cursor(ME_Row *row, ME_Cursor *cursor)
Definition: row.c:82
ME_Run * row_first_run(ME_Row *row)
Definition: row.c:54
ME_Row * row_prev_all_paras(ME_Row *row)
Definition: row.c:45
void row_end_cursor(ME_Row *row, ME_Cursor *cursor, BOOL include_eop)
Definition: row.c:92
ME_Run * row_next_run(ME_Row *row, ME_Run *run)
Definition: row.c:63
ME_Row * row_next_all_paras(ME_Row *row)
Definition: row.c:36
ME_Row * row_next(ME_Row *row)
Definition: row.c:27
ME_Row * row_from_row_number(ME_TextEditor *editor, int row_num)
Definition: row.c:111
union tagME_DisplayItem::@555 member