AkelPad Forum Index AkelPad
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Some questions and suggestions

 
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (English)
View previous topic :: View next topic  
Author Message
tmsg



Joined: 21 Aug 2012
Posts: 42
Location: UK

PostPosted: Thu Aug 23, 2012 10:22 am    Post subject: Some questions and suggestions Reply with quote

(Warning: looong post ahead.)

I have used a pretty old 3.x version of Akelpad for quite a while now, as a quick and simple editor. Most of my "heavy-duty" editing has been done with UltraEdit. Unfortunately, UE is getting ever more bloated and slower; what's more I'm experiencing some significant usability issues. So I have been looking into other text editors and, to my surprise, found that the lastest version of AP, plus a few plugins, could do almost everything I need (not least it has now regex support!).

However, there remain a few open points and questions. I am sure some of these can be implemented with the help of scripts; for others, more experienced users may have found a solution or have a hint. Others, I suspect, would need some changes in AP. Anyway, here goes:

    1. It would be great if copy and cut operations could be made to work on the current line (including its line terminator) if there's currently no selection.
    2. Sometimes I am editing program code and sometimes prose. For source code files (*.h;*.c etc) I'd prefer word wrap to be off; for all other uses I'd like it to be on. So it would be great if the wordwrap option could be automatically set according to filetype. I suspect there may be other attributes which also depend on the filetype.
    3. In the same vein, a command line option for AP as to which ini file to load would be a great help. (Currently I have copied and patched the AP .EXE file, so the original version still loads AKELPAD.INI and the patched one loads AKELADV.INI. Needless to say, this is not a satisfactory solution.) An added complication here is that plugins tend to have their own INI files, so perhaps the best long term approach may be to have two or more copies of AP installed?
    4. I'd like to see the ability to edit column selections, ie adding a string or numbers to a column block. I think there are a couple of scripts around to approximate that, but I haven't looked into them yet.
    5. Window positions for the Find and Replace dialogs are stored and reused within a single program run but reset once AP is restarted. It'd be nice if AP would remember those between invocations (as it thankfully does for many other dialog windows).
    6. If I want to edit, say all *.H files in a directory, I can't just type "akelpad *.h". Adding a wildcard ability to the command line would be another great helper.
    7. Similarly, I have tools to produce lists of files to be edited; a command line option to enable AP to read such a file and open all files in the list would be nice (many tools accept a "@filename" notion for this: "akelpad @filelist" would open all files in filelist).
    8. Replace within a selection doesn't work correctly because the selection is reset after the first Find/Replace. This behaviour is no big deal if I want to replace every X in the selection with a Z but it does become a real problem if I want to replace just some X's in the selection with Z's.
    9. I am using the Sessions plugin to reload the files open on exit (the "OnExit" options in the Sessions settings). This works fine; however I only want to actually reload the OnExit session files if no file is given on the AP command line (ie AP is started without a filename to open).


I'd be grateful for comments or help with any of these issues. Also, I'd like to thank Instructor for all the work he has put into AP!

TM
Back to top
View user's profile Send private message
Fr0sT



Joined: 24 Jul 2007
Posts: 876

PostPosted: Thu Aug 23, 2012 1:29 pm    Post subject: Reply with quote

1 - script
2 - script only currently; seem quite useful though
3 - only two copies for now
4 - alt+select, alt+v for vertical paste, space/shift-space fot moving selected block
5 -
6, 7 - seem useful
8 - yeah, that's apparently a bug.
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1441
Location: Poland

PostPosted: Thu Aug 23, 2012 8:07 pm    Post subject: Reply with quote

tmsg
1:
For copy you can use the script LinesSelectCopyMoveDuplicate.js
4:
Scripts:
ColumnsReplace.js presentation: http://akelpad.sourceforge.net/forum/viewtopic.php?p=9480&highlight=columnsreplace#9480
InsertTextLN.js
Back to top
View user's profile Send private message
tmsg



Joined: 21 Aug 2012
Posts: 42
Location: UK

PostPosted: Fri Aug 24, 2012 12:33 pm    Post subject: Reply with quote

