Lazarus

Programming => Packages and Libraries => SynEdit => Topic started by: Alextp on February 23, 2015, 08:31:40 am

Title: Making ATSynEdit
Post by: Alextp on February 23, 2015, 08:31:40 am
I started work on new "atSynEdit":
it's new syntax-editor, with the features of EControl Syntax Editor.
i hope it ll be OK Synedit after long-long time.
 

https://github.com/Alexey-T/ATSynEdit
Pls post issues to ISSUES page there
Title: Re: (todo) Plan to make new SynEdit
Post by: Martin_fr on February 23, 2015, 12:50:41 pm
(why?? i want EControl lexers in laz)

Well it will be a welcome addition.

About lexers (I assume kind of highlighter?) there is some thread on the forum with a configurable HL for SynEdit. There also is SynUniSyn, but it is not maintained.
Title: Re: (todo) Plan to make new SynEdit
Post by: Alextp on February 23, 2015, 01:12:05 pm
I mean lexers ==> https://sourceforge.net/projects/synwrite-addons/files/Lexers/ 
Title: Re: (todo) Plan to make new SynEdit
Post by: Martin_fr on February 23, 2015, 01:42:01 pm
Well that only tells what they can lex, But not the purpose. It does not say what they do with the info gained by lexing the text.

Title: Re: (todo) Plan to make new SynEdit
Post by: Alextp on February 23, 2015, 01:52:41 pm
lexing means a)Syntax hilite, b)much more powerfull syntax hilite than Synedit [no details, yet], c)cTags (sort of)
Title: Re: (todo) Plan to make new SynEdit
Post by: skalogryz on February 23, 2015, 02:03:53 pm
lzRichEdit maybe?
Title: Re: (todo) Plan to make new SynEdit
Post by: Morton on February 23, 2015, 03:01:56 pm
Just do it.
Surprise me.
Title: Re: (todo) Plan to make new SynEdit
Post by: Edson on February 23, 2015, 03:08:08 pm
It sounds a lot of work. If you can improve, some of SynEdit's lacks (wordwrap, column mode, ... ), it would be great.
Good luck.
Title: Re: (todo) Plan to make new SynEdit
Post by: Martin_fr on February 23, 2015, 03:37:49 pm
what is the problem with column mode? column selection or some thing else?
Title: Re: (todo) Plan to make new SynEdit
Post by: Edson on February 23, 2015, 04:43:10 pm
Column mode for edit multiple lines.
Title: Re: (todo) Plan to make new SynEdit
Post by: Martin_fr on February 23, 2015, 05:57:37 pm
Column mode for edit multiple lines.
Still not sure... But compile (trunk) IDE with WithSynMultiCaret defined. However, it has still plenty of bugs, and is not finished
Title: Re: (todo) Plan to make new SynEdit
Post by: Blaazen on February 23, 2015, 06:35:55 pm
Quote
Column mode for edit multiple lines.
I don't know what you mean exactly.

There exists package that enables to split Source Editor horizontally or vertically. https://github.com/ik5/split_lazarus/blob/master/package/lazsplitview.lpk (https://github.com/ik5/split_lazarus/blob/master/package/lazsplitview.lpk)

Title: Re: (todo) Plan to make new SynEdit
Post by: Martin_fr on February 23, 2015, 08:48:00 pm
well you can put 2 synedit next to eachother and connect them (share text buffer)

In the IDE you can open a 2nd source editor, and have the SynEdit in both. If you dock them then it is close.

Of course a feature is on the list .....
Title: Re: (todo) Plan to make new SynEdit
Post by: Martin_fr on February 26, 2015, 10:13:37 am
sorry not able to run an exe at the moment. Not a fan of downloading exe neither.
Title: Re: (todo) Plan to make new SynEdit
Post by: Alextp on February 26, 2015, 10:30:11 am
Pre-pre-test

