[Demo] Dual editor for translators

Demos, code samples. Only questions related to the existing topics are allowed here.
Post Reply
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

[Demo] Dual editor for translators

Post by Sergey Tkachenko »

Demo:
http://www.trichview.com/support/files/dualeditor.zip

A helper for human translators. It has two editors - one for the original text and one for the translated text. This screenshot shows English text and its Russian translation:
Image

This demo does two things:
1) synchronizes scrolling
2) highlights the currect paragraph in the focused editor, and the corresponding paragraph in another editor.

While (1) is a straightforward procedure, (2) is a kind of trick, because
custom drawing events were not designed for such things, and it slows down editing (because it needs to repaint both editors on each caret movement). If you decide to implement (2) in your application, I recommend to make it optional.
lkessler
Posts: 112
Joined: Thu Sep 01, 2005 9:00 pm
Location: Winnipeg, Manitoba, Canada
Contact:

Post by lkessler »

It would seem to me that this could be used to implement a splitter to divide a RVEdit window into two screens. That's something I will want to implement in the future. However, I will need it to work with tables.

Also, is the Invalidate function "smart" in knowing that it only needs to refresh the screen and not need to reformat?
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This demo does not modify the second editor, if the text in the first editor is changed. It only highlights paragraph with the same index.
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Displaying 'Filename' for open document/file

Post by Nostradamus »

Hello Sergey,

1 How do I display filenames {in a status bar TPanel} in the dualeditor for two open documents?

Would this be done the same way as for Editor 2 in the demos provided?

2 When I do SaveAs,,,

when the dialog window opens .... How do I get the current filename to appear in the window where it asks name of file?

Any help is appreciated

Richard
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, do it like in the Editor2 demo.
TRichView does not store names of files, you need to do it yourself (or use RichViewActions)
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Re: [Demo] Dual editor for translators

Post by Nostradamus »

Hello Sergey ,

I have upgraded to Delphi 10 and the Translator demo no longer works. Can you tweet it so it will work with Delphi 2010 ? the error log mentions incompatible types 'Char' and 'Word'
Cheers

Richard
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: [Demo] Dual editor for translators

Post by Sergey Tkachenko »

I cannot reproduce the problem. I just compiled this demo using TRichView 17.5 and a new version of Delphi.

Where is the error exactly?
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Re: [Demo] Dual editor for translators

Post by Nostradamus »

Hi Sergey,

Yes I tried that version & it does work with D 2010

I have a more elaborate version which selects/highlights words [Previous.Word button & Next.word Button ] that trigger a table. source.word search and retrieves table target word
and posts results in DBEdit.

This Project worked OK in Delphi 5 Enterprise with TNT Controls, TRichView and Rubicon Text Search.

Maybe I can get it to work or open if I try downloading and installing TNT Controls for 2009.
Otherwise, I will have to start from scratch.

I will try a few more things before asking again.

Thanks

Richard
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Re: [Demo] Dual editor for translators

Post by Nostradamus »

HELLO SERGEY,

I HAVE DECIDED TO TRY AGAIN TO GET THIS OLD DELPHI 5 PROJECT WHICH IS MODIFIED TO SELECT WORDS

WORKING UNDER DELPHI 2010 ENTERPRISE

I HAVE ZIPPED IT FOR YOU TO SEE AND EXPLAIN IF POSSIBLE HOW TO CHANGE IT TO RUN ON DELPHI 2010 WITH WINDOWS 7
ANY HELP IS APPRECIATED

SEE ATTACHED PROJECT DUALEDITOR.ZIP

RICHARD

FROM AUSTRALIA
Attachments
dualeditor.zip
(28.24 KiB) Downloaded 7294 times
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: [Demo] Dual editor for translators

Post by Sergey Tkachenko »

Nostradamus, this project was created in the old version of TRichView. The only required change to make it work in the new version of TRichView, is removing type-casting to Word in all calls of IsDelimiterW.
For example, change

Code: Select all

rve.RVData.IsDelimiterW(Word(ws[Offs]))
to

Code: Select all

rve.RVData.IsDelimiterW(ws[Offs])
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Re: [Demo] Dual editor for translators

Post by Nostradamus »

GREAT !

IT WORKS NOW

THANKS SERGEY
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Re: [Demo] Dual editor for translators

Post by Nostradamus »

Hello Sergey,
Can you please show me how to connect the Label.caption text data into a search
eg Highlighted word in TRichViewEdit is "above".
So....as part of the Onclick event
Select from table "Uni_Dict "
using the following :-
Label.caption := "above" [this is just a static example the real code will need to dynamically search for new words from Label.caption
after the "next-word"" button click or "previous-word" button click]

I guess a drop database or something would start a fresh search after each button click.
then search database "Uni_Dict"
where Uni_Dict.Eng := [Label.Caption]
I will send a zip of the project it runs from folder "C:\Delphi_DB_Projects\DB_Dual Editor WORD SELECT"
The current highlighted word would cause the upper dbText and DBEdit windows on the MAINFORM to be populated for each new word located in the database.

Any Help is appreciated.
I think this will help Lajos.

Cheers
Nostradamus
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: [Demo] Dual editor for translators

Post by Sergey Tkachenko »

Use GetCurrentWord function from RVGetTextW unit, assign its result to the label's Caption.
Do it in OnChange and in OnCaretMove events.
Post Reply