Die Sache läuft ja, aber beim Duplizieren hängt es ein \par Zeilenumbruch ran,
weiss jemand warum???
Code: Alles auswählen
;- © API_571_x64_PARSERMODE_012
; ► Editor_Set_Raw_Richtext_Ascii umbenannt!
; ►
; ►
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EnableExplicit
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Enumeration
#Edt_Win
#Txt_Rich
#Txt_Lese
#Txt_Html
#Btn_RTF
#Btn_RTF2
#Btn_WORK_MEMO
#Btn_DATA
#Clear_Work
#Btn_MEMO_WORK
#Clear_Memo
#Clear_Web
#Btn_MEMO_HTML
#Btn_WORK_HTML
EndEnumeration
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Global Editor_Zoom_Numerator
Global Editor_Zoom_Denominator
; --------------------------
Global Work_E_Notiz
Global Memo_E_Notiz
Global iPage_Web
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Global KleineLinie$ ="---------------------------------------------"
Global GrosseLinie$ = "------------------------------------------------------------------------------------------"
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Global KleineDoppelteLinie$ = "======================="
Global GrosseDoppelteLinie$ = "============================================="
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Global HTMLLine$ = "<hr>"
Global HTMLLine2$ = "<HR COLOR=#FF00FF SIZE=2>"
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Global Parser_NOTIZ$ = ""
Global NOTIZ$ = ""
Global Parser_RawRichText$
Global HTML.s = ""
; *****************************************************************************
Parser_NOTIZ$ + "{\rtf1\ansi\ansicpg1252\deff0\deflang1031\deflangfe1031{\fonttbl{\f0\fswiss\fprq2\fcharset0 Verdana;}{\f1\fswiss\fprq2\fcharset0 Segoe WP SemiLight;}}"
Parser_NOTIZ$ + "{\colortbl ;\red0\green128\blue128;\red51\green51\blue51;}"
Parser_NOTIZ$ + "{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\nowidctlpar\cf1\f0\fs20 So kennen wir den \'84Riverdale\ldblquote -Star gar nicht. \cf2\f1 (was so viel wie \'84Baumwollburg\ldblquote bedeutet)\cf1\f0\par"
Parser_NOTIZ$ + "\cf1\ul\b\i\fs28 APPNAME é à ç è ê @ € é à ç è ê Ö Ü Ä ö ü ä € "
Parser_NOTIZ$ + "}"
; *****************************************************************************
Global Parser_NOTIZ2$ = ""
; *****************************************************************************
; Global Parser_NOTIZ2$ = "{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fswiss\fprq2\fcharset0 Verdana;}{\f1\fswiss\fprq2\fcharset0 Segoe WP SemiLight;}{\f2\fnil\fcharset0 MS Shell Dlg;}} {\colortbl ;\red0\green128\blue128;\red51\green51\blue51;} \viewkind4\uc1\pard\nowidctlpar\cf1\f0\fs20 So kennen wir den \ldblquote Riverdale\ldblquote -Star gar nicht. \cf2\f1 (was so viel wie \ldblquote Baumwollburg\ldblquote bedeutet)\cf1\f0\par \pard\ul\b\i\fs28 APPNAME \'e9 \'e0 \'e7 \'e8 \'ea @ \'80 \'e9 \'e0 \'e7 \'e8 \'ea \'d6 \'dc \'c4 \'f6 \'fc \'e4 \'80 \cf0\ulnone\b0\i0\f2\fs17\par } "
; Global Parser_NOTIZ2$ = "{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fswiss\fprq2\fcharset0 Verdana"+Chr(59)+"}{\f1\fswiss\fprq2\fcharset0 Segoe WP SemiLight"+Chr(59)+"}{\f2\fnil\fcharset0 MS Shell Dlg"+Chr(59)+"}} {\colortbl "+Chr(59)+"\red0\green128\blue128"+Chr(59)+"\red51\green51\blue51"+Chr(59)+"} \viewkind4\uc1\pard\nowidctlpar\cf1\f0\fs20 So kennen wir den \'84Riverdale\ldblquote -Star gar nicht. \cf2\f1 (was so viel wie \'84Baumwollburg\ldblquote bedeutet)\par -------------------------------------------------------------------\cf1\f0\par \pard\ul\b\i\fs28 APPNAME \'e9 \'e0 \'e7 \'e8 \'ea @ \'80 \'e9 \'e0 \'e7 \'e8 \'ea \'d6 \'dc \'c4 \'f6 \'fc \'e4 \'80 \cf0\ulnone\b0\i0\f2\fs17\par } "
;Global Parser_NOTIZ2$ = "{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fswiss\fprq2\fcharset0 Verdana"+Chr(59)+"}{\f1\fswiss\fprq2\fcharset0 Segoe WP SemiLight"+Chr(59)+"}{\f2\fnil\fcharset0 Swis721 Ex BT"+Chr(59)+"}{\f3\fnil\fcharset0 Calibri"+Chr(59)+"}{\f4\fnil\fcharset0 MS Shell Dlg"+Chr(59)+"}} {\colortbl "+Chr(59)+"\red0\green128\blue128"+Chr(59)+"\red51\green51\blue51"+Chr(59)+"} \viewkind4\uc1\pard\nowidctlpar\f0\fs24 \cf1\fs20 So kennen wir den \'84Riverdale\ldblquote -Star gar nicht. \cf2\f1 (was so viel wie \'84Baumwollburg\ldblquote bedeutet)\par -------------------------------------------------------------------\cf1\f0\par \pard\sa200\sl276\slmult1\f2\fs28 APPNAME \f0\'e9 \'e0 \'e7 \'e8 \ul\b\i\'ea @ \'80 \'e9 \'e0 \'e7 \'e8 \'ea \'d6 \'dc \'c4 \'f6 \'fc \'e4 \'80 \cf0\lang7\ulnone\b0\i0\f3\fs22\par \pard\lang1031\f4\fs17\par \par \pard\cf0\fs17\par}"
; *****************************************************************************
Parser_NOTIZ2$ + "{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fswiss\fprq2\fcharset0 Verdana;}{\f1\fswiss\fprq2\fcharset0 Segoe WP SemiLight;}{\f2\fnil\fcharset0 MS Shell Dlg;}}"
Parser_NOTIZ2$ + "{\colortbl ;\red0\green128\blue128;\red51\green51\blue51;}"
Parser_NOTIZ2$ + "{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\nowidctlpar\cf1\f0\fs20 So kennen wir den \'84Riverdale\ldblquote -Star gar nicht. \cf2\f1 (was so viel wie \'84Baumwollburg\ldblquote bedeutet)\par"
Parser_NOTIZ2$ + "-------------------------------------------------------------------\cf1\f0\par"
Parser_NOTIZ2$ + "\pard\ul\b\i\fs28 APPNAME \'e9 \'e0 \'e7 \'e8 \'ea @ \'80 \'e9 \'e0 \'e7 \'e8 \'ea \'d6 \'dc \'c4 \'f6 \'fc \'e4 \'80\cf0\ulnone\b0\i0\f2\fs17\par"
Parser_NOTIZ2$ + "}"
; *****************************************************************************
;{ [STRUCT] CALLBACK_COOKIE
Structure _CALLBACK_COOKIE_
*Buffer
Pos.l
EndStructure
;}
; ================================
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-- [RTF] Editor
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure Editor_Get_Raw_ASCII_Callback(*dwCookie._CALLBACK_COOKIE_, *pbBuff, cb, *pcb.LONG)
; über Struct
If *dwCookie\Pos + cb > MemorySize(*dwCookie\Buffer)
*dwCookie\Buffer = ReAllocateMemory(*dwCookie\Buffer, *dwCookie\Pos + cb + SizeOf(CHARACTER))
EndIf
CopyMemory(*pbBuff, *dwCookie\Buffer + *dwCookie\Pos, cb)
*dwCookie\Pos + cb
*pcb\l = cb
ProcedureReturn 0
EndProcedure
Procedure.s Editor_Get_Raw_Richtext_Ascii(Gadget)
; -----------------------------------------------------
Protected stream.EDITSTREAM, CC._CALLBACK_COOKIE_, Result.s
; -----------------------------------------------------
; über Struct
CC\Buffer = AllocateMemory(2048)
; -----------------------------------------------------
CC\Pos = 0
; -----------------------------------------------------
stream\pfnCallback = @Editor_Get_Raw_ASCII_Callback()
; -----------------------------------------------------
stream\dwCookie = @CC
; -----------------------------------------------------
SendMessage_(GadgetID(Gadget), #EM_STREAMOUT, #SF_RTF | #SFF_PLAINRTF, @stream)
; -----------------------------------------------------
; Das geht mit leerraum
; -----------------------------------------------------
; 5.71 Ascii oder Unicode nicht gleich zwischen den Ständen
; Result = PeekS(CC\Buffer, MemorySize(CC\Buffer) , #PB_Ascii)
Result = PeekS(CC\Buffer, MemorySize(CC\Buffer), #PB_UTF8)
; -----------------------------------------------------
; 5.73 Ascii oder Unicode nicht gleich zwischen den Ständen
; Result = PeekS(CC\Buffer, MemorySize(CC\Buffer), #PB_Unicode)
; -----------------------------------------------------
FreeMemory(CC\Buffer)
; -----------------------------------------------------
ProcedureReturn Result
; -----------------------------------------------------
EndProcedure
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Editor_Set_Raw_Richtext_Ascii by mk-soft, v1.05, 27.03.2018
Procedure Editor_Set_Raw_Richtext_Ascii(Gadget, Text.s , NewLine=#False)
; -------------------------------
Protected pattern.s
Protected replacement.s
Protected regex
; -------------------------------
Debug "=>" + Text
; -------------------------------
SetGadgetText(Gadget,"")
; -------------------------------
If Left(Text, 5) <> "{\rtf"
Text = "{\rtf " + Text + "}"
EndIf
; -------------------------------
If NewLine
Text = Left(Text, Len(text) - 1) + "\line}"
EndIf
; -------------------------------
CompilerIf #PB_Compiler_Unicode
; -------------------------------
Protected hEdit = GadgetID(Gadget)
Protected ndx = GetWindowTextLength_(hEdit)
; -------------------------------
; pattern.s = "\\ldblquote\s*"
; replacement.s = " " + Chr(34)
; -------------------------------
pattern.s = "\par\par"
replacement.s = "\par"
; -------------------------------
regex = CreateRegularExpression(#PB_Any, pattern)
; -------------------------------
If regex
Text = ReplaceRegularExpression(regex, Text, replacement)
FreeRegularExpression(regex)
EndIf
Debug "Text= "+Text
; -------------------------------
Protected *szBuffer = UTF8(Text)
; Protected *szBuffer = Ascii(Text)
; -------------------------------
SendMessage_(hEdit, #EM_SETSEL, ndx, ndx)
SendMessage_(hEdit, #EM_REPLACESEL, 0, *szBuffer)
FreeMemory(*szBuffer)
; -------------------------------
CompilerElse
; -------------------------------
AddGadgetItem(Gadget, -1 , Text)
; -------------------------------
CompilerEndIf
; -------------------------------
EndProcedure
;}
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-- Windows
OpenWindow(#Edt_Win,0,0,300,625,"API_571_x64_PARSERMODE_013 Richtext to Web => TXT Problem",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(#Edt_Win))
ButtonGadget(#Btn_DATA,280,5,20,20,"#")
ButtonGadget(#Btn_MEMO_WORK,5,5,90,20,"MEMO => WORK")
ButtonGadget(#Clear_Work,95,5,20,20,"C")
TextGadget(#Txt_Rich,120,7,290,20,"[RTF] Richtext herein kopieren!")
Work_E_Notiz = EditorGadget(#PB_Any,5,25,290,160,#PB_Editor_WordWrap)
ButtonGadget(#Btn_RTF,270,190,30,20,"RTF")
ButtonGadget(#Btn_WORK_MEMO,5,190,90,20,"WORK => MEMO")
ButtonGadget(#Clear_Memo,95,190,20,20,"C")
TextGadget(#Txt_Lese,120,192,290,20,"[TXT] Lesetext wird angezeigt!")
Memo_E_Notiz = EditorGadget(#PB_Any,5,210,290,160,#PB_Editor_WordWrap)
ButtonGadget(#Btn_RTF2,270,370,30,20,"RTF")
ButtonGadget(#Btn_MEMO_HTML,5,370,90,20,"MEMO => HTML")
ButtonGadget(#Btn_WORK_HTML,95,370,90,20,"WORK => HTML")
ButtonGadget(#Clear_Web,190,370,20,20,"C")
TextGadget(#Txt_Html,220,372,290,20,"[HTML]")
iPage_Web = WebGadget(#PB_Any,5,395,290,225,"")
; TextGadget(iPage_Web,5,5,300,290,145,"")
; StringGadget(iPage_Web,5,300,290,145,"")
; Editor_Set_Raw_Richtext_Ascii(Work_E_Notiz, Parser_NOTIZ$)
Editor_Set_Raw_Richtext_Ascii(Work_E_Notiz, Parser_NOTIZ2$)
;}
;-- REPEAT
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow: End
Case #PB_Event_Gadget
Select EventGadget()
Case #Btn_DATA
;{ "SET WORK"
SetGadgetText(Work_E_Notiz,"")
Editor_Set_Raw_Richtext_Ascii(Work_E_Notiz, Parser_NOTIZ2$)
;}
Case #Clear_Work
;{ "SET MEMO"
SetGadgetText(Work_E_Notiz,"")
;}
Case #Btn_WORK_MEMO
SendMessage_(GadgetID(Work_E_Notiz), #EM_GETZOOM, @Editor_Zoom_Numerator, @Editor_Zoom_Denominator)
;{ "WORK => MEMO"
NOTIZ$ = Editor_Get_Raw_Richtext_Ascii(Work_E_Notiz)
NOTIZ$ = ReplaceString(NOTIZ$,KleineLinie$, GrosseLinie$ )
NOTIZ$ = ReplaceString(NOTIZ$,KleineDoppelteLinie$,GrosseDoppelteLinie$ )
Debug "NOTIZ$ = "+NOTIZ$
ClearGadgetItems(Memo_E_Notiz)
Editor_Set_Raw_Richtext_Ascii(Memo_E_Notiz,NOTIZ$)
;}
SendMessage_(GadgetID(Memo_E_Notiz), #EM_SETZOOM, Editor_Zoom_Numerator, Editor_Zoom_Denominator)
Case #Clear_Memo
SetGadgetText(Memo_E_Notiz,"")
Case #Btn_MEMO_WORK
SendMessage_(GadgetID(Memo_E_Notiz), #EM_GETZOOM, @Editor_Zoom_Numerator, @Editor_Zoom_Denominator)
;{ "MEMO => WORK"
NOTIZ$ = Editor_Get_Raw_Richtext_Ascii(Memo_E_Notiz)
NOTIZ$ = ReplaceString(NOTIZ$,GrosseLinie$,KleineLinie$)
NOTIZ$ = ReplaceString(NOTIZ$,GrosseDoppelteLinie$,KleineDoppelteLinie$)
ClearGadgetItems(Work_E_Notiz)
Editor_Set_Raw_Richtext_Ascii(Work_E_Notiz,NOTIZ$)
;}
SendMessage_(GadgetID(Work_E_Notiz), #EM_SETZOOM, Editor_Zoom_Numerator, Editor_Zoom_Denominator)
Case #Btn_RTF
;{ "RTF => HTML"
NOTIZ$ = Editor_Get_Raw_Richtext_Ascii(Work_E_Notiz)
HTML.s = "<!DOCTYPE html><head><meta charset='utf-8'></head><body>"+NOTIZ$+"</body></html>"
SetGadgetItemText(iPage_Web, #PB_Web_HtmlCode, HTML)
;}
Case #Btn_RTF2
;{ "RTF => HTML"
NOTIZ$ = Editor_Get_Raw_Richtext_Ascii(Memo_E_Notiz)
HTML.s = "<!DOCTYPE html><head><meta charset='utf-8'></head><body>"+NOTIZ$+"</body></html>"
SetGadgetItemText(iPage_Web, #PB_Web_HtmlCode, HTML)
;}
Case #Btn_WORK_HTML
;{ "TXT => HTML"
NOTIZ$ = GetGadgetText(Work_E_Notiz)
NOTIZ$ = ReplaceString(NOTIZ$,KleineDoppelteLinie$,HTMLLine2$)
NOTIZ$ = ReplaceString(NOTIZ$,KleineLinie$,HTMLLine$)
Debug "=> "+#PB_Compiler_Version
CompilerIf #PB_Compiler_Version > 571
HTML.s = "<!DOCTYPE html><head><meta charset='utf-8'></head><body>"+NOTIZ$+"</body></html>"
CompilerElse
HTML.s = "<!DOCTYPE html><head></head><body>"+NOTIZ$+"</body></html>"
CompilerEndIf
SetGadgetItemText(iPage_Web, #PB_Web_HtmlCode, HTML)
;}
Case #Btn_MEMO_HTML
;{ "TXT => HTML"
NOTIZ$ = GetGadgetText(Memo_E_Notiz)
NOTIZ$ = ReplaceString(NOTIZ$,KleineDoppelteLinie$,HTMLLine2$)
NOTIZ$ = ReplaceString(NOTIZ$,KleineLinie$,HTMLLine$)
Debug "=> "+#PB_Compiler_Version
CompilerIf #PB_Compiler_Version > 571
HTML.s = "<!DOCTYPE html><head><meta charset='utf-8'></head><body>"+NOTIZ$+"</body></html>"
CompilerElse
HTML.s = "<!DOCTYPE html><head></head><body>"+NOTIZ$+"</body></html>"
CompilerEndIf
SetGadgetItemText(iPage_Web, #PB_Web_HtmlCode, HTML)
;}
Case #Clear_Web
SetGadgetItemText(iPage_Web, #PB_Web_HtmlCode,"")
EndSelect
EndSelect
ForEver
;}