NO

Author Topic: Simple Text Editor project  (Read 10240 times)

tanel

  • Guest
Simple Text Editor project
« 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.
« Last Edit: July 03, 2013, 02:01:36 PM by tanel »

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Simple Text Editor project
« Reply #1 on: June 29, 2013, 01:46:02 AM »
Thanks, nice little project that might come in handy for others...  :D

Ralf

tanel

  • Guest
New Version of Simple Text Editor
« Reply #2 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


czerny

  • Guest
Re: Simple Text Editor project
« Reply #3 on: July 03, 2013, 03:59:20 PM »
It is not a good idea to add/change standard include files.

tanel

  • Guest
Re: Simple Text Editor project
« Reply #4 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

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Simple Text Editor project
« Reply #5 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 ?
May the source be with you

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Simple Text Editor project
« Reply #6 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)

tanel

  • Guest
Re: Simple Text Editor project
« Reply #7 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.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Simple Text Editor project
« Reply #8 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
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Simple Text Editor project
« Reply #9 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.

tanel

  • Guest
Re: Simple Text Editor project
« Reply #10 on: July 04, 2013, 07:21:25 AM »
Now, I understood what Timovjl meant. "(2 underscores)" made clear.


Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Simple Text Editor project
« Reply #11 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, and found workarounds for quite a number of bugs.

You can also search the Masm32 forum for the term RichEdit - there are 31 threads dealing with it, as compared to only two here.

tanel

  • Guest
Re: Simple Text Editor project
« Reply #12 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.

tanel

  • Guest
V1.2 of Simple Text Editor project
« Reply #13 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
« Last Edit: August 15, 2013, 11:28:51 AM by tanel »

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Simple Text Editor project
« Reply #14 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 :)