
Ce document est un didacticiel concernant le support AppleScript de l'Žditeur de ressources Rezilla pour MacOSX. Il explique, au moyen d'exemples, comment piloter Rezilla en Žcrivant des scripts dans le langage AppleScript. Il suppose que le lecteur est dŽjˆ familier avec les principes de base de ce langage. Le prŽsent document correspond ˆ la version 1.1 de Rezilla.
Un support complet de scriptabilitŽ dans le langage AppleScript a ŽtŽ introduit dans Rezilla ˆ partir de la version 1.0.5b. AppleScript est le langage de scripts d'Apple pour l'automatisation des opŽrations et le contr™le externe des applications. Rezilla dŽfinit un ensemble de commandes et de classes afin de manipuler facilement les fichiers de ressources: elles permettent de simuler la plupart des actions dŽfinies par l'application, c'est-ˆ-dire des commandes disponibles dans les divers menus.
Toutes les commandes expliquŽes dans ce tutoriel doivent tre adressŽes ˆ l'application au moyen des instructions tell habituelles, comme par exemple:
tell application "Rezilla" -- ici viennent les commandes... end tell
Dans la suite de ce document, nous ne rŽpŽterons pas ˆ chaque exemple, pour des raisons de lisibilitŽ, le bloc tell complet mais il est toujours implicite.
On peut ouvrir des fichiers de ressources au moyen de la commande open.
Pour ouvrir un fichier de ressources nommŽ somefile.rsrc et situŽ dans le dossier HD:foo:bar:, on utilisera l'instruction suivante:
open "HD:foo:bar:somefile.rsrc" as aliasDe mme, pour sŽlectionner un fichier de ressources et l'ouvrir dans Rezilla, il suffit d'Žcrire:
set theFile to {choose file}
open theFile as alias
Il y a deux paramtres optionnels avec la commande open:
open "HD:foo:bar:somefile.rsrc" as alias with readOnly
open "HD:foo:bar:somefile.rsrc" as alias from data forkLes valeurs possibles pour le paramtre from sont data fork, resource fork, ou any fork (qui est la valeur par dŽfaut).
open "HD:foo:bar:file_with_no_fork_at_all" as alias with createFork
Une table de ressources peut tre refermŽe au moyen de la commande close. L'argument optionnel saving, permettant de prŽciser si le document doit tre sauvegardŽ avant d'tre refermŽ, est acceptŽ (ses valeurs possibles sont yes, no ou ask). Par exemple:
close first map document saving no
Les modifications faites dans un document de ressources peuvent tre sauvegardŽes directement au moyen de la commande save. Deux paramtres supplŽmentaires sont dŽfinis:
save document 1 in "HD:foo:bar:otherMap.rsrc" as resource fork
Il est aussi possible d'abandonner des modifications faites dans la table de ressources et de revenir ˆ la dernire version sauvegardŽe en utilisant la commande revert comme ceci:
revert map document 1
On crŽe une nouvelle table de ressources vide au moyen de la commande make. Cette commande accepte trois paramtres. Les deux premiers sont obligatoires, l'autre est optionnel:
Voici un exemple complet:
-- ask the Finder to make the folder object
tell application "Finder"
set theFolder to folder "HD:foo:bar:" as alias
end tell
-- create the new map document in this folder
make new map document in theFolder with properties Â
{name:"newmap.rsrc",fork:data fork,readOnly:true}
On notera que le dossier contenant le nouveau document de ressources doit
tre dŽclarŽ dans un bloc
tell adressŽ au Finder et non pas ˆ Rezilla. Cela provient du fait
que le terme folder fait partie du vocabulaire du Finder et non
pas de celui de Rezilla.Il y a essentiellement trois types d'objets dans Rezilla: les documents, les fentres et les tables de ressources. Le terme de table est utilisŽ pour dŽsigner le contenu entier d'une branche de ressources.
Chaque table peut tre considŽrŽe comme une base de donnŽes dont les ŽlŽments sont caractŽrisŽs par un type et un numŽro d'identification. Le modle d'objets de Rezilla utilise une reprŽsentation analogue: une table est un objet qui contient des objets type, et ces objets type eux-mmes contiennent des objets ressource . Un objet table abstrait est toujours associŽ dans Rezilla ˆ un document de ressources.
Il y a deux sortes de documents:
Par exemple, on peut obtenir dans un script AppleScript la liste de toutes les fentres, toutes les tables ou tous les documents avec une commande comme ceci (le terme get est ici facultatif):
get windows get maps get documents
Outre les propriŽtŽs partagŽes par tous les objets de la classe documents (voir plus loin), les documents de ressources possdent un ensemble de propriŽtŽs spŽcifiques:
Par exemple, le script suivant permet de rŽcupŽrer les valeurs de ces propriŽtŽs:
set mapDoc to map document 1
set a to the name of mapDoc
set b to the refnum of mapDoc
set c to the fork of mapDoc
set d to the index of mapDoc
set e to the readOnly of mapDoc
set f to the window of mapDoc
set g to the file of mapDoc
set h to the format of mapDoc
{a, b, c, d, e, f, g, h}La propriŽtŽ format peut tre modifiŽe au moyen de la commande set. Les autres sont des propriŽtŽs en lecture seulement. Par exemple:
set the format of map document 1 to html
Par exemple, le script suivant permet de rŽcupŽrer les valeurs de ces propriŽtŽs (en supposant qu'un Žditeur est effectivement ouvert):
set theEd to editor 1 of map document 1
set a to the index of theEd
set b to the kind of theEd
set c to the readOnly of theEd
set d to the window of theEd
set e to the resource of theEd
set f to the owner doc of theEd
{a, b, c, d, e, f}Toutes ces propriŽtŽs sont des propriŽtŽs en lecture seulement. Elles ne peuvent tre modifiŽes au moyen de la commande set.
On pourra obtenir ces valeurs comme ceci:
set mapWin to map window 1
set a to the types count of mapWin
set b to the resources count of mapWin
{a, b}
Ce sont des propriŽtŽs en lecture seulement. Par exemple:
set editWin to editing window 1 get the kind of editWinC'est une propriŽtŽ en lecture seulement.
Par commoditŽ, il est possible de dŽsigner les fentres d'Ždition directement comme des ŽlŽments d'un document principal. Ainsi, les raccourcis suivants sont autorisŽs:
get editing window 1 of map document 1au lieu de
get window of editor 1 of map document 1De mme
get hexadecimal window 1 of map document 1est Žquivalent ˆ
get window of hexadecimal editor 1 of map document 1Il en va de mme si l'on dŽsigne les fentres d'Ždition par nom plut™t que par indice:
get editing window "name_of_window" of map document 1au lieu de
get window of editor "name_of_window" of map document 1De mme
get template window "name_of_window" of map document 1est Žquivalent ˆ
get window of template editor "name_of_window" of map document 1
get map of map document 1pourrait renvoyer quelque chose comme ceci:
map id 22 of application "Rezilla"
La table pourrait alors tre invoquŽe par la suite dans un script au moyen de l'expression map id 22. Le numŽro d'identification est unique.
Les tables de ressources ont les propriŽtŽs suivantes:
Voici un exemple de script pour rŽcupŽrer les propriŽtŽs d'une table de ressources:
set theMap to the map of map document 1
set a to the refnum of theMap
set b to the attributes of theMap
set c to the readOnly of theMap
set d to the compact of theMap
set e to the changed of theMap
{a, b, c, d, e}
Une table est elle-mme un contenant: les objets qu'elle contient sont les
types, comme nous le verrons ˆ la prochaine section. Pour obtenir la liste de tous les types contenus dans la table, on Žcrira:
set theMap to the map of map document 1 get all types of theMap
Les propriŽtŽs attributes, readOnly, compact et changed peuvent tre modifiŽes au moyen de la commande set. Les autres sont des propriŽtŽs en lecture seulement. Par exemple:
set theMap to map document 1 -- 160 is mapReadOnly _and_ mapChanged (128 + 32) set the attributes of theMap to 160 -- This unsets the mapReadOnly flag (-128) set the readOnly of theMap to 0 -- This sets the mapCompact flag (+64) set the compact of theMap to 1 -- This unsets the mapChanged flag (-32) set the changed of theMap to 0
Les propriŽtŽs suivantes sont dŽfinies:
Voici un exemple de script pour rŽcupŽrer les propriŽtŽs d'un type dans une table de ressources:
set theType to type "TEXT" of map 1
set a to the index of theType
set b to the name of theType
{a, b}
Pour obtenir la liste de toutes les ressources appartenant ˆ un type
particulier, on Žcrira par exemple:
set theType to type "TEXT" of map 1 get all IDs of theType
Toutes ces propriŽtŽs sont des propriŽtŽs en lecture seulement. Elles ne peuvent tre modifiŽes au moyen de la commande set.
Une ressource ˆ l'intŽrieur d'un objet type peut tre spŽcifiŽe par indice, par nom ou par identificateur (ID). La spŽcification par identificateur est unique. Une ressource peut aussi tre dŽsignŽe directement dans une table de ressources en utilisant une paire constituŽe de son type et de son identificateur, comme par exemple:
resource {"TEXT", 128} of map id 22
On notera qu'il est aussi possible faire rŽfŽrence ˆ une ressource comme s'il s'agissait d'un ŽlŽment d'un document de ressources directement plut™t qu'un ŽlŽment de la table abritŽe par ce document. Il s'agit d'un raccourci commode qui permet d'Žcrire des expressions comme:
resource {"TEXT", 128} of theDoc
au lieu de
resource {"TEXT", 128} of the map of theDoc
Les diverses propriŽtŽs d'une ressource sont les suivantes:
Voici un exemple de script pour rŽcupŽrer certaines de ces valeurs:
set therez to resource {"TEXT", 128} of map id 22
set a to the name of therez
set b to the ID of therez
set c to the changed of therez
set d to the size of therez
set e to the sizeOnDisc of therez
set f to the attributes of therez
set g to the system heap of therez
set h to the purgeable of therez
set i to the locked of therez
set j to the preload of therez
set k to the protected of therez
{a, b, c, d, e, f, g, h, i, j, k}Les propriŽtŽs name, attributes, sysHeap, purgeable, locked, preload, protected, changed, sizeOnDisc et hex data peuvent tre modifiŽes au moyen de la commande set. Les autres sont des propriŽtŽs en lecture seulement. Par exemple:
set theRez to resource {"MENU", 128} of map document 1
set the name of theRez to "Apple menu"
-- 12 is resProtected _and_ resPreload (8 + 4):
set the attributes of theRez to 12
-- This unsets the resProtected flag:
set the protected of theRez to 0
-- This sets the resPurgeable flag:
set the purgeable of theRez to 1
-- This unsets the resLocked flag:
set the locked of theRez to 1
-- This sets the resChanged flag:
set the changed of theRez to 1
-- Modifiy the size on disc (use at your own risk):
set the sizeOnDisc of theRez to 512Les donnŽes de la ressource peuvent tre obtenues au moyen de la propriŽtŽ hex data, comme ceci:
set theRez to resource {"ALRT", 128} of map 1
get the hex data of theRez
Le rŽsultat est renvoyŽ sous forme hexadŽcimale, comme par exemple:
"002800280096019000805555300a"
La commande set peut tre utilisŽe pour installer des donnŽes diffŽrentes dans la ressource. Par exemple:
set theRez to resource {"ALRT", 128} of map 1
set the hex data of therez to "001400140087016800805555300a"On notera deux exceptions importantes concernant la reprŽsentation hexadŽcimale des donnŽes d'une ressource. Elles concernent les ressources de type TEXT et les ressources de type STR#. Dans ce cas, Rezilla utilise une reprŽsentation textuelle:
get hex data of resource {"TEXT", 128} of map 1
renverrait Viva Rezilla au lieu de l'Žquivalent hexadŽcimal
566976612052657a696c6c61.La rŽciproque est vraie. Pour fixer la valeur d'une ressource TEXT ou STR#, on utilisera la syntaxe suivante:
-- simple string
set txtRez to resource {"TEXT", 128} of map 1
set the hex data of txtRez to "Viva Rezilla!!!"
-- list of strings
set strRez to resource {"STR#", 128} of map 1
set the hex data of strRez to {"Viva Rezilla!!!", "Rezilla is great!!!"}Voici quelques exemples:
edit resource {"MENU", 128} of map 1 using interface edit resource {"MENU", 128} of map 1 using template
edit resource {"MENU", 128} of map 1 using hexadecimal
edit resource {"aeut", 128} of map 1 as "aete"
Les autres actions d'Ždition de base sont la duplication et la suppression d'une ressource dans la table de ressources. Elles sont accomplies par les commandes duplicate et delete respectivement.
duplicate resource {"MENU", 128} of map 1 delete resource {"STR#", 128} of map 1
La commande delete permet aussi de supprimer toutes les ressources d'un certain type simultanŽment, comme ceci:
delete type "MENU" of map 1
Les modifications faites dans un Žditeur peuvent tre sauvegardŽes en utilisant la commande save:
save first editor of map document 1On notera que les arguments usuels in et as de la commande save sont ignorŽs dans ce cas (car elles n'ont pas de sens dans ce contexte).
Un document d'Ždition peut tre refermŽ par la commande close, comme ceci:
close first editor of map document 1ou, de manire Žquivalente, en refermant la fentre directement:
set thewin to window of first editor of map document 1 close thewin
Certains Žditeurs (mais malheureusement pas tous) comprennent la commande revert. Cela concerne l'Žditeur de gabarits, l'Žditeur de ressources de terminologie (aete) et l'Žditeur de menus. Par exemple:
revert editor "somefile.rsrc - 'MENU' #128" of document 1
Les fentres hexadŽcimales associŽes ˆ l'Žditeur hexadŽcimal possdent quelques propriŽtŽs qui peuvent servir ˆ modifier le contenu d'une ressource directement dans les panneaux de ces fentres. Les propriŽtŽs sont les suivantes:
Voici un exemple de script pour rŽcupŽrer ces propriŽtŽs:
edit resource {"TEXT",128} of map document 1 using hexadecimal
set theWin to hexadecimal window 1 of map document 1
set a to the startPos of theWin
set b to the endPos of theWin
set c to the maxPos of theWin
set d to the hex selection of theWin
set e to the text selection of theWin
{a, b, c, d, e}La propriŽtŽ maxPos est en lecture seule. Toutes les autres propriŽtŽs peuvent tre modifiŽes au moyen de la commande set. Voici un court exemple:
set theWin to hexadecimal window 1 of map document 1 set the startPos of win to 6 set the endPos of win to 9 set the hex selection of win to "52657a696c6c61"
Dans cet exemple, les octets situŽs entre les positions spŽcifŽes seront remplacŽs par les octets correspondant ˆ la cha”ne hexadŽcimale. On aurait pu, de manire analogue, effectuer le remplacement dans le panneau texte au moyen d'une instruction comme ceci:
set the text selection of theWin to "Rezilla"Pour simplement supprimer des octets, il suffit de spŽcifier une cha”ne vide.
On peut crŽer une nouvelle ressource vide dans un document de ressources au moyen de la commande make. Cette commande accepte quatre paramtres. Les deux premiers sont obligatoires, les autres sont optionnels:
Voici un exemple complet:
set theDoc to map document 1
-- create an empty 'MENU' resource
make new resource in theDoc with properties {type:"MENU"}
-- create an 'ALRT' resource with ID 128
make new resource in theDoc with properties Â
{ID:128, type:"ALRT", name:"An alert", protected:true} Â
with data "001400140087016800805555300a"
-- create a 'TEXT' resource with the specified string
-- ('TEXT' is the default when no type is specified)
make new resource in theDoc with data "Hello Rezilla"Si aucun identificateur (ID) n'est spŽcifiŽ, Rezilla attribue un identificateur unique. Si l'identificateur est spŽcifiŽ mais qu'il existe dŽjˆ une ressource ayant ce numŽro, la crŽation de la nouvelle ressource Žchouera: Rezilla prŽserve ainsi les ressources dŽjˆ existantes. Si aucun type n'est spŽcifiŽ, Rezilla crŽera une ressource TEXT par dŽfaut.
L'objet racine situŽ au-dessus de tous les objets de Rezilla est l'application elle-mme. Rezilla dŽfinit des propriŽts de base pour les classes document et fentre, propriŽtŽs dont tous les objets plus spŽcifiques (comme les Žditeurs ou les fentres des tables de ressources par exemple) hŽritent ˆ leur tour.
Cette section dŽcrit les propriŽtŽs des classes application, document et window.
L'application elle-mme peut fournir quelques informations. Elle possde une propriŽtŽ version qui renvoie le numŽro de version courant. Par exemple:
get the version
La fentre d'inspection est aussi une propriŽtŽ de l'application mais elle est considŽrŽe plut™t comme un objet ˆ part entire. Ses propriŽtŽs sont expliquŽes dans la section Fentre d'inspection ci-dessous.
Rezilla dŽfinit les propriŽtŽs communes suivantes dont hŽritent toutes les classes de documents (documents de ressources, documents d'Ždition):
Voici un exemple de script pour rŽcupŽrer ces propriŽtŽs dans le cas de diffŽrents types de documents:
set theDoc to map document 1
set a to the name of theDoc
set b to the modified of theDoc
edit resource {"TEXT", 128} of theDoc
set theEditor to editor 1 of theDoc
set c to the name of theEditor
set d to the modified of theEditor
{a, b, c, d}Ce sont des propriŽtŽs en lecture seulement. Elles ne peuvent tre modifiŽes au moyen de la commande set.
Toutes les fentres de Rezilla (tables, fentres d'Ždition, fentre d'inspection, etc.) partagent l'ensemble de propriŽtŽs suivant:
Voici un exemple de code illustrant ces propriŽtŽs:
set win2 to the second window set a to the name of win2 set b to the bounds of win2 set c to the position of win2 set d to the visible of win2 set e to the closeable of win2 set f to the titled of win2 set g to the resizable of win2 set h to the zoomed of win2 (a, b, c, d, e, f, g, h)
Les propriŽtŽs name, bounds, zoomed, visible et position peuvent tre modifiŽes au moyen de la commande set. Les autres sont des propriŽtŽs en lecture seulement.
-- windows count set a to count windows set b to count map windows set c to count editing windows set d to count hexadecimal windows set e to count template windows set f to count interface windows -- documents count set g to count documents set h to count map documents set i to count editors set j to count hexadecimal editors set k to count template editors set l to count interface editors{a, b, c, d, e, f, g, h, i, j, k , l}
On peut aussi dŽnombrer les tables, les types et les ressources. Par exemple:
set a to count maps set b to count types of map 1 set c to count resources of type "TEXT" of map 1{a, b, c}
La commande exists permet de vŽrifier si un objet est connu de Rezilla. Voici quelques exemples:
first window exists
exists second window
exists third window
exists map of document 1
set theMap to map 1
exists theMap
exists type "TEXT" of theMap
exists type "XYZT" of theMap
set theType to type "TEXT" of map 1
exists resource id 128 of theType
exists resource "Vivat" of theType
exists resource id 128 of type "MENU" of map 1
exists resource {"MENU", 128} of map document 1
exists hexadecimal editor 1
exists template editor 1
exists interface editor 1
exists editing window 1
exists hexadecimal window 1
exists template window 1
exists interface window 1
exists window of document 1
exists editor 1 of document 1
exists second editor of document 1
exists window of first editor of document 1
exists inspectorLa fentre d'inspection est toujours prŽsente dans Rezilla (mme si elle n'est pas affichŽe, elle reste prŽsente en coulisse). Pour afficher l'information concernant une ressource particulire, on utilise la commande inspect comme ceci:
inspect resource {"MENU", 128} of map 1
Cette commande affiche la fentre d'inspection qui contient toute
l'information relative ˆ la
ressource spŽcifiŽe. Chaque champ de la fentre d'inspection est
accessible gr‰ce aux propriŽtŽs de la fentre d'inspection:
set a to the ID field of the inspector set b to the name field of the inspector set c to the system heap of the inspector set d to the purgeable of the inspector set e to the locked of the inspector set f to the preload of the inspector set g to the protected of the inspector (a, b, c, d, e, f, g)
Les champs du numŽro d'identification et du nom, de mme que toutes les cases ˆ cocher peuvent tre modifiŽs au moyen de la commande set data . Par exemple:
set the name field of inspector to "Viva Rezilla!!!" set the ID field of inspector to 130 set the system heap of inspector to false set the purgeable of inspector to true set the locked of inspector to true set the preload of inspector to false set the protected of inspector to true
La propriŽtŽ current resource renvoie une rŽfŽrence ˆ la ressource affichŽe par la fentre d'inspection ce qui permet d'Žcrire des instructions comme :
get the hex data of the current resource of the inspector
Il faut cependant distinguer les propriŽtŽs rŽelles d'une ressource de ce qui peut tre affichŽ dans la fentre d'inspection. Si des modifications on ŽtŽ effectuŽes dans l'inspecteur, elles ne seront validŽes dans la ressource elle-mme que lorsque le bouton Apply aura ŽtŽ pressŽ. Dans un script AppleScript, on utilisera la commande save afin de valider le contenu de la fentre d'inspection, comme ceci:
save the inspectorEn revanche, si des modifications ont ŽtŽ faites dans la fentre d'inspection et qu'on ne souhaite pas les conserver, on utilisera la commande revert pour revenir aux dernires valeurs sauvegardŽes, comme ceci:
revert the inspector
Pour masquer la fentre d'inspection, on utilise la commande close:
close the inspectorDe manire Žquivalente, on peut utiliser l'une des commandes suivantes:
close inspector window 1ou
set the visible of the inspector to falsePour rendre la fentre d'inspection visible, on peut utiliser la commande inspect comme expliquŽ prŽcedemment ou invoquer l'instruction suivante:
set the visible of the inspector to true
On peut effectuer une comparison entre deux tables de ressources (dŽsignŽes respectivement, dans ce qui suit, comme l'ancienne et la nouvelle) gr‰ce ˆ la commande compare. Il faut spŽcifier en argument les deux fichiers contenant les tables ˆ comparer. La commande accepte trois paramtres boolŽens optionnels permettant de spŽcifier les critres de comparison :
Cette commande renvoie un objet de comparison dont les propriŽtŽs indiquent quelles ressources diffrent ou sont identiques entre les tables de ressources. On peut obtenir les propriŽtŽs suivantes ˆ partir du rŽsultat:
Voici un exemple complet:
set theComp to compare "HD:foo:bar:file1" as alias  and "HD:foo:bar:file2" as alias  with ignoreName without ignoreAttrs -- get information out of the result get the old only resources of theComp get the new only resources of theComp get the differing resources of theComp get the identical resources of theComp -- get the criteria get the criteria of theComp
La commande export correspond ˆ l'article de menu Export du menu Fichier (File) de Rezilla. Elle permet de gŽnŽrer un export d'une table de ressources dans divers formats. Cette commande accepte deux paramtres:
export map document 1 in "HD:foo:bar:" as alias Â
with properties {name:"exportedMap.xml", format:xml}La commande AppleScript import correspond ˆ l'article de menu Import du menu File de Rezilla. Elle permet d'importer une table de ressources depuis un fichier XML conforme ˆ la DTD de Rezilla (Rezilla.dtd). C'est le cas des fichiers gŽnŽrŽs par la commande Export en format XML. Cette commande import accepte deux paramtres:
set theFile to (choose file) import map document 1 from theFile
Depuis la version 1.1, Rezilla supporte l'addition d'Žditeurs externes dŽfinis au moyen d'extensions (ou plugins). La terminologie AppleScript comporte un nouveau terme plugin permettant d'obtenir des informations sur les extensions couramment disponibles.
Les objets plugin appartiennent directement ˆ l'objet application. On peut les dŽsigner par nom ou par indice. Voici quelques instructions AppleScript simples:
get name of plugins
count plugins
Les objets plugin possdent les propriŽtŽs suivantes:
Toutes ces propriŽtŽs sont en lecture seule: elles ne peuvent tre modifiŽes au moyen de la commande set. Voici quelques instructions simples pour obtenir les informations sur un plugin:
set a to name of plugin 1
set b to version of plugin 1
set c to typecode of plugin 1
set d to creator of plugin 1
set e to loaded of plugin 1
{a, b, c, d, e}
Pour obtenir la liste des types supportŽs:
get supported types of plugin "RezImagePlugin.plugin"
Dans le cas o plusieurs plugins supportent un mme type de ressource, Rezilla permet de spŽcifier le plugin ˆ utiliser de prŽfŽrence pour Žditer une ressource de ce type. Ce choix peut tre rŽglŽ dans l'application dans le panneau Plugin Order du dialogue affichŽ lorsqu'on invoque la commande Plugins... du menu File. On peut aussi le contr™ler par une instruction AppleScript. Il y a une propriŽtŽ de l'application appelŽe preferred plugins ˆ cet effet: elle renvoie un dictionnaire dont les clŽs sont les types de ressources et les valeurs sont, pour chaque type, le nom du plugin prŽfŽrŽ associŽ. Par exemple, le script suivant:
get preferred pluginsrenvoie des informations telles que
{JPEG:"RezImagePlugin.plugin", PStr:"RezSamplePlugin.plugin", etc.}
Cette propriŽtŽ peut tre modifiŽe avec la commande set afin de dŽsigner un autre plugin de prŽdilection pour certains types (le rŽglage ne se fait pas nŽcessairement pour tous les types ˆ la fois). Ceci n'a de sens que pour les types supportŽs par plusieurs plugins. Par exemple:
-- Assume the 'jpg ' and 'tiff' resource types can be edited by several
-- plugins and you want Rezilla to use the RezImagePlugin plugin for them
set preferred plugin to {Çclass tiffÈ:"RezImagePlugin.plugin", Çclass jpg È:"RezImagePlugin.plugin"}
Le plugin doit par ailleurs exister effectivement pour que cette opŽration
rŽussisse.Les sŽlectionneurs de ressources (resource pickers, introduits dans la version 1.1) ont les propriŽtŽs suivantes:
Les sŽlectionneurs, en tant qu'objets, sont des ŽlŽments appartenant aux tables de ressources (map document). Ils peuvent tre dŽsignŽs par type (c'est le type qui tient lieu de nom) ou par indice. Par exemple, on peut Žcrire:
set thePik to picker "icl8" of map document 1
Le script suivant permet de rŽcupŽrer toutes les valeurs des propriŽtŽs d'un sŽlectionneur:
set thePik to picker 1 of map document 1 set a to the name of thePik set b to the index of thePik set c to the readOnly of thePik set d to the window of thePik set e to the type of thePik set f to the owner doc of thePik set g to the selection of thePik{a, b, c, d, e, f, g}
Seule la propriŽtŽ selection peut tre modifiŽe au moyen de la commande set. Toutes les autres sont en lecture seule. Le numŽro de la ressource ˆ sŽlectionner doit tre passŽ sous forme de cha”ne. Par exemple:
set the selection of picker 1 of map document 1 to "128"
Pour retirer la sŽlection, il suffit de passer une cha”ne vide dans la
propriŽtŽ selection, comme ceci:
set the selection of picker 1 of map document 1 to ""
Un sŽlectionneur peut tre ouvert au moyen de la commande pick comme ceci:
pick type "cicn" of map 1Si un sŽlectionneur est effectivement dŽfini pour le type spŽcifiŽ, la commande renvoie un spŽcificateur pour l'objet nouvellement crŽŽ.
Pour refermer un sŽlectionneur, on utilise la commande close comme ceci:
close picker "cicn" of map document 1
Caveat: la commande pick s'applique aux types (objets type), qui sont des ŽlŽments des objets map (tables de ressources) et non pas des objets map document. D'un autre c™tŽ, les sŽlectionneurs sont des ŽlŽments d'un objet map document et non pas d'un objet map. On doit donc faire scrupuleusement la distinction entre map et map document, comme dans le code suivant:
pick type "TEXT" of map 1 count pickers of map document 1 close picker "TEXT" of map document 1
Voici, pour la rŽfŽrence, la description formelle complte du dictionnaire de terminologie de Rezilla, telle que la rapporte (en anglais) l'application ƒditeur de Scripts.
Required Suite: Terms that every application should supportopen: Open the specified object(s) open reference -- Objects to open. Can be a list of files or an object specifier. [from data fork/resource fork/any fork/same fork] -- restrict to a particular fork (default is anyFork) [readOnly boolean] -- specify if the file should be opened in read-only mode (by default it is not) [createFork boolean] -- specify if a resource fork should be created when the file does not have any resource fork already (by default it is not)
quit: Quit the application quit
Standard Suite: Common terms for most applications
Class application: the application Elements: window by numeric index, by name, as a range of elements document by numeric index, by name map document by numeric index, by name map by ID plugin by numeric index, by name Properties: name international text [r/o] -- Rezilla's name version international text [r/o] -- the version of the application inspector inspector window [r/o] -- the inspector preferred plugin record -- the preferred plugin for each supported type: the property is a record whose keys are the types and the values are the plugin names.
Class document: A document Plural form: documents Properties: name international text [r/o] -- the title of the document modified boolean [r/o] -- Has the document been modified since the last save?
Class window: a window Plural form: windows Properties: name international text -- the title of the window index integer [r/o] -- the number of the window bounds bounding rectangle -- the boundary rectangle for the window closeable boolean [r/o] -- does the window have a close box? titled boolean [r/o] -- does the window have a title bar? floating boolean [r/o] -- does the window float? modal boolean [r/o] -- is the window modal? resizable boolean [r/o] -- is the window resizable? zoomable boolean [r/o] -- is the window zoomable? zoomed boolean -- is the window zoomed? visible boolean -- is the window visible? position point -- upper left coordinates of window
close: Close an object close reference -- the objects to close [saving yes/no/ask] -- specifies whether or not changes should be saved before closing
count: Return the number of elements of a particular class within an object count reference -- the object whose elements are to be counted each type class -- the class of the elements to be counted Result: integer -- the number of elements
data size: Return the size in bytes of an object data size reference -- the object whose data size is to be returned Result: integer -- the size of the object in bytes
exists: Verify if an object exists exists Result: boolean -- true if it exists, false if not
get: Get the data for an object get reference -- the object whose data is to be returned Result: anything -- The data from the object
make: Make a new element make new type class -- the class of the new element in reference -- the container in which to create the new element (it must already exist) [with properties record] -- properties of the element (for instance 'name', 'readOnly', 'fork') [with data anything] -- the initial data for the new element Result: reference -- Object specifier for the new element
revert: Revert an object to the most recently saved version revert reference -- object to revert
save: save an object save reference -- object to save [in alias] -- the file in which to save the object [as data fork/resource fork/any fork/same fork] -- the fork in which to save the data (in a Save As operation)
set: Set an object's data set reference -- the object to change to anything -- the new value
Rezilla suite: Rezilla specifics
Class comparison window: a maps comparison window Plural form: comparison windows Properties: inherits window [r/o] -- all properties of the 'window' class result comparison [r/o] -- a comparison result object
Class editing window: a resource editing window (hexadecimal, template or interface) Plural form: editing windows Properties: inherits window [r/o] -- all properties of the 'window' class kind interface/plugin/template/hexadecimal [r/o] -- the kind of the editing window (hexadecimal, template, plugin or interface)
Class editor: an editor document for a single resource Plural form: editors Properties: inherits document [r/o] -- all properties of the 'document' class index integer [r/o] -- the number of the document kind interface/plugin/template/hexadecimal [r/o] -- the kind of editor document (hexadecimal, template, plugin or interface) readOnly boolean [r/o] -- is this document read-only? window window [r/o] -- the window of the document. resource resource [r/o] -- the resource edited by this document owner doc map document [r/o] -- the rezmap document that owns this editor document
Class hexadecimal editor: a hexadecimal document editing a resource Plural form: hexadecimal editors Properties: inherits editor [r/o] -- all properties of the 'editor' class
Class hexadecimal window: a hexadecimal editing window Plural form: hexadecimal windows Properties: inherits editing window [r/o] -- all properties of the 'editing window' class maxPos integer [r/o] -- index of last position (i-e position after the last character) startPos integer -- position of beginning of selection endPos integer -- position of end of selection hex selection international text -- the contents of the selected region in the hex pane text selection international text -- the contents of the selected region in the text pane
Class inspector window: the inspector window Properties: inherits window [r/o] -- all properties of the 'window' class ID field small integer -- the value of the 'ID' field name field international text -- the value of the 'name' field system heap boolean -- the value of the 'System Heap' checkbox purgeable boolean -- the value of the 'Purgeable' checkbox locked boolean -- the value of the 'Locked' checkbox preload boolean -- the value of the 'Preload' checkbox protected boolean -- the value of the 'Protected' checkbox current resource resource [r/o] -- the resource for which info is currently displayed
Class interface editor: a dedicated interface document editing a resource Plural form: interface editors Properties: inherits editor [r/o] -- all properties of the 'editor' class
Class interface window: an interface editing window Plural form: interface windows Properties: inherits editing window [r/o] -- all properties of the 'editing window' class
Class map document: a resource map document (representing the contents of an entire fork) Plural form: map documents Elements: editor by numeric index, by name picker by numeric index, by name Properties: inherits document [r/o] -- all properties of the 'document' class index integer [r/o] -- the number of the document among other map documents readOnly boolean [r/o] -- is this document read-only? window window [r/o] -- the window of the document. refnum small integer [r/o] -- the reference number of the map in memory fork DataFork/ResourceFork/UnknownFork [r/o] -- the fork this document is editing (data fork or resource fork) map map [r/o] -- the resource map associated with this document file file specification [r/o] -- the file on disk corresponding to this resource map document format unknown export/xml/html/text/DeRez -- the format used for export
Class map window: a resource map window Plural form: map windows Properties: inherits window [r/o] -- all properties of the 'window' class types count integer [r/o] -- number of types in this map as displayed at the bottom of the map window resources count integer [r/o] -- total number of resources in this map as displayed at the bottom of the map window
Class picker: a picker document for a given type Plural form: pickers Properties: name international text [r/o] -- the name of the picker: this is the name of the associated type index integer [r/o] -- the index of the picker readOnly boolean [r/o] -- is this picker read-only? window window [r/o] -- the window of the picker type type [r/o] -- the type of the resources displayed by this picker owner doc map document [r/o] -- the rezmap document that owns this picker selection international text -- the ID of the selected resource (use an empty string to remove the selection)
Class picker window: a picker window Plural form: picker windows Properties: inherits window [r/o] -- all properties of the window class
Class plugin: a plugin object Plural form: plugins Properties: name international text [r/o] -- the name of the plugin index integer [r/o] -- the index of the plugin version international text [r/o] -- the version of the plugin typecode string [r/o] -- the type code of the plugin creator string [r/o] -- the creator code of the plugin loaded boolean [r/o] -- is the plugin loaded? supported types a list of list [r/o] -- the list of types supported by the plugin
Class plugin editor: a plugin document editing a resource Plural form: plugin editors Properties: inherits editor [r/o] -- all properties of the 'editor' class
Class plugin window: a plugin editing window Plural form: plugin windows Properties: inherits editing window [r/o] -- all properties of the 'editing window' class
Class template editor: a template document editing a resource Plural form: template editors Properties: inherits editor [r/o] -- all properties of the 'editor' class
Class template window: a template editing window Plural form: template windows Properties: inherits editing window [r/o] -- all properties of the 'editing window' class
compare: compare two resource maps compare alias -- first resource file for comparison and alias -- second resource file for comparison [ignoreName boolean] -- ignore name differences [ignoreAttrs boolean] -- ignore attributes differences [ignoreData boolean] -- ignore data differences Result: comparison -- a maps comparison object
delete: Delete the specified object delete reference -- the object to delete
duplicate: Duplicate a resource in the resource map. The duplicate is automatically attributed an unique ID. duplicate reference -- the object to duplicate Result: reference -- a specifier for the duplicated resource(s)
edit: edit one or more resources edit resource -- resource to edit [using interface/plugin/template/hexadecimal] -- specifies which kind of editor to use (if not specified, Rezilla tries to find successively an interface, a template or the hexadecimal editor) [like type class] -- use an another type's editor
export: export a rezmap document in a specified format export map document -- resource map document to export in alias -- the folder in which to save the export file. This folder must already exist. [with properties record] -- the initial values for the properties (essentially to specify a name and a format)
import: import a rezmap document from an XML file import map document -- the map document into which to import the data. This must be an empty document. from alias -- the XML file to import. It must be conform to the Rezilla DTD.
inspect: display info about the specified resource in the Inspector window inspect resource -- Resource object to display info about.
pick: open a picker pick type -- type of the resources to display in a picker [Result: picker] -- an object specifier for the picker
Resource suite: Resource maps handling
Class comparison: the result of a comparison between two maps Properties: criteria record [r/o] -- the comparison criteria ignoreName boolean [r/o] -- have name differences been ignored? ignoreAttrs boolean [r/o] -- have attributes differences been ignored? ignoreData boolean [r/o] -- have data differences been ignored? old only resources a list of list [r/o] -- the list of resources which are only in the old map new only resources a list of list [r/o] -- the list of resources which are only in the new map differing resources a list of list [r/o] -- the list of resources which exist in both maps and are different identical resources a list of list [r/o] -- the list of resources which exist in both maps and are identical
Class map: a resource map Plural form: maps Elements: type by numeric index, by name, by ID Properties: refnum small integer [r/o] -- the reference number of the map in memory all types list [r/o] -- the list of all types (in alphabetical order) attributes small integer -- the global value of the map attributes (sum of the individual flags) readOnly boolean -- the mapReadOnly bit compact boolean -- the mapCompact bit changed boolean -- the mapChanged bit
Class resource: a single resource with specific type and ID Plural form: resources Properties: name international text -- the resource's name typename string [r/o] -- the type of the resource as text ID small integer [r/o] -- the ID of the resource index integer [r/o] -- the index of the resource within its type (in the order used by the resource manager) attributes small integer -- the global value of the resource attributes (sum of the individual flags) sysHeap boolean -- the resSysHeap bit purgeable boolean -- the resPurgeable bit locked boolean -- the resLocked bit preload boolean -- the resPreload bit protected boolean -- the resProtected bit changed boolean -- the resChanged bit size integer [r/o] -- the size of the resource data (in bytes) sizeOnDisc integer [r/o] -- the size of the resource on disk hex data anything -- the resource data (in hex format)
Class specifier: a two-elements list containing the type and the ID of a resource
Class type: a resource type Plural form: types Elements: resource by name, by ID, by numeric index Properties: index integer [r/o] -- the index of the type in the document (types are ordered alphabetically) name international text [r/o] -- the type's name ID unsigned integer [r/o] -- a type as a long unsigned integer all IDs list [r/o] -- the list of all IDs of resources belonging to this type
Last updated 2006-11-01 15:24:42