Pelles C forum

C language => User contributions => Topic started by: tanel on June 28, 2013, 08:28:05 PM

Title: Simple Text Editor project
Post by: tanel on June 28, 2013, 08:28:05 PM
Removed the Version 1.0 since there is newer one.

original:
Simple Text Editor V1.0 is based on RichEdit 2.0.  The reason for this project is not to develop a text editor software. I'll integrate it  to another project. It is practical to develop and test a project in parts.

Currently, following basic functions were implemented: "File open, file save, file save as, file close, redo, undo, cut, copy, paste, find, find-replace." Some functions implemented differently although richedit has alternative (such as clipboard functions and stream in/out for file read/write).

I will add more functions in feature versions including print, font selection etc.

The project folder (ppj, c, h etc included) is attached. Comments, contribution and feedbacks are welcomed.
Title: Re: Simple Text Editor project
Post by: Bitbeisser on June 29, 2013, 01:46:02 AM
Thanks, nice little project that might come in handy for others...  :D

Ralf
Title: New Version of Simple Text Editor
Post by: tanel on July 03, 2013, 01:59:28 PM
New version of Simple Text Editor is attached (V1.1.a)

What changes are (as summary):

1. cleaned c, h and rc files and removed dead code. (also changed the structure)
2. Changed local cut-copy-paste functions to clipboard operations
3. Added New File, Print, Recent Files (last 10 files), Delete, Select All, Change case functions
4. Added a status bar that displays file name with path
5. Added a tool bar with New File, File Open, File Save, Cut, Copy, Paste, Undo, Redo, Find, Replace
6. Added menu seperators to Edit menu
7. Added more shortcuts (common)
8. Added context menu with Cut, Copy, Paste, Delete and Select All functions

Title: Re: Simple Text Editor project
Post by: czerny on July 03, 2013, 03:59:20 PM
It is not a good idea to add/change standard include files.
Title: Re: Simple Text Editor project
Post by: tanel on July 03, 2013, 05:00:21 PM
standard include files and libraries were not changed. if  you refer to "cleaned c, h and rc files" statement, changed files are
simpletexteditor.c
simpletexteditor.h
simpletexteditor.rc
Title: Re: Simple Text Editor project
Post by: TimoVJL on July 03, 2013, 05:39:56 PM
Better to use standard headers in normal way:
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <Commdlg.h>
#include <tchar.h>
#include <richedit.h>
#include <stdlib.h>
#include <strsafe.h>
#include <tgmath.h>
and why just not using __int64 or long long ?
Title: Re: Simple Text Editor project
Post by: jj2007 on July 03, 2013, 08:06:16 PM
Nice project :)

Minor glitches:
- Ctrl V pastes clipboard content twice.
- Opens RTF files in rich mode but saves plain text, i.e. formatting gets lost.

Pelles C says 3*unreachable code; 42,496 bytes without debug info is OK but could be condensed a bit (for comparison: TinyIDE is a 7.0 kBytes editor (http://masm32.com/board/index.php?topic=103.0))
Title: Re: Simple Text Editor project
Post by: tanel on July 03, 2013, 08:35:59 PM
Thanks for the feedbacks. It is interesting that ctrl v pastes content  twice but shift insert, toolbar icon, edit menu and context menu act as they supposed to.

Commented ctrl v assignment from the accelerator table of rc file, it works normally. I think ctrl v works twice. I'll look into it. I'll also look into rtf files format change.

Yes, 3 unreachable areas reported but looks no problem in operation. I'll to try to find out reason.

Note to timovjl:

I use MS Visual Studio, just started Pelle's C. And compiler states that _int64 is undefined. It is my preference to stay with _int64 rather than using long long.
Title: Re: Simple Text Editor project
Post by: frankie on July 03, 2013, 11:37:08 PM
I use MS Visual Studio, just started Pelle's C. And compiler states that _int64 is undefined. It is my preference to stay with _int64 rather than using long long.
_int64 is not standard C, PellesC have __int64 (2 underscores) as Timovjl has wrote (look better his post).
You can make your code compatible with both compilers using:
Code: [Select]
#ifdef __POCC__
typedef __int64 _int64;
#endif
Title: Re: Simple Text Editor project
Post by: jj2007 on July 04, 2013, 01:15:02 AM
Commented ctrl v assignment from the accelerator table of rc file, it works normally. I think ctrl v works twice.

The RichEd control handles Ctrl C/X/V by default, therefore no need for an accelerator.
Title: Re: Simple Text Editor project
Post by: tanel on July 04, 2013, 07:21:25 AM
Now, I understood what Timovjl meant. "(2 underscores)" made clear.

Title: Re: Simple Text Editor project
Post by: jj2007 on July 04, 2013, 08:59:16 AM
Tanel,

This is a nice project. Be aware, though, that the RichEdit control is a pig - it has some really nasty bugs, and badly documented behaviour. PM me if you are stuck with weird behaviour; I have written 15,000 lines for RichMasm (http://www.masmforum.com/board/index.php?topic=9044), and found workarounds for quite a number of bugs.

You can also search the Masm32 forum (http://masm32.com/board/index.php) for the term RichEdit - there are 31 threads dealing with it, as compared to only two here.
Title: Re: Simple Text Editor project
Post by: tanel on July 04, 2013, 06:09:15 PM
Thank you jj2007. I'll check masm32 forum.

In the meantime, I realized that StringCbCopy causes "unreachable code" warnings.
Title: V1.2 of Simple Text Editor project
Post by: tanel on July 05, 2013, 11:11:25 PM
Taking the comments and feedbacks into consideration, updated version of the project is attached. Major difference is file read and write mechanism. In order to keep rich format during file save, streamout was implemented.

Change summary between V1.1a and V1.2a
1. Added open/save in rtf (file read & write approach completely changed)
2. Fixed "ctrl v paste twice" issue
3. Fixed New File and Close File problems
4. Added text mode information in status bar
5. Added font parameters dialog to change font type, color, size, style
6. Fixed context menu, toolbar and main menu enable/disable issues
7. Enabled printer dialog box
8. Added "content change" check to Close button of System Menu

(My goal was to have basic plain text editor but turned out to be more functional. )

Removed attachment due to availability of new version
Title: Re: Simple Text Editor project
Post by: jj2007 on July 05, 2013, 11:21:06 PM
And there is even a box saying "you made changes, wanna save?"
Keep up the good work :)
Title: New version; V2.0 of Simple Text Editor project
Post by: tanel on August 15, 2013, 11:34:58 AM
In parallel with my main project, updated the Simple Text Editor to have MDI support. New version  is attached as project file.

Change Log summary between V1.2a and V2.0a

1. Implemented multiple document support with tab control (reason for the major change in version).
So that, more than one document can be opened, edited, created.
2. Added Caps Lock detection and display in the status bar.
3. Added Insert / Over Write mode detection and display in the status bar.
4. Added drag&drop feature to open a document. (file can be opened by dropping its icon onto application icon)
5. Added Windows menu item to main menu to support MDI
6. Added help function with a menu item
7. Added tip for the tool bar icons