Title: Re: (todo) Plan to make new SynEdit
Post by: Basile B. on February 26, 2015, 10:55:02 am
I gave a try, so far so good, I've put it in IDA, no TSyn...things in the names...
Too bad you don't wanna make line warping for SynEdit instead...

What would be great in a new HL system is highlightning based on a collection of lexer tokens. For example to highlight all the results of a search it becames totally different, that's how internet browser search in webpage nowadays, they use the DOM. One problem of the current SynEdit is that a source code lexer is not compatible with the HL lexer (because it's 'line by line'-based while a source code lexer doesn't care that much about a line...). Anyway still a very good component. ;)
Title: Re: (todo) Plan to make new SynEdit
Post by: Alextp on February 26, 2015, 10:59:14 am
-would be great in a new HL system is highlightning based on a collection
Say it later, not now: not ready.. Of coz I ll try to make
Title: Re: (todo) Plan to make new SynEdit
Post by: Martin_fr on February 26, 2015, 11:08:10 am
The line by line does not interfere with a contiguous source scan.
The lines are only used as arbitrary safe-points for the state, and the scan is continued.

As for search result highlight, this is called markup in synedit.

you can see all find results if you do incremental search.
Also have a look at user-defined-colors to highlight any term you want (this one is currently single line)
Title: Re: (todo) Plan to make new SynEdit
Post by: Alextp on February 26, 2015, 12:07:29 pm
Basile
i don't want to make wrap for Synedit. Indeed. I saw Synedit code, not nice at all, very complicated. Note I made ATViewer so i want to see code which is ok.. ok readable. this all leads me to conclusion: need new comp-t. Totally my code, which i understand

I made:
wrap-mode (off/ by edge/ by any column),
show unprintable chars (spc/ tabs/ eols)
show wrapped lines indented (like Sublime)
minimap (Sublime)
gutter with any info

later others..
Title: Re: (todo) Plan to make new SynEdit
Post by: Alextp on March 12, 2015, 07:09:14 pm
A pre-pre-pre-alfa https://github.com/Alexey-T/SynLite , program demo_editor (Not others!). Only base, even
no undo...
Who likes Minimap?
Title: Re: (todo) Plan to make new SynEdit
Post by: Xirax on March 12, 2015, 07:17:12 pm
Hi Alex,
Its really good!If your progress is as fast as now we will have a greet editor.
About Minimap its cool and a feature request please add mouse click and mouse down move for fast scrolling when click at it.
And painting is very slow when form size changes.

Have a good day.
Title: Re: (todo) Plan to make new SynEdit
Post by: Edson on March 13, 2015, 06:47:48 pm
Excelent @Alextp. It looks very advanced. Did you consider to implement the Column Mode Edition?
Title: Re: (todo) Plan to make new SynEdit
Post by: Alextp on March 13, 2015, 07:33:28 pm
I did.Click, then click other line with Ctrl+Shift. Column mode
Title: Re: (todo) Plan to make new SynEdit
Post by: aradeonas on March 13, 2015, 07:47:46 pm
Cool! I like Column mode (it seems cool) but never understand what its usage!
Title: Re: (todo) Plan to make new SynEdit
Post by: Edson on March 13, 2015, 07:56:13 pm
OK, It works. I was using Ctrl+Shift+Down/Up.
Title: Re: (todo) Plan to make new SynEdit
Post by: Alextp on March 13, 2015, 08:01:54 pm
More wishes not now; ltr, selection(ALL carets) not done yet
Title: Re: (todo) Plan to make new SynEdit
Post by: Alextp on March 16, 2015, 12:16:45 pm
Made last days: a) editing commands for all multi-carets (type char, delete, bksp, del-line, enter....)
b) bookmark system (already in demo u see it: click gutter at edge)
c) hilite of current line (or lines for carets), and current column (caret 0)
d) hiliting of changed-lines on gutter (3pix line: yellow, green, blue)
Title: Re: (todo) Plan to make new SynEdit
Post by: Martin_fr on March 16, 2015, 12:55:12 pm
Cool! I like Column mode (it seems cool) but never understand what its usage!

