Hi List,
A couple of questions and comments for you here.
I really can't know why my new ML submissions are not taken into account -
while my reply to a msg coming from the ML is accepted
Do I have to put some tag word like [REBOL] in the subject line or whatever
else ?
Any idea ?
Thanks!
Gerard
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Below is the original content I previously tried to submit a couple of times
to the ML
============================================================
I also want to take some time to explain what exploration I did about the
way the R2 View Editor works and how I could get a hook
to alter some part of its keymapping to get my CTRL+Right or CTRL+Left work
as under Win, that is move from a word to the
beginning of the next or the previous one.
For the benefit of any newcomer,I also wanted to comment the way I did my
search (with tips taken from REBOL.COM)
See below and please add your own observations, comments and/or suggestions,
Thanks,
Gerard
----------------------------------------------------------------------------------------------------------------------------------------------------------------
While I looked at the source of the R2/View editor (with >> source editor),
I found there was a ctx-edit/view-file launched somewhere.
Looking further to see if I could get a hook to include some enhancements to
the way the Editor reacts to my keyboard mapping,
I never found a way to do that. May be there exists but I can't get further.
Some help or explanation is needed for me to step further in my exploration.
However I would like to share with other newcomers how I got more details
about the way I found some details about the
internal workings of the Editor, even if I stalled at a level that is not
too deep ...
>From the REBOL documentation I found that with a combination of simple
instructions I could get the details of the
ctx-edit object and its view-file function (or method) I later discovered
See the code below : I tried to keep the comments to a minimum that I hope
can nevertheless be useful to others.
Sorry for the lengthy process - Any suggestion to help me not overbooking
the ML in the future with lenghty content is welcome.
Here is what I would like to have for starters.
New learners need a single place to share our experiments and quickly find
what others did in the past.
The rebol.org and the ML seem the better place to me - Am I right to think
so ?
May be some form of a public "Learning REBOL wiki" exchange could be useful
too, could it not ?
Eventually more and more places open and it becomes hard to gather all this
useful information from so many sources.
It's a luck for us that Google is of some help but there could be a simpler
way to index or concentrate all of this movement ...
I know there is the AltMe and the R3 chat but thay are not quickly available
from the Web.
In fact I follow more easily Carl S. submissions from Twitter than from the
R3 chat - even if the details are not available there.
When I need to get them then I go to the chat.
I thought that some easy wiki mechanism could be added to the REBOL.ORGengine.
So everything to help newcomers about learning REBOL from the official
source could be kept together in a single place
May be only pointers are required for follow-ups but may be something else
is needed to act as a leverage tool !
Thanks for listening and any suggestion to help solve this puzzle...
Gerard
=========================================================================
Let's return to my Editor's code exploration
Here is my code.
;=====================================================================
; Small tests to see how the Rebol/View embedded editor is functioning
;=====================================================================
>> source editor
editor: func [file /app app-word /local tmp][
either link? [
if block? ctx-edit [
ctx-edit: context either all [
value? 'fileset-files?
tmp: fileset-files? 'desktop
find tmp %desktop/edit.r
tmp: load/header link-root/desktop/edit.r
] [next tmp] [ctx-edit]
]
either app [ctx-edit/view-file/app file app-word]
[ctx-edit/view-file file]
] [
either exists? tmp: view-root/desktop/scripts/edit.r [do/args tmp
file] [
if block? ctx-edit [ctx-edit: context ctx-edit]
ctx-edit/view-file file
]
]
]
;================================================================================
; Then I tried to isolate the part that was really running when I manually
start the Editor
; Here is how I proceeded - manually tracing by inserting some instructions
; for printing, pausing and stopping.
;================================================================================
old-editor: :editor ;<--- First get
a safe copy of the
editor: func [file /app app-word /local tmp][ ; original editor
source content
either link? [ ; then
edit my own copy of the editor
if block? ctx-edit [ ; code
before launching more tests
ctx-edit: context either all [
value? 'fileset-files?
tmp: fileset-files? 'desktop
find tmp %desktop/edit.r
tmp: load/header link-root/desktop/edit.r
] [print "MK-1" next tmp ] [print "MK-2" ctx-edit] ; <---
some prints inserted here and there
]
either app [print "MK-3" ctx-edit/view-file/app file app-word]
[print "MK-4" ctx-edit/view-file file]
] [
either exists? tmp: view-root/desktop/scripts/edit.r [print "MK-5"
do/args tmp file] [
if block? ctx-edit [print "MK-6" ctx-edit: context ctx-edit]
print "MK-7"
probe ctx-edit ; <--- tried some more
experiments below to discover that it is
ask "Suite ?" ; the last line
that really executes in my situation !
print "OK" ; Before finding
this, I had a good time trying to see
ctx-edit/view-file "" ; where do come
from the link-root/desktop/...
halt ; finally I
had to suggest myself that this situation
ctx-edit/view-file ; is probably
taken into account when the editor is running
] ; from a
connected mode (but can't say more)
]
]
>> editor: :old-editor ; <-- After my
exploration, better to put back the original Editor code
>> ctx-edit/view-file "" ; <-- manual launch of the
editor to see if it really is similar to a normal
; start-up of
the editor when the >> editor "" command is used.
>> type? ctx-edit ; <-- test the nature of
this ctx-edit (normally ctx- is used to mean a context
== object! ; and a context is
done with an object!
>> probe first ctx-edit ; <-- Here are the
components of this ctx-edit object!
[self prefs dirty-edit this-file this-app t1 s1 h1 f1 edit-prefs ed-lo
save-lo ff fb fc fp find-lo
resize refresh save-prefs open-as new-file save-as save-file up-file
open-file
result ask-save save-edit do-file quit-edit quit-now caret start last-str
last-case
last-pat find-text search find-str find-again find-next find' scroll-to
show-help help-text
keymap scroll-edit init form-title view-file]
;================================================================================
; As a personal test, I tried to find every word beginning with the letter
"k"
; got some problems since "k" is diff from a char
; finally I found a way to do it - maybe better or shorter ways exist.
;================================================================================
>> foreach item first ctx-edit [if (to-char "k") == to-char first to-string
item [probe item]]
keymap
;================================================================================
; May be I could edit this table - but I don't know what to do when the key
is detected :(
;================================================================================
>> probe ctx-edit/keymap
[
#"^S" [save-file]
#"^W" [quit-edit]
#"^Q" [quit-edit]
#"^O" [open-as]
#"^N" [new-file]
#"^E" [do-file]
#"^F" [find-text]
#"^G" [find-again]
F3 [find-text]
F5 [do-file]
page-up [scroll-edit true -1]
page-down [scroll-edit true 1]
]
;===============================
; Let's explore further ...
;===============================
>> probe ctx-edit/view-file ; <---
Oups! view-file seems to be evaluated.
** Script Error: view-file is missing its file argument ; Let's see if
it is a function ?
** Where: halt-view
** Near: probe ctx-edit/view-file
>> type? get in ctx-edit 'view-file ; <--- Yes
it really is a function waiting
== function! ;
for a file parameter.
>> probe get in ctx-edit 'view-file ; <--- Get
the contents in a safe - non evaluated - way!
func [file /app app-word][ ;
similar to using the 'source function
if not save-edit [exit] ;
but going directly at the real Source
if app [this-app: app-word] ; that
is from the object's content itself
t1/text: none
t1/line-list: none
if not viewed? ed-lo [
if exists? prefs [edit-prefs: make edit-prefs load/all prefs]
t1/para/wrap?: edit-prefs/wrap
ed-lo/offset: edit-prefs/offset
if outside? system/view/screen-face/size ed-lo/offset + 20x20 [
ed-lo/offset: 40x40
save-prefs
]
resize edit-prefs/size
ed-lo/text: form-title file
view/new/options ed-lo [resize]
init
center-face/with find-lo ed-lo
if not overlap? find-lo system/view/screen-face [find-lo/offset:
ed-lo/offset + 20]
]
open-file file
if 1 = length? system/view/screen-face/pane [do-events]
]
;=======================================================================================
; Also looked under the edit-prefs and the associated file containing
; the user-prefs but nothing useful was found there.
; May be the ed-lo or some other part of the ctx-edit object
; contains the required code to modify but I am no more able to do this and
go further
;=======================================================================================
;=======================================================================================
; Below is a snippet taken from the REBOL web site
; This is how we can redirect the output of some mezzanine function to
another destination
; Here the new print-str function is a modified copy of the old 'print
source code
; that's what inspired me to learn how to replace the original Editor
content with mine.
;=======================================================================================
output: make string! 1000
print-str: func third :print [
repend output [reform :value newline]
]
; End of the current exploration
; Nothing is really new here but having all the pieces together in the same
place is good.
; It's similar to getting access to the cooking section of the rebol.comsite
; but it deserves to be an interactive zome for discussion about such
recipes - like the ML or AltMe
--
Gérard Côté
Québec, Canada
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.