RichEdit Functions (OOP) New: with Image-Support

Share your advanced PureBasic knowledge/code with the community.
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Re: RichEdit Functions (OOP) New: with Image-Support

Post by RichardL »

Thanks but...
The values of 'startpos' and 'endpos' are memory addresses' and I need to read (a) the contents of the line in the HEX editor (to recover the offset address) and (b) the highlighted section that the user has identified.

I suppose I could search backwards or forwards from 'startpos' until I find an address (which is identifiable because it has a lot of digits with no spaces) but that is a bit of a kludge!

Richard
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: RichEdit Functions (OOP) New: with Image-Support

Post by VB6_to_PBx »

ts-soft ,

How can i Open a regular .TXT file with your RichEdit Software ??

i would like to Open and Edit a regular .TXT file with your RichEdit Software ,
then make some RichText changes to that .TXT file content, ( such as Bold or Font Color changes , etc. )
and then be able to Save that file along with any Rich Text changes i've made
and Save it with .RTF extension , as a real .RTF file.

-----------

i know i can open a .TXT file then Copy its Text to the ClipBoard
and then Paste it into your RichEdit software
but i would like to just Open a TXT file and do Rich Text editing inside your software
then Save it as .RTF File
Last edited by VB6_to_PBx on Wed Oct 09, 2013 12:20 am, edited 1 time in total.
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: RichEdit Functions (OOP) New: with Image-Support

Post by rsts »

Did you try renaming the .txt to .rtf?

Just asking. I have not tried it myself.

cheers
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: RichEdit Functions (OOP) New: with Image-Support

Post by VB6_to_PBx »

rsts wrote:Did you try renaming the .txt to .rtf?

Just asking. I have not tried it myself.

cheers
i had tried that too, but it does not work .

the only other way is too Paste text from the ClipBoard
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: RichEdit Functions (OOP) New: with Image-Support

Post by ts-soft »

Code: Select all

RichEdit_LoadText()
RichEdit_SaveRTF()
?
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: RichEdit Functions (OOP) New: with Image-Support

Post by VB6_to_PBx »

ts-soft wrote:

Code: Select all

RichEdit_LoadText()
RichEdit_SaveRTF()
?
i changed your Code to this : Edit\LoadText(File)