Column mode = multi caret mode ?

In 1.5 SynEdit/the IDE have this too. (shift-ctrl-left mouse button or keyboard)
Title: Re: (todo) Plan to make new SynEdit
Post by: Alextp on March 16, 2015, 01:03:57 pm
Ye: column mode is multi-carets, name used in Notepad++
Title: Re: Making new SynEdit
Post by: Alextp on March 20, 2015, 09:11:11 pm
1st post--URL added to repo; added Cut/Copy/Paste support and Ctrl+A, see "demo_editor"..
Title: Re: Making new SynEdit
Post by: Alextp on March 21, 2015, 02:09:13 am
@Martin F

Do u think it's ok way: build column-selection(Alt-Drag) ABOVE
existing multi-carets. All programs: column-sel is new thing ,where
editor draws column block and handles it as column. Why not: don't
make new thing but use existing multicarets for this-- just make N carets
for all lines of block and make selections for them? it will look like old approach.
Less code. No need to make new code for AltDrag and utilize old
Title: Re: Making new SynEdit
Post by: Martin_fr on March 21, 2015, 02:31:01 am
This is really probably a personal decisions. I dont know how different editors handle different selections.

AFAIK:
Multiple selections (such as you propose) are copied to the clipboard, by joining them with a new line (though I really do not know if that always applies).
Thus when pasted, I would expect them to insert new lines.

Column mode selection, is copied in a special mode, that, if pasted inserts into existing lines. They do not insert new lines.

But I do not know how many editors do this.
Title: Re: Making new SynEdit
Post by: Alextp on March 21, 2015, 02:44:14 am
It seems such copy/paste breaks that idea. I dont want to paste incorrect, so i stay with usual idea.. 
I've done mul-selections: make selections with Ctrl+Drag
Title: Re: Making new SynEdit
Post by: Alextp on March 26, 2015, 07:11:01 pm

Code: [Select]
procedure TATSynEdit.UpdateScrollbarVert;
var
  si: TScrollInfo;
begin
  FillChar(si{%H-}, SizeOf(si), 0);
  si.cbSize:= SizeOf(si);
  si.fMask:= SIF_ALL;// or SIF_DISABLENOSCROLL; //todo -- DisableNoScroll doesnt work(Win)
  si.nMin:= FScrollVert.NMin;
  si.nMax:= FScrollVert.NMax;
  si.nPage:= FScrollVert.NPage;
  si.nPos:= FScrollVert.NPos;
  SetScrollInfo(Handle, SB_VERT, si, True);
end;


problem. If i uncomment 'or SIF_DISABLENOSCROLL' then I expect that scroll won't hide but will be shown on small text. it's ok - Linux, it's broken- Win32, on Win i see scroll hidden !

What to do on Win?
Title: Re: Making new SynEdit
Post by: Martin_fr on March 26, 2015, 08:13:16 pm
It works in SynEdit (at least win), the flag is set, and the scrollbar is shown disabled if needed. (and if SynEdit is set to do so)
Title: Re: Making new SynEdit
Post by: Alextp on March 29, 2015, 12:34:01 am
how to group Undo items, via "Group undo" option? e.g. I type text, then Enter, then move-caret, then type again... and what are groups of undo?
Title: Re: Making new SynEdit
Post by: Martin_fr on March 29, 2015, 12:44:14 am
In SynEdit items are grouped if:

- they have the same command: both ecChar, or both ecNewLine, or both ecDeleteWordLeft ...
- the caret start pos, of the 2nd item is the caret end pos of the 1st

But there could be different rules, for example, instead of checking the caret pos, one could check, that no other action (e.g. caret move) happened in between.