Folks, THX for the feedback. Yesterday eve, I threw together a quick'n'dirty script for #1 (first AP script, so if I do something stupid, please tell me!):
Code:
// copySelOrLine.js
// Call with `Call("Scripts::Main",1,"copySelOrLine.js","0x300")` to cut
// Call with `Call("Scripts::Main",1,"copySelOrLine.js","0x301")` to copy
var hwndEdit=AkelPad.GetEditWnd();
if (!hwndEdit) WScript.Quit();
if (AkelPad.GetSelStart()==AkelPad.GetSelEnd()) {
  var nLine=AkelPad.SendMessage(hwndEdit,0x00C9 /*EM_LINEFROMCHAR*/,-1,0);
  var nS=AkelPad.SendMessage(hwndEdit,0x00BB /*EM_LINEINDEX*/,nLine,0);
  var nE=AkelPad.SendMessage(hwndEdit,0x00BB /*EM_LINEINDEX*/,nLine+1,0);
  AkelPad.SetSel(nS,nE);
}
if (AkelPad.GetSelStart()==AkelPad.GetSelEnd()) WScript.Quit();
if (WScript.Arguments.length==1) AkelPad.SendMessage(hwndEdit,parseInt(WScript.Arguments(0)),0,0);

I will also look into the other things indicated as scriptable.

For #2 and #6 and #7, is there a mechanism to run a script automatically when a file is opened/closed or when the focus switches from one tab to another? If not, adding such "auto-event scripts" would be another suggestion (EDIT: for inclusion in a future version of AP).

Fr0sT wrote:
4 - alt+select, alt+v for vertical paste, space/shift-space fot moving selected block

A misunderstanding: I do know how column selections work. What I want is to be able to define a column block and then add text or numbers to it. I have found KDJ's script (InsertTextLN.js, thanks for that). This is doing an approximation of what I want to do but using it is a bit cumbersome.

I've also found a solution for #9, with a command line alias for Take Command (the CLI I am using). So not too bad so far.

Alas, #8 and #5 are still bugging me.

TM
Back to top
View user's profile Send private message
FeyFre



Joined: 07 Aug 2007
Posts: 2061
Location: Vinnitsa, Ukraine

PostPosted: Fri Aug 24, 2012 6:45 pm    Post subject: Reply with quote

Quote:
For #2 and #6 and #7, is there a mechanism to run a script automatically when a file is opened/closed or when the focus switches from one tab to another? If not, adding such "auto-event scripts" would be another suggestion (EDIT: for inclusion in a future version of AP).
Yes and No. I mean, there is no direct obvious mechanism but it is possible, by next algorithm:
1. Script should be running already, and should run in background mode(there are some such scripts, You can distinct them by presence of "AkelPad.ScriptNoMutext()" in source.
2. This script must hook main window(i.e. provided function will be called for each message of this window).
3. Mentioned above function must process AKDN_FRAME_ACTIVATE - this message means some tab is activated. Here You can do whatever You want.

About "auto-event scripts": it is possible to do in current version. Now You know scripts can run on background. So one of such scripts can "listen for all events" and start other scripts when needed.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5524

PostPosted: Sat Aug 25, 2012 7:11 am    Post subject: Reply with quote

tmsg
tmsg wrote:
1. ...(first AP script, so if I do something stupid, please tell me!)...
Good start.
tmsg wrote:
2. ... For source code files (*.h;*.c etc) I'd prefer word wrap to be off; for all other uses I'd like it to be on...
See AutoScript-Sample2.js.
tmsg wrote:
6. If I want to edit, say all *.H files in a directory, I can't just type "akelpad *.h"...
I prefer use file manager to select/search files and open them in AkelPad with Drag'n'Drop.
tmsg wrote:
7. ...open all files in the list would be nice...
OpenFileList.js
Back to top
View user's profile Send private message Send e-mail
tmsg



Joined: 21 Aug 2012
Posts: 42
Location: UK

PostPosted: Sat Aug 25, 2012 11:30 am    Post subject: Reply with quote

FeyFre wrote:
Yes and No. I mean, there is no direct obvious mechanism but it is possible, by next algorithm:
<rest skipped>

I see how that works (this seems to be the method used in the script mentioned in the next post by Instructor).

However, I think that a simpler, formal mechanism for these (and other) events would be a good idea for some future version of AP. There are all sorts of things one can do with text files once there are auto_open, auto_save and auto_close events.

But that's not my current concern though I'd very much like to see some further development along those lines.

Instructor wrote:

tmsg wrote:
2. ... For source code files (*.h;*.c etc) I'd prefer word wrap to be off; for all other uses I'd like it to be on...
See AutoScript-Sample2.js.

I've not yet checked the details but this seems to be a solution to that problem. The script looks a bit "hackish" if you know what I mean but if it works I'm not going to complain;-)
Instructor wrote:
tmsg wrote:
6. If I want to edit, say all *.H files in a directory, I can't just type "akelpad *.h"...
I prefer use file manager to select/search files and open them in AkelPad with Drag'n'Drop.