Code: Select all

    Case #PB_Event_Menu
      Select EventMenu()
        Case #mnu_New
          Edit\Clear()
          SetStatusbarText()
          DisableToolBarButton(0, #mnu_Undo, Edit\CanUndo() ! 1)
          DisableToolBarButton(0, #mnu_Redo, #True)
        Case #mnu_Open
          File = OpenFileRequester(Lang(23), "", "RichText (*.rtf)|*.rtf | Text (*.txt)|*.txt", 0)
          If File
            Edit\LoadRTF(File)
            Edit\LoadText(File)
            SetStatusbarText()
            DisableToolBarButton(0, #mnu_Undo, Edit\CanUndo() ! 1)
            DisableToolBarButton(0, #mnu_Redo, #True) 
          EndIf

is that OK or proper way to modify your Code ??
any problems doing that way ??

Also when you Save a File it does not automatically add the .RTF extension

One more Problem occurs if i try your RichText software in new PB version 5.20
but not in older v5.11

the PB v5.20 ERROR is Line = #CFM_SUPERSCRIPT
[01:52:36] [COMPILER] Line 106: Constant already declared with a different value: #CFM_SUPERSCRIPT.
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: RichEdit Functions (OOP) New: with Image-Support

Post by ts-soft »

VB6_to_PBx wrote:Also when you Save a File it does not automatically add the .RTF extension
This is a feature :mrgreen: (not everybody use the rtf extension)
VB6_to_PBx wrote:the PB v5.20 ERROR is Line = #CFM_SUPERSCRIPT
[01:52:36] [COMPILER] Line 106: Constant already declared with a different value: #CFM_SUPERSCRIPT.
Add a compilerdirective with CompilerIf Defined around the declaration.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: RichEdit Functions (OOP) New: with Image-Support

Post by ts-soft »

Update:
History wrote:; Version 2.2, October 31, 2013
; modified for PB 5.20
; modified: GetRTFStreamCallback

; Version 2.3, November 03, 2013
; changed to Module (RichEdit)
; some bugfixes
Special thanks to ozzie for his suggestions/fixes
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
ASI
New User
New User
Posts: 5
Joined: Thu Sep 12, 2013 4:07 pm

Re: RichEdit Functions (OOP) New: with Image-Support

Post by ASI »

I know this is an old thread but anyone downloading this may still get an error from
#CFM_SUPERSCRIPT already defined with different value

Because the constant is declared again a little further down the list of constants
just after the CFE constants
#CFM_SUBSCRIPT = #CFE_SUBSCRIPT | #CFE_SUPERSCRIPT

So the first definition can be commented out and everything will be ok.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: RichEdit Functions (OOP) New: with Image-Support

Post by ts-soft »

@ASI
from first page:
ts-soft wrote:Attention:
The new version breaks the limit of 60000 chars from the forum,
please download it.

Current is Version 2.3 from 2013/11/03
here the link (is also in the first page):
http://www.realsource.de/downloads/doc_ ... edit-class
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
ASI
New User
New User
Posts: 5
Joined: Thu Sep 12, 2013 4:07 pm

Re: RichEdit Functions (OOP) New: with Image-Support

Post by ASI »

Yes i know links are on the first page.

Appologies for confusion caused. And not meant to offend,
I thank you for creating this in the first place.

I have been using the code for a while in a project.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: RichEdit Functions (OOP) New: with Image-Support

Post by ts-soft »

I mean, there is no problem with constants in v 2.3?

Code: Select all

  #CFM_ALLCAPS = $80
  #CFM_ANIMATION = $40000
  #CFM_BACKCOLOR = $4000000
  #CFM_BOLD = $1
  #CFM_CHARSET = $8000000
  #CFM_COLOR = $40000000
  #CFM_DISABLED = $2000
  #CFM_EMBOSS = $800
  #CFM_FACE = $20000000
  #CFM_HIDDEN = $100
  #CFM_IMPRINT = $1000
  #CFM_ITALIC = $2
  #CFM_KERNING = $100000
  #CFM_LCID = $2000000
  #CFM_LINK = $20
  #CFM_OFFSET = $10000000
  #CFM_OUTLINE = $200
  #CFM_PROTECTED = $10
  #CFM_REVAUTHOR = $8000
  #CFM_REVISED = $4000
  #CFM_SHADOW = $400
  #CFM_SIZE = $80000000
  #CFM_SMALLCAPS = $40
  #CFM_SPACING = $200000
  #CFM_STRIKEOUT = $8
  #CFM_STYLE = $80000
  CompilerIf Defined(CFM_SUPERSCRIPT, #PB_Constant) = #False
    #CFM_SUPERSCRIPT =  $20000; #CFM_SUBSCRIPT
  CompilerEndIf
  #CFM_UNDERLINE = $4
  #CFM_UNDERLINETYPE = $800000
  #CFM_WEIGHT = $400000
  
  #CFE_ALLCAPS = #CFM_ALLCAPS
  #CFE_AUTOBACKCOLOR = #CFM_BACKCOLOR
  #CFE_AUTOCOLOR = $40000000
  #CFE_BOLD = #CFM_BOLD
  #CFE_DISABLED = #CFM_DISABLED
  #CFE_EMBOSS = #CFM_EMBOSS
  #CFE_HIDDEN = #CFM_HIDDEN
  #CFE_IMPRINT = #CFM_IMPRINT
  #CFE_ITALIC = #CFM_ITALIC
  #CFE_LINK = #CFM_LINK
  #CFE_OUTLINE = #CFM_OUTLINE
  #CFE_PROTECTED = #CFM_PROTECTED
  #CFE_REVISED = #CFM_REVISED
  #CFE_SHADOW = #CFM_SHADOW
  #CFE_SMALLCAPS = #CFM_SMALLCAPS
  #CFE_STRIKEOUT = $8
  #CFE_SUBSCRIPT = $10000
  #CFE_SUPERSCRIPT = $20000
  #CFE_UNDERLINE = $4
  #CFM_SUBSCRIPT = #CFE_SUBSCRIPT | #CFE_SUPERSCRIPT
  
  #ENM_LINK = $04000000
  
  #PFA_JUSTIFY = 4  ;New paragraph-alignment option 2.0
  
  #ST_DEFAULT = 0
  #ST_KEEPUNDO = 1
  #ST_SELECTION = 2
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Ferdinand
New User
New User
Posts: 9
Joined: Tue Mar 10, 2015 1:43 pm
Location: Netherlands
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by Ferdinand »

Just downloaded and experimented with this.
I didn't get any error messages.
And I think this is really impressive. :D
thanks for the work on it, ts-soft.
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: RichEdit Functions (OOP) New: with Image-Support

Post by HanPBF »

Hello Thomas!

Just needed an RTF-converting to raw text.

Seems that SetText and GetText do this easily as PB can show RTF.

So, thanks a lot for sharing!!!
User avatar
DjPoke
User
User
Posts: 14
Joined: Sun Aug 10, 2014 11:23 am
Location: Corsica (France)
Contact:

Re: RichEdit Functions (OOP) New: with Image-Support

Post by DjPoke »

Thanks for this usefull and great work.
This is a lot of time i wait for something like this.

I noticed in the spellchecker example that if the first word at top/left is wrong, correcting it will make its first letter to be doubled.

I also noticed that the Chr(13) separator seems to not be recognised in the "Tokenise" functions.
For example, if i delete the randomly generated text, and put a wrong word at the first line and a wrong word at the second line, a right click on the first word will give me a correction based on the two words.

EDIT:
The first bug was that at three times, you should use #WB_MOVEWORDLEFT, not #WB_LEFTBREAK.

This is the three procedures to edit :

Code: Select all

RichEdit_GetWordUnderMouse( *this.RichEditClassTemplate, x.i, y.i )
RichEdit_GetCurrentWord(*this.RichEditClassTemplate)
RichEdit_GetWordAtPosition(*this.RichEditClassTemplate, Pos.i)
Enjoy the silence
Post Reply