Commit b4a4382a authored by Robert Sprowson's avatar Robert Sprowson

Eliminate need for EditIntern headers

edit.c:
txtar.h and txtoptmenu.h weren't actually needed since none of their definitions were in use.
txtfile.h was being used for a single function which is now implemented in save_one_txt(), sharing code with the panic file save function.
Accept RISC_OS_PLUS switch (circa RISC OS 3.00) is always true now, and delete some experimental code.
Fix bug in panic file saves to Wimp$ScrapDir, the filetype was being derived from bits 20-31 of the load address rather than 8-19. Panic save also changed to use RISC_OSLib style SWI functions rather than _swi and _swix.
message.c:
Take ownership of the task window defines, same as SrcEdit has for some years.

Tested in a RAM install, printing a 2 line BASIC program out.

Version 1.70. Tagged as 'Edit-1_70'
parent 048389da
......@@ -13,5 +13,4 @@
| limitations under the License.
|
Dir <Obey$Dir>
cdir <Install$Dir>.!Edit
amu_machine install INSTDIR=<Obey$Dir>.!Edit
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.69"
Module_Version SETA 169
Module_MajorVersion SETS "1.70"
Module_Version SETA 170
Module_MinorVersion SETS ""
Module_Date SETS "24 Oct 2013"
Module_ApplicationDate SETS "24-Oct-13"
Module_Date SETS "08 Jul 2014"
Module_ApplicationDate SETS "08-Jul-14"
Module_ComponentName SETS "Edit"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Edit"
Module_FullVersion SETS "1.69"
Module_HelpVersion SETS "1.69 (24 Oct 2013)"
Module_FullVersion SETS "1.70"
Module_HelpVersion SETS "1.70 (08 Jul 2014)"
END
/* (1.69)
/* (1.70)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.69
#define Module_MajorVersion_CMHG 1.70
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 24 Oct 2013
#define Module_Date_CMHG 08 Jul 2014
#define Module_MajorVersion "1.69"
#define Module_Version 169
#define Module_MajorVersion "1.70"
#define Module_Version 170
#define Module_MinorVersion ""
#define Module_Date "24 Oct 2013"
#define Module_Date "08 Jul 2014"
#define Module_ApplicationDate "24-Oct-13"
#define Module_ApplicationDate "08-Jul-14"
#define Module_ComponentName "Edit"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Edit"
#define Module_FullVersion "1.69"
#define Module_HelpVersion "1.69 (24 Oct 2013)"
#define Module_LibraryVersionInfo "1:69"
#define Module_FullVersion "1.70"
#define Module_HelpVersion "1.70 (08 Jul 2014)"
#define Module_LibraryVersionInfo "1:70"
......@@ -43,7 +43,6 @@
#define BASIC TRUE
#define PRINT 1
#define RISC_OS_PLUS 1
#define CTL FALSE
/* Not using the ctl module yet. */
......@@ -74,9 +73,7 @@
#include "template.h"
#include "dbox.h"
#include "txt.h"
#include "EditIntern/txtar.h"
#include "txtscrap.h"
#include "EditIntern/txtoptmenu.h"
#include "typdat.h"
#include "txtedit.h"
#include "event.h"
......@@ -86,12 +83,11 @@
#include "dboxquery.h"
#include "editv.h"
#include "baricon.h"
#include "EditIntern/message.h"
#include "taskwin.h"
#include "xferrecv.h"
#include "msgs.h"
#include "visdelay.h"
#include "pointer.h"
#include "EditIntern/txtfile.h"
#if CTL
#include "ctl.h"
......@@ -106,6 +102,8 @@ static menu Edit_Options;
static char filetypebuff[10] = "";
static menu Edit_Menu;
static void save_one_txt(txt, int);
static int cistrcmp(const char *s1, const char *s2)
{
int ch1, ch2;
......@@ -354,7 +352,7 @@ void edit__hot_copy(wimp_eventstr *e, void *handle) {
/* -------- Desktop saving. -------- */
os_error * save_desktop(int handle)
static os_error * save_desktop(int handle)
{
char buffer[300];
char buffer2[256];
......@@ -385,30 +383,6 @@ void arcedit_bkg_events(wimp_eventstr *e, void *handle) {
switch(e->e) {
#if FALSE
case wimp_EKEY:
{
/* werr(FALSE, "hot key: %i %i.\n", e->e, e->data.key.chcode); */
txt t = txtscrap_selectowner();
char chcode = e->data.key.chcode;
if ((chcode == akbd_Fn + 7 || chcode == 3 /*ASCII ^C*/) && t != 0) {
/* werr(FALSE, "hot key - copy selection."); */
if (win_idle_event_claimer() != edit__hotcopy) {
/* ignore if already in operation. Should stack up somehow? */
edit__prev_idle_claimer = win_idle_event_claimer();
win_claim_idle_events(edit__hotcopy);
edit__selptr = 0;
};
} else {
/* >>>> This bit doesn't quite work? It seems that if
noone has the caret the hot keys like F12 get lost if we are around... */
wimpt_noerr(wimp_processkey(chcode));
};
break;
};
#endif
case wimp_ESEND:
case wimp_ESENDWANTACK:
tracef0("it's a message.\n");
......@@ -439,18 +413,6 @@ void arcedit_bkg_events(wimp_eventstr *e, void *handle) {
wimpt_complain(wimp_sendmessage(wimp_EACK, &e->data.msg, e->data.msg.hdr.task));
};
#if FALSE
os_gbpbstr s;
s.action = 2; /* write bytes to current file pointer. */
s.file_handle = e->data.msg.data.words[0];
/* s.file_handle = e->data.savedesk.filehandle; */
s.data_addr = "hello there!\n";
s.number = 13;
werr(0, "save desk request, file handle=%i.\n", s.file_handle);
s.number = (int) wimpt_complain(os_gbpb(&s)); /* discard value, removes compiler warning. */
#endif
}
#if PRINT
......@@ -459,7 +421,7 @@ void arcedit_bkg_events(wimp_eventstr *e, void *handle) {
{
txtedit_state *s = 0;
BOOL newtext = FALSE;
typdat our_ty;
os_regset r;
if (e->data.msg.data.print.type != 0xffb /* not basic */)
return;
......@@ -489,10 +451,20 @@ void arcedit_bkg_events(wimp_eventstr *e, void *handle) {
}
/* --- save to Printer$Temp --- */
our_ty = s->ty;
our_ty.ld |= 0xfff00;
r.r[0] = 0x83; /* Open out, no path */
r.r[1] = (int)"<Printer$Temp>";
if (os_find(&r) == NULL)
{
int h = r.r[0];
save_one_txt(s->t, h);
r.r[0] = 0; /* Close */
r.r[1] = h;
os_find(&r);
os_swix3(OS_File, 18, "<Printer$Temp>", 0xfff);
}
txtfile_saverange(s->t, "<Printer$Temp>", our_ty, 0, INT_MAX);
if (newtext) txtedit_dispose(s);
}
......@@ -605,16 +577,30 @@ static void edit_signal_handler(int signal)
longjmp(SigBuf, signal);
}
static void save_one_txt(txt t, int handle)
{
size_t p = 0;
char *a;
int n;
do
{
/* Not sure where the dot is, so locate each segment in turn */
txt_arrayseg(t, p, &a, &n);
if (n) os_swix4(OS_GBPB, 2, handle, a, n);
p += n;
} while(n);
}
static void save_edits(int s, char *buff)
{
_kernel_oserror *e;
os_error error;
int reported = 0;
os_regset r;
BOOL reported = FALSE;
txtedit_state *txtedits;
char *a;
int f, n;
int f;
int key;
int p, h;
e = _kernel_last_oserror();
pointer_reset_shape();
......@@ -628,27 +614,30 @@ static void save_edits(int s, char *buff)
if (txt_charoptions(txtedits->t) & txt_UPDATED) {
if (!reported) {
sprintf(error.errmess, msgs_lookup("EditX"), e->errmess, buff);
_swi(Wimp_ReportError, _IN(0)|_IN(1)|_IN(2)|_OUT(1), &error, 3, "Edit", &key);
reported = 1;
os_swi3r(Wimp_ReportError, &error, 3, "Edit", NULL, &key, NULL);
reported = TRUE;
if (key == 2) break;
_swi(OS_File, _IN(0)|_IN(1)|_IN(4), 8, buff, 0);
os_swi5(OS_File, 8, buff, 0, 0, 0);
}
buff[s] = '.';
buff[s+1] = f / 10 + '0';
buff[s+2] = f % 10 + '0';
buff[s+3] = 0;
if (!_swix(OS_Find, _IN(0)|_IN(1)|_OUT(0), 0x83, buff, &h)) {
r.r[0] = 0x83; /* Open out, no path */
r.r[1] = (int)buff;
if (os_find(&r) == NULL) {
int h = r.r[0];
os_swix4(OS_GBPB, 2, h, "> ", 2);
os_swix4(OS_GBPB, 2, h, txtedits->filename, strlen(txtedits->filename));
os_swix2(OS_BPut, '\n', h);
p = 0;
do {
txt_arrayseg(txtedits->t, p, &a, &n);
if (n) os_swix4(OS_GBPB, 2, h, a, n);
p += n;
} while(n);
os_swix2(OS_Find, 0, h);
os_swix3(OS_File, 18, buff, txtedits->ty.ld >> 20);
save_one_txt(txtedits->t, h);
r.r[0] = 0; /* Close */
r.r[1] = h;
os_find(&r);
os_swix3(OS_File, 18, buff, (txtedits->ty.ld >> 8) & 0xfff);
}
f++;
}
......@@ -682,11 +671,8 @@ int main(int argc, char *argv[])
visdelay_begin();
#if RISC_OS_PLUS
wimpt_wimpversion(300);
wimpt_messages(edit_messages);
#endif
wimpt_messages(edit_messages);
res_init("Edit");
msgs_init();
......
......@@ -47,14 +47,13 @@
#include "txtscrap.h"
#include "typdat.h"
#include "txtedit.h"
#include "EditIntern/txtoptmenu.h"
#include "txtwin.h"
#include "trace.h"
#include "werr.h"
#include "wimp.h"
#include "wimpt.h"
#include "win.h"
#include "EditIntern/message.h"
#include "taskwin.h"
#include "slist.h"
#include "msgs.h"
#include "msgtrans.h"
......@@ -152,7 +151,7 @@ strcpy(cliline + mylength + 10, hex); /* Started task knows txt of caller */
return wimp_starttask(cliline);
} /* End procedure */
os_error * message_sendmessage(
static os_error * message_sendmessage(
message_action action,
wimp_t dest, /* Who to, 0 => everyone, including us */
message_data * data) /* The data, NULL for die */
......
/* Copyright 2014 Castle Technology Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* -> h.taskwin
* Title: TaskWindow
* Purpose: Message protocol definition for task
communication in task windows.
* History:
* 16-May-88: JGT: history started.
*/
#ifndef taskwin_h
#define taskwin_h
#define TaskModuleSWI 0x808C0
typedef enum {
message_input = TaskModuleSWI, /* Parent has input for child */
message_output = TaskModuleSWI + 1, /* Child has output for parent */
message_ego = TaskModuleSWI + 2, /* Child tells parent its name */
message_morio = TaskModuleSWI + 3, /* Child dies */
message_morite = TaskModuleSWI + 4, /* Parent kills child */
message_newtask = TaskModuleSWI + 5, /* External agent requests task window */
message_suspend = TaskModuleSWI + 6, /* Parent halts child */
message_resume = TaskModuleSWI + 7 /* Parent continues child */
} message_action;
/* This will appear in place of the wimp_msgaction in wimp_msghdr */
typedef struct
{
int size;
char * data;
} message_data;
/* This will appear in the data field of wimp_msgstr */
extern os_error * message_taskinit(
char * name, /* The * comand to start the task, and its parameters */
wimp_t me); /* My task handle, passed to the task in STR$~ form */
extern void message_taskwindow(char * comname);
extern void killalltasks(void);
extern void message_init(void);
#endif
/* End taskwin.h */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment