Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenrow.c
Go to the documentation of this file.
00001 /* 00002 * RichEdit - Operations on rows of text (rows are recreated during 00003 * wrapping and are used for displaying the document, they don't keep any 00004 * true document content; delete all rows, rewrap all paragraphs and 00005 * you get them back). 00006 * 00007 * Copyright 2004 by Krzysztof Foltman 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00022 */ 00023 00024 00025 #include "editor.h" 00026 00027 /* I'm sure these functions would simplify some code in caret ops etc, 00028 * I just didn't remember them when I wrote that code 00029 */ 00030 00031 ME_DisplayItem *ME_RowStart(ME_DisplayItem *item) { 00032 return ME_FindItemBackOrHere(item, diStartRow); 00033 } 00034 00035 /* 00036 ME_DisplayItem *ME_RowEnd(ME_DisplayItem *item) { 00037 ME_DisplayItem *item2 = ME_FindItemFwd(item, diStartRowOrParagraphOrEnd); 00038 if (!item2) return NULL; 00039 return ME_FindItemBack(item, diRun); 00040 } 00041 */ 00042 00043 ME_DisplayItem * 00044 ME_FindRowWithNumber(ME_TextEditor *editor, int nRow) 00045 { 00046 ME_DisplayItem *item = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph); 00047 int nCount = 0; 00048 00049 while (item->type == diParagraph && 00050 nCount + item->member.para.nRows <= nRow) 00051 { 00052 nCount += item->member.para.nRows; 00053 item = item->member.para.next_para; 00054 } 00055 if (item->type != diParagraph) 00056 return NULL; 00057 for (item = ME_FindItemFwd(item, diStartRow); item && nCount < nRow; nCount++) 00058 item = ME_FindItemFwd(item, diStartRow); 00059 return item; 00060 } 00061 00062 00063 int 00064 ME_RowNumberFromCharOfs(ME_TextEditor *editor, int nOfs) 00065 { 00066 ME_DisplayItem *item = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph); 00067 int nRow = 0; 00068 00069 while (item->type == diParagraph && 00070 item->member.para.next_para->member.para.nCharOfs <= nOfs) 00071 { 00072 nRow += item->member.para.nRows; 00073 item = item->member.para.next_para; 00074 } 00075 if (item->type == diParagraph) 00076 { 00077 ME_DisplayItem *next_para = item->member.para.next_para; 00078 00079 nOfs -= item->member.para.nCharOfs; 00080 item = ME_FindItemFwd(item, diRun); 00081 while ((item = ME_FindItemFwd(item, diStartRowOrParagraph)) != NULL) 00082 { 00083 if (item == next_para) 00084 break; 00085 item = ME_FindItemFwd(item, diRun); 00086 if (item->member.run.nCharOfs > nOfs) 00087 break; 00088 nRow++; 00089 } 00090 } 00091 return nRow; 00092 } Generated on Thu May 24 2012 04:26:28 for ReactOS by
1.7.6.1
|