Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-05

how to set two memos for parallel text editing ?

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Etienne Leblois

Dear list,

I want to edit two textfiles in a parallel way, so that visible portion of text one in memo1 has always same lines extent as the visible portion of text two in memo2, say lines n1 to n2.

Of course WordWrap must be false, so that one_text_line=one_visible_line

Then, how to manage that scrolling or arrowing up in one memo will also scroll up the other one ? Intercept event yes, but how to issue/code a scrolling order for memo that does not have focus ?

Thanks for hints,

Etienne.

Reply by email

Martin Frb
to Etienne Leblois
Etienne Leblois wrote 11 lines
Dear list, I want to edit two textfiles in a parallel way, so that visible portion of text one in memo1 has always same lines extent as the visible portion of text two in memo2, say lines n1 to n2. Of course WordWrap must be false, so that one_text_line=one_visible_line Then, how to manage that scrolling or arrowing up in one memo will also scroll up the other one ? Intercept event yes, but how to issue/code a scrolling order for memo that does not have focus ?

I dont know about TMemo. But with TSynEdit, you can use OnStatusChange

Reply by email

Martin Frb
to Martin Frb

Sorry, that mail was sent a bit quicker than I intended.

Martin Frb wrote 14 lines
On 28/05/2014 00:46, Etienne Leblois wrote: > Dear list, > > I want to edit two textfiles in a parallel way, so that visible > portion of text one in memo1 has always same lines extent as the > visible portion of text two in memo2, say lines n1 to n2. > > Of course WordWrap must be false, so that one_text_line=one_visible_line > > Then, how to manage that scrolling or arrowing up in one memo will > also scroll up the other one ? Intercept event yes, but how to > issue/code a scrolling order for memo that does not have focus ? I dont know about TMemo. But with TSynEdit, you can use OnStatusChange

I dont know about TMemo. But with TSynEdit, you can use OnStatusChange

SynEdit2.TopLine := SynEdit1.TopLine;
Also
SynEdit2.CaretY := SynEdit1.CaretY;

That is cool if you enable current line highlight, so the line with the caret has a special background color.

Reply by email

Howard Page-Clark
to Etienne Leblois: I want to edit two textfiles in a parallel way, so that visible portion of text one in…
Etienne Leblois wrote
how to manage that scrolling or arrowing up in one memo will also scroll up the other one ?

The following Windows example shows how to synchronise scrolling between two memos (Memo1, Memo2) using scrollbar movement. Responding to memo caret movement in addition would require more code based on the same message-interception ideas.

//== code ==
unit mainScrollMemo;
{$mode objfpc}{$H+}
interface
uses
   Classes, Forms, Controls, LMessages, StdCtrls;
type
   TForm1 = class(TForm)
     Memo1: TMemo;
     Memo2: TMemo;
     procedure FormCreate(Sender: TObject);
   private
     FOrgMemoWndProc: TWndMethod;
     procedure MemoWndMethod(var theMessage: TLMessage);
   end;
var
   Form1: TForm1;
implementation
uses windows;
{$R *.lfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
   FOrgMemoWndProc:=Memo1.WindowProc;
   ;
   memo1.Lines.LoadFromFile('..\..\mainscrollmemo.pp');
   memo2.Lines.LoadFromFile('..\..\mainscrollmemo.pp');
end;
procedure TForm1.MemoWndMethod(var theMessage: TLMessage);
begin
   FOrgMemoWndProc(theMessage);
   if theMessage.msg=LM_VSCROLL then
     SendMessage(Memo2.Handle, WM_VSCROLL, theMessage.wParam ,
theMessage.lParam);
   if theMessage.wParamlo=SB_THUMBTRACK then
     SetScrollPos(Memo2.Handle, SB_VERT, theMessage.wParamhi, True);
end;
end.
//== code end ==

You should be able to adapt this to your needs.

Howard

Reply by email