|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
DanRRight
Joined: 10 Mar 2008 Posts: 2852 Location: South Pole, Antarctica
|
Posted: Sat Jan 06, 2024 8:52 pm Post subject: Saturday exercise: Adding Editor |
|
|
This is Clearwin Editor. Very convenient to edit your initial file or do any minor repetitive editions with just one click on a button. Works with my larger codes like a charm. Also i have the Viewer but it is more complex while this one is essentially just one line of Fortran code with %eb. But in my codes i complicated it adding some more niceties and now can not scale it back to use in some additional code.
Because today is effing Saturday my saturday devilry harasses me to the extreme (it already started day with one of my harddrives not functioning - never happened for the last 20 years) I can not make it to start with already opened initial file (suppose it is called a.a) no matter what i do. Tried 3 different variants, none displays the file from start, i need to start the dialog, find the file and open it...you lose any sense to use this shortcut/improvement. This improvement is already not an improvement for me, i spent on it so much time that in 10 lives would not spend without it just using usual editors via just few more steps....
Here is simplest version. Anyone? Recommend to use it for everyone if you succeed, you will not regret
Code: | WINAPP
CHARACTER*129 file,new_file
INTEGER i,win
i=winio@('%ca[Editor]&')
i=winio@('%mn[&File[&Open]]&','EDIT_FILE_OPEN','a.a',file)
i=winio@('%mn[[&Save]]&','EDIT_FILE_SAVE','*.*',new_file)
i=winio@('%mn[[Save &As]]&','EDIT_FILE_SAVE_AS','*.*',new_file)
i=winio@('%mn[[|]]&')
i=winio@('%mn[[E&xit]]&','EXIT')
i=winio@('%mn[&Edit[&Copy]]&','COPY')
i=winio@('%mn[[&Paste]]&','PASTE')
i=winio@('%sy[3d_depressed,thin_border]&')
i=winio@('%ww%sf%pv%30.10eb[hscrollbar,vscrollbar]&','*',0)
i=winio@('%es')
END |
Last edited by DanRRight on Sun Jan 07, 2024 4:32 pm; edited 2 times in total |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2578 Location: Sydney
|
Posted: Sun Jan 07, 2024 2:06 am Post subject: |
|
|
Hi Dan,
Thanks for the example.
Not sure what Saturday devilry you are referring to ?
Copied into PLATO and Start.
Managed to open a file, by typing first few characters of name, ignoring your a.a recomendation.
Modifying file by typing or deleting text; also works ok.
Built the program in PLATO; edited dan_edit.f90; saved changes and then saw updated version appear in PLATO window. Works well.
Did not manage to achieve "any minor repetitive editions with just one click on a button"
or understand how to use copy / paste.
Would be good if <ctl>H, <ctl>c, <ctl>v and <ctl>x worked, but not sure how to enable. I expect I should RTFM.
NOTEPAD also works ok for this ( although have not tried ctl characters, which can be a deficiency.
Thanks for the devilry update, but not sure what is wrong ?
All the best for 2024
John |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2852 Location: South Pole, Antarctica
|
Posted: Sun Jan 07, 2024 3:39 am Post subject: |
|
|
Hope you and all here had nice holidays. I as usually was busy, because holidays are the best time when supercomputers are less busy. Not this season though, unfortunately...Seriously thinking how create my own right now cores ~300-500. Remote computers are not that convenient anyway as the one near you
Seems i was not clear:
- After you have file a.a in directory,
- and created EXE file,
- you just click on EXE file and a.a file have to be immediately displayed without any other movements or clicks
Right now when you click on EXE no a.a displayed on the screen and you need further actions which makes this approach useless |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2578 Location: Sydney
|
Posted: Sun Jan 07, 2024 5:22 am Post subject: |
|
|
Dan,
Is it possible to provide an enhanced example for %eb where the edit menu provides the following functions, plus access via accelerator keys :
find Ctrl+F
replace Ctrl+H
cut Ctrl+X
copy Ctrl+C
paste Ctrl+V
The example lists COPY and PASTE, but a more enhanced example would be interesting !
An indication of what is or is not easy to achieve would help. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8003 Location: Salford, UK
|
Posted: Sun Jan 07, 2024 10:29 am Post subject: |
|
|
I can see sample code like this in FTN95.chm but it uses '*.*' as the "filter".
The fllter could be "*.f90" if you wanted to open and save Fortran files with that extension. The use of 'a.a' in this context is a mistake.
The original sample code in the help file illustrates how to create a simple editor like Notepad.
You could add code so that a given file was opened at startup but you can't use the filter for this purpose. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2852 Location: South Pole, Antarctica
|
Posted: Sun Jan 07, 2024 3:14 pm Post subject: |
|
|
Yea, the trick was that the darn thing i was missing was hidden in absolutely different place from the main text of the Editor. It was in the main GUI menu in completely different file! The editor can not open anything by itself and the literally few symbols which open needed file are so rarely used that you will never find them after ones used it (in my case inside Main program:.... 'edit_file', Init_File).
All works in two steps: first, your click just opens Editbox %eb and leaves it open with %lw. Then the next command from the same menu ^mn or button %bt like below will run the command 'edit_file' with the filename you supply, no need to transfer this name to the source of the Editor.
Here is the code with some more tricks i use. Use your favorite fonts - Linux Monospace, Tahoma, Courier_New, Terminal etc., text sizes, backgrounds and confirm_exits. I also use %pm which can be added if someone plan to use this handy Editor tool often. And you can use Paul's suggestion with *.* instead of "a.a" which i use because this is narrow-purpose Editor where i specifically avoid to search for anything in the directories with sometimes a quarter million of files
Code: | WINAPP
character*256 :: Init_File='a.a'
integer, external :: Edit_cb
i=winio@('%^bt[Edit InitFile]%es','+', Edit_cb, 'edit_file', Init_File)
end
!= = = = = = = = = = = = = = = = = = = = = = = = = =
integer function Edit_cb()
CHARACTER*256 initfile, new_file, open_filename
INTEGER i, ilw
open_filename = '*.*'
i=winio@('%ca[Editor]&')
i=winio@('%mn[&File[&Open'//char(9)//'Ctrl+O]]&','EDIT_FILE_OPEN','a.a',initfile)
i=winio@('%mn[[&Save'//char(9)//'Ctrl+S]]&','EDIT_FILE_SAVE','*.*',new_file)
i=winio@('%mn[[Save &As'//char(9)//'Shift+Ctrl+S]]&','EDIT_FILE_SAVE_AS','*.*',new_file)
i=winio@('%mn[[|]]&')
i=winio@('%mn[[E&xit'//char(9)//'Ctrl+X]]&','EXIT')
i=winio@('%mn[&Edit[&Copy'//char(9)//'Ctrl+C]]&','COPY')
i=winio@('%mn[[&Paste'//char(9)//'Ctrl+V]]&','PASTE')
i=WINIO@('%fn[Courier New]%bf%bg&',RGB@(210,230,230) )
i=winio@('%sy[3d_depressed,thin_border]&')
i=winio@('%ww%pv%80.40eb[hscrollbar,vscrollbar,no_border,undo]&','z',0)
i=winio@('%ac[Ctrl+O]&','EDIT_FILE_OPEN',open_filename, initfile)
i=winio@('%ac[Ctrl+S]&','EDIT_FILE_SAVE',open_filename, new_file)
i=winio@('%ac[Alt+S]&','EDIT_FILE_SAVE',open_filename, new_file)
i=winio@('%ac[Shift+Ctrl+S]&','EDIT_FILE_SAVE_AS',open_filename, new_file)
! i = winio@('%ac[Esc]&','confirm_exit','C l o s e Editor ?')
! i = winio@('%ac[Alt+X]&','confirm_exit','C l o s e Editor ?')
i = winio@('%ac[Ctrl+X]&','Cut')
i = winio@('%ac[Ctrl+C]&','Copy')
i = winio@('%ac[Ctrl+V]&','Paste')
i=winio@('%lw%es',ilw)
Edit_cb = 2
END Finction
|
Last edited by DanRRight on Sun Jan 07, 2024 5:46 pm; edited 8 times in total |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2852 Location: South Pole, Antarctica
|
Posted: Sun Jan 07, 2024 3:32 pm Post subject: |
|
|
The %pm part is with Fortran77 formatting, i am lazy to rebuild it, i will always make a mistake. As you see just two short commands which actually do the whole work -- %eb and 'edit_file' -- quickly turn into the holly mess
Code: | i=winio@(
+ '%pm[&File[&Open'//char(9)//'Ctrl+O,'//
+ '&Save'//char(9)//'Ctrl+S,'//
+ 'Save &As'//char(9)//'Shif+Ctrl+S,'//
+ '|,E&xit'//char(9)//'Esc Alt+X],'//
+ '&Edit['//
+ '&Undo'//char(9)//'Ctrl+Z,'//
+ '&Copy'//char(9)//'Ctrl+C,'//
+ 'Cu&t'//char(9)//'Ctrl+X,'//
+ '&Paste'//char(9)//'Ctrl+V],'//
+ '&Help[&Contents,&Help Search]]&',
+ 'EDIT_FILE_OPEN', open_filename, fileToEdit,
+ 'EDIT_FILE_SAVE', open_filename, new_file,
+ 'EDIT_FILE_SAVE_AS',open_filename, new_file,
+ 'EXIT','EDIT_UNDO','COPY','CUT','PASTE',
+ 'HELP_CONTENTS',help_file,'HELP_ON_HELP',help_file)
i = winio@('%pm[[|, Settings ]]&', Edit_FuncSett)
i = winio@('%pm[|,Exit'//char(9)//'Esc Alt+X]&', 'EXIT')
i=WINIO@('%sf&')
i = winio@('%lw[owned]&', lw_ctrl_Edit_func)
i = winio@('%hw', ihw_ctrl_Edit_func)
|
Thanks all for trying and comments. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2852 Location: South Pole, Antarctica
|
Posted: Sun Jan 07, 2024 4:09 pm Post subject: |
|
|
If somebody hates all that mess above, one can add editor of your specific file a.a just with these few lines
Code: |
WINAPP
integer, external :: Editor
i=winio@(' %^tt[Edit input]%es', '+', Editor, 'edit_file', 'a.a')
END
integer*4 function Editor ()
use clrwin
character*256 new_file
i=winio@('%ww[no_border]%fn[Courier New]%bf&')
i=winio@('%mn[File[&Save'//char(9)//'Ctrl+S]]&','EDIT_FILE_SAVE','*.*', new_file)
i=winio@('%pv%80.50eb[vscrollbar,hscrollbar, no_border,undo]%lw%es','*.*',0, ilwEd)
Editor = 2
end function
|
|
|
Back to top |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|