Well, I positively avoid all sorts of file managers as much as I can. I do almost everything via my trusty command line processor and I have defined loads of aliases and helpers to simplify life.
So unfortunately, that hint, though valid, is not going to help me much.
Instructor wrote:
tmsg wrote:
7. ...open all files in the list would be nice...
OpenFileList.js

I'll check that one as well. The downside with such script-based solutions (vs a native capability of AP) is that the command line alias I use to start AP gets ever more complex and unwieldy... until it gets too hard to handle;-(.

But I'll give it a try. And if all else fails, I could have a look into the AP sources.

This still leaves my points #5 (saving the Find/Replace window positions) and #8 (Replacing within a selection). Do you think there's anything you could do there?

Anyway, so far things look not too bad. I think AP is flexible enough to deal with most problems I might face. And it's blazing fast which I like.

So THX for all the hints already provided.

TM
Back to top
View user's profile Send private message
tmsg



Joined: 21 Aug 2012
Posts: 42
Location: UK

PostPosted: Fri Aug 31, 2012 12:44 pm    Post subject: Reply with quote

A progress report (well, sort of...) and a couple more questions.

From my original 9 items, I have found script solutions for #1, #2 and #4. For #7 and #9 there are workable solutions which involve command line magic and a script.

For #3 and #5 I have had to patch AkelPad.c/Edit.c and the .rc file. #6 will need some more patching but I've postponed that.

I think #8 is a bug which will probably survive me;-)

I have written or adapted quite a few scripts now and there are two issues for which I have found no further information in the docs and the forum. I often write editor scripts which are triggered by a hotkey and then read a single character from the console to determine what exactly to do.

Example: I want to write a script to terminate an AP session; let's say this is triggered by Alt+X. Depending on the next character pressed (one of w, x, q) the script should either write all files and terminate ('w') or terminate w/o saving anything ('x') or ask for any changed file whether to save it or not ('q', the current default when terminating).

So far, the only method I've found to read the keyboard from a script is AkelPad.InputBox(). That's OK if I want to get a full string but I want to read only a single character and I do not want to press <enter> either. Any idea how to do that?

The second issue is that I've found no script method to terminate AP when files have been changed w/o asking whether those files should be saved (the option 'x' from above). To make that clear: I want to be able to terminate AP w/o saving any changed files and w/o any query, just exit.

THX for any further hints from the script gurus.

TM
Back to top
View user's profile Send private message
FeyFre



Joined: 07 Aug 2007
Posts: 2061
Location: Vinnitsa, Ukraine

PostPosted: Fri Aug 31, 2012 12:51 pm    Post subject: Reply with quote

Quote:
The second issue is that I've found no script method to terminate AP when files have been changed w/o asking whether those files should be saved (the option 'x' from above). To make that clear: I want to be able to terminate AP w/o saving any changed files and w/o any query, just exit.
Do AkelPad.SendMessage(AkelPad().GetMainWnd(), AKD_SETMODIFY, hwnd, 0); for each hwnd - which is handle of modified(non-saved) edit window.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Fr0sT



Joined: 24 Jul 2007
Posts: 876

PostPosted: Fri Aug 31, 2012 2:52 pm    Post subject: Reply with quote

tmsg
you may easily create your own trivial WinAPI window (just an empty area with a hint label) and implement its WindowProc thus catching any input you wish. Just catch and process WM_KEY.
Back to top
View user's profile Send private message
tmsg



Joined: 21 Aug 2012
Posts: 42
Location: UK

PostPosted: Sat Sep 01, 2012 10:19 am    Post subject: Reply with quote

FeyFre wrote:
Do AkelPad.SendMessage(AkelPad().GetMainWnd(), AKD_SETMODIFY, hwnd, 0); for each hwnd - which is handle of modified(non-saved) edit window.

Great, searching the forum for AKD_SETMODIFY did the trick!
Fr0sT wrote:
you may easily create your own trivial WinAPI window (just an empty area with a hint label) and implement its WindowProc thus catching any input you wish. Just catch and process WM_KEY.

Hm... that's a rather big cannon for a tiny bird;-). I was hoping for some built-in solution. Well... I'll have a look.

A further question for those who compile AP from the sources: the batch files for that use the MS C compiler switch /O1 (optimize for size). I'd rather prefer speed over size, so I am compiling with /O2 and so far, AP seems to work fine. Are there any known negative side effects to the /O2 switch?

Thanks again TM
Back to top
View user's profile Send private message
Fr0sT



Joined: 24 Jul 2007
Posts: 876

PostPosted: Mon Sep 03, 2012 6:13 am    Post subject: Reply with quote

tmsg
nothing big, you can check any script creating a dialog window and copy just some of the code you need
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (English) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SourceForge.net Logo Powered by phpBB © 2001, 2005 phpBB Group