Home » U++ Library support » RichText,QTF,RTF... » Insert text data from file
Insert text data from file [message #40916] |
Mon, 07 October 2013 18:49  |
iST1
Messages: 107 Registered: August 2013
|
Experienced Member |
|
|
I'm trying to load txt file with transform base code LoadImage, but occured 2 problem:
1) it seems that QTF doesn't work with RichPara, but i use it for create new line (&);
2) rus code page
File:
line 1
line 2
line 3
строка 4
строка 5
строка 6
=>
`[`& line 1`]`[`& line 2`]`[`& line 3`]`[`& 4`]`[`& 5`]`[`& 6`]
void RichEdit::LoadTxt()
{
FileSel fsel;
fsel.Type("Текстовые файлы ", "*.txt");
static String dir = fsel.GetActiveDir();
fsel.ActiveDir(dir);
if(fsel.ExecuteOpen(t_("Выберите текстовый файл для вставки"))) {
dir = fsel.GetActiveDir();
FileIn fi;
if(!fi.Open(~fsel)) {
Exclamation(NFormat(t_("Ошибка открытия файла [* \1%s\1]."), ~fsel));
return;
}
RichPara para;
RichPara::CharFormat fmt;
while (!fi.IsEof()) {
para.Cat(DeQtf("[& " + fi.GetLine() + "]"), fmt);
}
RichText clip;
clip.Cat(para);
RemoveSelection();
Insert(GetCursor(), clip, false);
Finish();
}
}
|
|
|
Re: Insert text data from file [message #40926 is a reply to message #40916] |
Tue, 08 October 2013 20:04   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
iST1 wrote on Mon, 07 October 2013 12:49 | I'm trying to load txt file with transform base code LoadImage, but occured 2 problem:
1) it seems that QTF doesn't work with RichPara, but i use it for create new line (&);
|
RichPara represents a 'line' (in fact, a paragraph, but I guess in this context you mean that). Therefore, if you want more paragraphs, you need to Cat them...
RichText clip;
while (!fi.IsEof()) {
RichPara para;
RichPara::CharFormat fmt;
para.Cat(fi.GetLine()), fmt);
clip.Cat(para);
}
}
(Alternatively, there not much wrong creating the whole clip in Qtf, not using RichPara).
Mirek
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 12:15:14 CEST 2025
Total time taken to generate the page: 0.00863 seconds
|