I have no idea how other editors do this.
Title: Re: Making new SynEdit
Post by: Alextp on March 29, 2015, 01:21:33 am
Thank; it's good, group if caret not moved(key or mouse cmds), it;s ok
Title: Re: Making new SynEdit
Post by: Alextp on March 31, 2015, 12:17:21 am
Delphi or some ide, has featire-- undo jumps to last change,only next undo undoes this change.
Synedit has it?
Title: Re: Making new SynEdit
Post by: Martin_fr on March 31, 2015, 12:36:56 am
No.

But thanks for explaining it. I had never been able to figure out the logic, about what Delphi actually does on undo.

Now I at leas get it, thanks to your post.

Easy to implement though, but no priority.
Title: Re: Making new SynEdit
Post by: Alextp on March 31, 2015, 03:57:58 am
@Martin
so many empty lines in your msg...  %)

Made Undo
Title: Re: Making new SynEdit
Post by: Alextp on April 03, 2015, 01:56:54 am
I need copying/pastin of Col Blocks into clp (Alt+drag). I don't know how to copy col block/
how to get "text is col block" on paste. Help me?
Title: Re: Making new SynEdit
Post by: Martin_fr on April 03, 2015, 02:06:36 am
I am not aware of any "standard" how the *extra* info is stored in the clipboard. SynEdit invents its own.

That is, 2 parts a copied.
1) the text, normal format for any text editor.
2) the extra info (i.e. a flag, that this is column mode data)

for 2 clipboard has AddFormat(). etc..

Code: [Select]
  SYNEDIT_CLIPBOARD_FORMAT_TAGGED = 'Application/X-Laz-SynEdit-Tagged';

The same is used to keep folds in copy and paste.

SO column mode works only synedit to synedit. Other editors only see the text.


Title: Re: Making new SynEdit
Post by: Alextp on April 03, 2015, 02:13:25 am
thank. I ll see SE code how to.
Btw, maybe interesting to u: i made ColBlock as mul-selections (as I wrote before), with flag "we have rect [x1,y1,x2,y2]" (flag is used if needed to copy)
Title: Re: Making new SynEdit
Post by: Alextp on April 04, 2015, 11:29:55 pm
I make "Move sel up-down", "insert empty ln up-down". If Synedit has not these, pls add
Title: Re: Making new SynEdit
Post by: Martin_fr on April 04, 2015, 11:54:16 pm
Sounds like a misnomer? It does not actually move the selection (if only part of a line is selected)
It moves the lines with the selection.

You can add it to mantis as feature request. but it will probably be low priority.
This belongs to the things, that in the IDE you can do by recording/writing macros.

Same as things like: Add selection to existing clipboard (something that iirc emacs does)
Title: Re: Making ATSynEdit
Post by: Alextp on June 05, 2015, 03:31:52 pm
Martin F,
what style of borders for each token is needed? token "aaaa" may have 4 borders (u/d/l/r),
borders have what styles:

solid line
dot line
....and?

SynEdit gives color for each border? (left green, right red..)

Title: Re: Making ATSynEdit
Post by: Martin_fr on June 05, 2015, 03:49:42 pm
Your choice...

Currently SynEdit only has one border color. But that is not a technical restriction, just the amount of properties needed.
 
The EditorOptions in the IDE can give ypou some ideas.

Or see TSynHighlighterAttributesModifier in components\synedit\synedithighlighter.pp and base classes for "Frame..."
FrameEdges should be replaced/extended by a set, instead of an enum



Maybe more important, if you support overlapping frames:
 
Code: [Select]
[ AAAA ( BBB ] CCCC )
"BBB" has both frames, of course the top and bottom will only be from one frame (unless there is an alpha channel).

But the right/left borders should all 4 be present.
Title: Re: Making ATSynEdit
Post by: Alextp on June 08, 2015, 03:51:56 pm
I post prevw images for C# and Css:

Title: Re: Making ATSynEdit
Post by: Alextp on June 09, 2015, 04:27:58 am
Pict on Linux/ tokens hiliting
Title: Re: Making ATSynEdit
Post by: Alextp on June 09, 2015, 10:50:31 pm
Like Rad studio

TinyPortal © 2005-2018