Display file content in Edwin

Login to reply to this topic.
Sun, 2006-05-14 14:56
Joined: 2006-04-01
Forum posts: 28
Hello every body

       These days I was programming an app to display the file content in Edwin, I met a problem that the content displayed in ONE line.(The Edwin ignores the carriage return)

        I have searched the a lot of posts, but can't find a complete explanation to solve this problem. I think there are many newbie like me may meet this problem, so I hope somebody who knows the solving method to tell us and give an example.

        Thanks zillions for your reply!

Sun, 2006-05-14 15:46
Joined: 2005-11-20
Forum posts: 1156
Re: Display file content in Edwin
I think the easiest way to get nearer to the source of the problem is you posting the part of your code where you create and configure the EdWin (if you create it yourself) or the part of your rss file (if the EdWin is defined there, e.g. as part of a dialog).

René Brunner

Mon, 2006-05-15 02:38
Joined: 2006-04-01
Forum posts: 28
Re: Display file content in Edwin
Thanks rbrunner:

    I create this app based on the example PlainTextEditor This is my code which adds to the PlainTextEditor:

first,I use WriteFile() to generate the file I want to display in the Edwin
Code:
void CPlainTextEditorContainer::WriteFile()
{
//for test
_LIT(KMyFile,"C:\\test.txt");
RFs ifs;
RFile iFile;
User::LeaveIfError(ifs.Connect());
TInt err = iFile.Open(ifs,KMyFile,EFileShareAny|EFileWrite);
if (err==KErrNotFound) // file does not exist - create it
                {
          iFile.Create(ifs,KMyFile,EFileShareAny|EFileWrite|EFileRead);
                }
TBufC8<256> buf = _L8("C:\\C1.txt\r\nC:\\C2.txt\r\nC:\\3.txt\r\nC:\\C4.txt\r\nC:\\C5.txt\r\nC:\\C6.txt\r\nC:\\C7.txt\r\nC:\\C8.txt\r\nC:\\C9.txt\r\nC:\\C10.txt");
iFile.Write(buf);
iEikonEnv->InfoMsg(_L("Writing Success!"));

// Close the connection
iFile.Close();
ifs.Close();
}

Then, I modify the code in the ConstructL()
Code:
void CPlainTextEditorContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();

iEditor = new (ELeave) CEikEdwin;
iEditor->SetContainerWindowL(*this);
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, R_PLAINTEXTEDITOR_URLEDITOR);
iEditor->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(); // reader
iEditor->SetFocus(ETrue);

SetRect(aRect);
const CPlainText::TTextOrganisation aTextOrganisation = CPlainText::EOrganiseByLine;//EOrganiseByParagraph

TFileName filename(KFilePath);
iEditor->InsertFromTextFileL(filename,aTextOrganisation);
ActivateL();
}
I have known that the EDWIN ignores the carriage return under the direction of desdemona ,so I use InsertFromTextFileL() to add the content to the EDWIN. Unfortunately, I can't get the result I want, the contents of file also display in ONE line.

    I think many newbies as me can be stuck by the problem. Thanks for the help of experts.
Mon, 2006-05-15 06:06
Joined: 2005-11-20
Forum posts: 1156
Re: Display file content in Edwin
Well, I don't really know, but the 2 things that I would now try first as "shots in the dark" are:

a) use EOrganiseByParagraph instead of EOrganiseByLine because from the SDK documentation I got the impression that you need this one here because you generate your line ends as CR/LF

b) write a UNICODE text file instead of an ASCII file and see what happens

and then, finally, if it still does not work,

c) create a scroll bar frame for the edwin, with CreateScrollBarFrameL(); maybe it only starts to use lines when it has the "freedom" to scroll if necessary...

René Brunner

Mon, 2006-05-15 07:29
Joined: 2006-01-09
Forum posts: 105
Re: Display file content in Edwin
Hi...

try this code snippet ..

const TFileName file(KHelpFilePath);
iEdwin->InsertFromTextFileL(file,CPlainText::EOrganiseByParagraph );

where iEdwin is object of CEikRichTextEditor class...


Cheers !!
CodePupil




Thanks and Regards
CodePupil
__________________________
You are I and I am he .. !!

Mon, 2006-05-15 08:06
Joined: 2005-11-20
Forum posts: 1156
Re: Display file content in Edwin
... and maybe it would be a good idea to take a step back from this whole EdWin story and think about the task at hand.

Is the task at hand to show the user a list of file names? If yes, maybe use a listbox, the right user interface element in Symbian for this job?

If the task at hand is to allow the user to manage a list of files, maybe use a combination of a listbox to show the current list, a simple one-line EdWin for entering new names, and two functions "Add Name" and "Delete Name"?

This way we may still not know how to display text with line breaks in an EdWin, but this would not matter because other controls are used.

René Brunner

Mon, 2006-05-15 11:25
Joined: 2006-04-01
Forum posts: 28
Re: Display file content in Edwin
Hi kind-hearted buddies:

    I have tried to modify my app according your direction, but the problem is still here.

First, I changed EOrganiseByLine to EOrganiseByParagraph. The contents displayed overlapped, i.e. there are only C:\C1.txt in the screen, and if I click the right arrow, the next content C:\C2.txt appeared when I move the cursor in the end of "C:\C1.txt", and so on.

Second, my app is not related to listbox. It likes a E-book Reader to read the .txt files. So I can't use other UI component to evade this problem.
Thu, 2006-05-18 13:50
Joined: 2006-04-01
Forum posts: 28
Re: Display file content in Edwin
Hello everybody:

    My problem has been solved according what did desdemona  tell.
I am so silly that can not find a mistake in the rss file.
Code:
#define KUrlWidth 176
#define KUrlNumberLines 1  <----------------------Here
#define KMaxUrlLength 256

// ---------------------------------------------------------
//   
//    URL editor for the application
//
// ---------------------------------------------------------
//
RESOURCE EDWIN r_plaintexteditor_urleditor
{
width = KUrlWidth;
lines = KUrlNumberLines;
maxlength = KMaxUrlLength;
flags = EEikEdwinWidthInPixels | EEikEdwinReadOnly;
avkon_flags = EAknEditorFlagNoT9 | EAknEditorFlagEnableScrollBars;
default_case = EAknEditorLowerCase;
allowed_case_modes = EAknEditorUpperCase | EAknEditorLowerCase;
numeric_keymap = EAknEditorPlainNumberModeKeymap;
allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode;
default_input_mode = EAknEditorTextInputMode;
special_character_table = R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG;

}
The KUrlNumberLines was defined by 1, namely the text editor can only display ONE line.
I am ashamed to trouble you who spent so much time to help me. Hope the post can help many newbies like me.

This is my correct code snippet
Code:
void CPlainTextEditorContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();

iEditor = new (ELeave) CEikEdwin;
iEditor->SetContainerWindowL(*this);
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, R_PLAINTEXTEDITOR_URLEDITOR);
iEditor->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(); // reader
iEditor->SetFocus(ETrue);
iEditor->CreateScrollBarFrameL();

SetRect(aRect);
const CPlainText::TTextOrganisation aTextOrganisation = CPlainText::EOrganiseByParagraph;//EOrganiseByLine

TFileName filename(KFilePath);
iEditor->InsertFromTextFileL(filename,aTextOrganisation);
ActivateL();
iEditor->SetCursorPosL(0, EFalse);
}

Good luck everyone!
  • Login to reply to this topic.