EDITOR.MOD 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533
  1. IMPLEMENTATION MODULE Editor;
  2. (*
  3. * REPERTOIRE
  4. * Release 1.6
  5. * By Charles Bradford and Cole Brecheen
  6. * (c) Copyright 1985-1992 PMI
  7. * Green Bay, Wisconsin
  8. * All rights reserved
  9. * (414) 468-6040
  10. *
  11. * $Header: D:/logfiles/mods/editor.mov 1.7 10 Mar 1991 15:26:46 coleb $
  12. *
  13. *)
  14. (*$O-*)
  15. (*We turn off optimization for the whole module to help avoid bugs in
  16. Logitech's LONGINTs.*)
  17. (*EntryDiag:
  18. IMPORT Diagnostics;
  19. :EntryDiag*)
  20. IMPORT BigSets;
  21. IMPORT ByteFiddler;
  22. IMPORT GenLists;
  23. IMPORT KbdInput;
  24. IMPORT Key;
  25. IMPORT ListUtils;
  26. IMPORT LowLevel;
  27. IMPORT M2Strings;
  28. IMPORT MsColors;
  29. IMPORT Numbers;
  30. IMPORT NumTypes;
  31. IMPORT PosUtils;
  32. IMPORT ScrnTypes;
  33. IMPORT ScrnUtl1;
  34. IMPORT Spkr;
  35. IMPORT StrConv;
  36. IMPORT StrEdit;
  37. IMPORT SYSTEM;
  38. IMPORT UserOps;
  39. IMPORT VEditor;
  40. IMPORT VWindows;
  41. VAR
  42. Initialized : BOOLEAN;
  43. CONST
  44. LineLeng = 255;
  45. DisplayLeng = 80;
  46. TYPE
  47. LineType = ARRAY [0..LineLeng] OF CHAR;
  48. LongAndShort =
  49. RECORD
  50. CASE : BOOLEAN OF
  51. TRUE: longi: LONGINT;
  52. | FALSE: locard, hicard: CARDINAL;
  53. END;
  54. END;
  55. VAR
  56. DumType: CARDINAL;
  57. blank : ARRAY [0..0] OF CHAR;
  58. DeleteBuffer : GenLists.GenList;
  59. PROCEDURE CountToStr( TheCount: LongAndShort;
  60. VAR TheStr: ARRAY OF CHAR);
  61. BEGIN
  62. IF TheCount.hicard = 0 THEN
  63. StrConv.CardinalToStr( TheCount.locard, 1, TheStr);
  64. ELSE
  65. StrConv.LongIntegerToStr( TheCount.longi, 1, TheStr);
  66. END;
  67. END CountToStr;
  68. PROCEDURE DefaultEditor( VAR TheList: GenLists.GenList;
  69. VAR Rec: VEditor.AnEdControlRec );
  70. TYPE
  71. WriteToScreenOrNot = (DoWrite, DontWrite);
  72. VAR
  73. BlankStr : ARRAY [0..DisplayLeng] OF CHAR;
  74. Testing, DoExitBox : BOOLEAN;
  75. (* Testing is true if want to see internals printed. *)
  76. WindowHeight, ColsScrolled, MaxLength,
  77. LastLineDeleted, TheRow, RLineCnt, TLine,
  78. TheNdx : CARDINAL;
  79. RCharCnt, TCharCnt : LongAndShort;
  80. (* TheRow = the actual row on the screen where the cursor
  81. is*)
  82. (* Row1 = first row on screen that is in the editor*)
  83. (* TheNdx = the column in the text, not on the screen,
  84. where we are. Value starts at 0. TheNdx + Col1 is the
  85. actual screen column*)
  86. (* RCharCnt, RlineCnt = actual text size in characters and
  87. lines*)
  88. (* TCharCnt, Tline = cursor position in text (characters &
  89. lines)*)
  90. dumint: INTEGER;
  91. PROCEDURE SetPromptColors( TheFrame: ScrnTypes.DisplayFrame );
  92. BEGIN
  93. VWindows.SetForeColor( TheFrame^.WindowHandle,
  94. Rec.EdPromptFore );
  95. VWindows.SetBackColor( TheFrame^.WindowHandle,
  96. Rec.EdPromptBack );
  97. VWindows.SetMonoAttr( TheFrame^.WindowHandle,
  98. Rec.EdPromptAttrib );
  99. END SetPromptColors;
  100. PROCEDURE SetAttribOrColor( ForeColor, BackColor: MsColors.AColor;
  101. attr: MsColors.AMonoAttribute );
  102. BEGIN
  103. VWindows.SetForeColor( Rec.WindowHandle, ForeColor );
  104. VWindows.SetBackColor( Rec.WindowHandle, BackColor );
  105. VWindows.SetMonoAttr( Rec.WindowHandle, attr );
  106. END SetAttribOrColor;
  107. PROCEDURE CheckMax(): BOOLEAN;
  108. BEGIN
  109. IF (Rec.MaxLines = 0) OR
  110. (GenLists.ListLength( TheList ) < Rec.MaxLines) THEN
  111. RETURN TRUE;
  112. ELSE
  113. Spkr.Noise( Spkr.Warble, Spkr.Normal, Spkr.Short);
  114. RETURN FALSE;
  115. END;
  116. END CheckMax;
  117. PROCEDURE UpdateFrameRec();
  118. VAR
  119. FieldRec: ScrnTypes.InputFieldRecord;
  120. BEGIN
  121. IF Rec.FrameRec # NIL THEN
  122. IF GenLists.Initialized( Rec.FrameRec^.FieldList ) AND
  123. (Rec.FrameRec^.CurrentField # 0) AND
  124. (GenLists.ListLength( Rec.FrameRec^.FieldList ) > 0) THEN
  125. IF (Rec.FrameRec^.CurrentField = 0) THEN
  126. Rec.FrameRec^.CurrentField := 1;
  127. END;
  128. ScrnUtl1.GetFieldRec( Rec.FrameRec, Rec.FrameRec^.CurrentField,
  129. FieldRec );
  130. IF FieldRec.typ = ScrnTypes.EditorCode THEN
  131. (*
  132. ??
  133. FieldRec.Col2 := Rec.Col2;
  134. FieldRec.Row2 := Rec.Row2;
  135. *)
  136. FieldRec.TextRow1 := Rec.TextRow1;
  137. FieldRec.CursorCol := Rec.CursorCol;
  138. FieldRec.CursorRow := Rec.CursorRow;
  139. FieldRec.MaxLines := Rec.MaxLines;
  140. FieldRec.ChangeMade := Rec.ChangeMade;
  141. FieldRec.ReadOnly := Rec.ReadOnly;
  142. ScrnUtl1.PutFieldRec( FieldRec, Rec.FrameRec,
  143. Rec.FrameRec^.CurrentField );
  144. END;
  145. END;
  146. END;
  147. END UpdateFrameRec;
  148. PROCEDURE GetFrameRecData();
  149. VAR
  150. FieldRec: ScrnTypes.InputFieldRecord;
  151. BEGIN
  152. IF Rec.FrameRec # NIL THEN
  153. Rec.WindowHandle := Rec.FrameRec^.WindowHandle;
  154. IF GenLists.Initialized( Rec.FrameRec^.FieldList ) AND
  155. (GenLists.ListLength( Rec.FrameRec^.FieldList ) > 0) THEN
  156. IF (Rec.FrameRec^.CurrentField = 0) THEN
  157. Rec.FrameRec^.CurrentField := 1;
  158. END;
  159. ScrnUtl1.GetFieldRec( Rec.FrameRec, Rec.FrameRec^.CurrentField,
  160. FieldRec );
  161. IF FieldRec.typ = ScrnTypes.EditorCode THEN
  162. (*
  163. ??
  164. Rec.Col2 := FieldRec.Col2;
  165. Rec.Row2 := FieldRec.Row2;
  166. *)
  167. Rec.TextRow1 := FieldRec.TextRow1;
  168. Rec.CursorCol := FieldRec.CursorCol;
  169. Rec.CursorRow := FieldRec.CursorRow;
  170. Rec.MaxLines := FieldRec.MaxLines;
  171. Rec.ChangeMade := FieldRec.ChangeMade;
  172. Rec.ReadOnly := FieldRec.ReadOnly;
  173. IF NOT ScrnUtl1.ListFromEdField( Rec.FrameRec,
  174. Rec.FrameRec^.CurrentField, TheList ) THEN
  175. (*Remember that a user might invoke a help sequence from
  176. within the editor, which would require PushFrame/PopFrame
  177. to save and restore the frame's lists. Since we're editing
  178. one of them, we need to update our pointer, because the
  179. saved copy will be in a different place.*)
  180. END;
  181. END;
  182. END;
  183. END;
  184. END GetFrameRecData;
  185. PROCEDURE findindent(str : ARRAY OF CHAR) : CARDINAL;
  186. VAR
  187. ind, leng : CARDINAL;
  188. done : BOOLEAN;
  189. BEGIN
  190. done := FALSE;
  191. ind := 0;
  192. leng := M2Strings.Length(str);
  193. IF leng#0 THEN
  194. DEC(leng);
  195. REPEAT
  196. IF (str[ind]#blank[0]) THEN
  197. done := TRUE;
  198. ELSIF (ind>=leng) THEN
  199. done := TRUE;
  200. ind := HIGH(str) + 1;
  201. ELSE
  202. INC(ind);
  203. END;
  204. UNTIL done;
  205. ELSE
  206. ind := HIGH(str) + 1;
  207. END;
  208. RETURN (ind);
  209. END findindent;
  210. PROCEDURE WriteStrings(TextLine, baserow, endrow : CARDINAL);
  211. VAR
  212. clrstr: ARRAY [0..DisplayLeng] OF CHAR;
  213. clrlngth, tmpsize, leng, tmprow : CARDINAL;
  214. tmpadr: SYSTEM.ADDRESS;
  215. BEGIN
  216. LowLevel.Fill( SYSTEM.ADR(clrstr), DisplayLeng + 1, blank);
  217. leng := GenLists.ListLength( TheList);
  218. M2Strings.Assign(BlankStr, clrstr);
  219. tmprow := baserow - 1;
  220. WHILE (TextLine <= leng) AND (tmprow < endrow) DO
  221. INC( tmprow);
  222. GenLists.GetElmtAdr( TheList, TextLine, tmpadr, tmpsize, DumType);
  223. tmpsize := LowLevel.ScanEQ( tmpsize, 0C, tmpadr );
  224. IF tmpsize < ColsScrolled THEN
  225. clrlngth := MaxLength;
  226. tmpsize := 0;
  227. (*set tmpsize to 0 because none of the string will
  228. show.*)
  229. ELSE
  230. IF (tmpsize - ColsScrolled) > MaxLength THEN
  231. tmpsize := MaxLength;
  232. clrlngth := 0;
  233. ELSE
  234. tmpsize := Numbers.Min( tmpsize - ColsScrolled, MaxLength );
  235. clrlngth := MaxLength - tmpsize;
  236. END;
  237. IF tmpsize > 0 THEN
  238. VWindows.DrawStr( Rec.WindowHandle, Rec.Col1,
  239. tmprow, LowLevel.AddAddr(tmpadr, ColsScrolled),
  240. tmpsize );
  241. END;
  242. END;
  243. IF clrlngth > 0 THEN
  244. VWindows.DrawStr( Rec.WindowHandle,
  245. Rec.Col1 + tmpsize, tmprow, SYSTEM.ADR(clrstr),
  246. clrlngth );
  247. END;
  248. INC( TextLine);
  249. END;
  250. IF (tmprow < endrow) AND (endrow = Rec.Row2) THEN
  251. VWindows.ClearPart( Rec.WindowHandle,
  252. Rec.Col1, tmprow + 1, Rec.Col2, Rec.Row2);
  253. END;
  254. END WriteStrings;
  255. PROCEDURE OvrOrIns( VAR TheStr: ARRAY OF CHAR);
  256. BEGIN
  257. IF Rec.overwriting THEN
  258. StrEdit.AssignStr( 'Overwrite', TheStr);
  259. ELSE
  260. StrEdit.AssignStr( ' Insert ', TheStr);
  261. END;
  262. END OvrOrIns;
  263. PROCEDURE WriteFooter();
  264. VAR
  265. dumstr : ARRAY [0..DisplayLeng] OF CHAR;
  266. tmpstr : ARRAY [0..10] OF CHAR;
  267. SavedFore, SavedBack : MsColors.AColor;
  268. SavedAttr : MsColors.AMonoAttribute;
  269. BEGIN
  270. IF Rec.FrameRec # NIL THEN
  271. SavedFore := VWindows.ForeColor( Rec.WindowHandle );
  272. SavedBack := VWindows.BackColor( Rec.WindowHandle );
  273. SavedAttr := VWindows.MonoAttr( Rec.WindowHandle );
  274. SetPromptColors( Rec.FrameRec );
  275. END;
  276. CountToStr(RCharCnt, tmpstr);
  277. M2Strings.Concat('TEXT SIZE: chars:', tmpstr, dumstr);
  278. StrEdit.LeftJustify( dumstr, 23 );
  279. StrEdit.Append(dumstr, ' lines:');
  280. StrConv.CardinalToStr(RLineCnt, 1, tmpstr);
  281. StrEdit.Append(dumstr, tmpstr);
  282. StrEdit.LeftJustify( dumstr, 33 );
  283. StrEdit.Append(dumstr, ' POSITION: char:');
  284. CountToStr( TCharCnt, tmpstr);
  285. StrEdit.Append(dumstr, tmpstr);
  286. StrEdit.LeftJustify( dumstr, 54 );
  287. StrEdit.Append(dumstr, ' line:');
  288. StrConv.CardinalToStr(TLine, 1, tmpstr);
  289. StrEdit.Append(dumstr, tmpstr);
  290. StrEdit.LeftJustify( dumstr, 65 );
  291. StrEdit.Append(dumstr, 'MODE:');
  292. OvrOrIns( tmpstr);
  293. StrEdit.Append(dumstr, tmpstr);
  294. VWindows.DrawStr( Rec.WindowHandle,2, Rec.CountRow,
  295. SYSTEM.ADR(dumstr), M2Strings.Length(dumstr) );
  296. IF Rec.FrameRec # NIL THEN
  297. VWindows.SetForeColor( Rec.WindowHandle, SavedFore );
  298. VWindows.SetBackColor( Rec.WindowHandle, SavedBack );
  299. VWindows.SetMonoAttr( Rec.WindowHandle, SavedAttr );
  300. END;
  301. END WriteFooter;
  302. PROCEDURE AddCLCount( CharTotalDiff: LONGINT; LineTotalDiff: INTEGER;
  303. CharPosDiff: LONGINT; LinePosDiff : INTEGER );
  304. VAR
  305. tmpstr : ARRAY [0..20] OF CHAR;
  306. TmpLong : LONGINT;
  307. SavedFore, SavedBack : MsColors.AColor;
  308. SavedAttr : MsColors.AMonoAttribute;
  309. BEGIN
  310. TLine := INTEGER( INTEGER(TLine) + LinePosDiff );
  311. IF Rec.DoCounting THEN
  312. IF Rec.FrameRec # NIL THEN
  313. SavedFore := VWindows.ForeColor( Rec.WindowHandle );
  314. SavedBack := VWindows.BackColor( Rec.WindowHandle );
  315. SavedAttr := VWindows.MonoAttr( Rec.WindowHandle );
  316. SetPromptColors( Rec.FrameRec );
  317. END;
  318. IF LineTotalDiff # 0 THEN
  319. RLineCnt := INTEGER(INTEGER(RLineCnt) + LineTotalDiff);
  320. StrConv.CardinalToStr(RLineCnt, 1, tmpstr);
  321. StrEdit.Append(tmpstr, ' ');
  322. StrEdit.SetLength(tmpstr, 4);
  323. VWindows.DrawStr( Rec.WindowHandle, 31,
  324. Rec.CountRow, SYSTEM.ADR(tmpstr), 4);
  325. END;
  326. IF LinePosDiff#0 THEN
  327. StrConv.CardinalToStr(TLine, 1, tmpstr);
  328. StrEdit.Append(tmpstr, ' ');
  329. StrEdit.SetLength(tmpstr, 4);
  330. VWindows.DrawStr( Rec.WindowHandle,62, Rec.CountRow,
  331. SYSTEM.ADR(tmpstr), 4);
  332. END;
  333. IF CharTotalDiff # NumTypes.L0 THEN
  334. TmpLong := CharTotalDiff;
  335. RCharCnt.longi := RCharCnt.longi + TmpLong;
  336. CountToStr( RCharCnt, tmpstr);
  337. StrEdit.Append(tmpstr, ' ');
  338. StrEdit.SetLength(tmpstr, 5);
  339. VWindows.DrawStr( Rec.WindowHandle,19, Rec.CountRow,
  340. SYSTEM.ADR(tmpstr), 5);
  341. END;
  342. IF CharPosDiff # NumTypes.L0 THEN
  343. TmpLong := CharPosDiff;
  344. TCharCnt.longi := TCharCnt.longi + TmpLong;
  345. CountToStr( TCharCnt, tmpstr);
  346. StrEdit.Append(tmpstr, ' ');
  347. StrEdit.SetLength(tmpstr, 5);
  348. VWindows.DrawStr( Rec.WindowHandle,51, Rec.CountRow,
  349. SYSTEM.ADR(tmpstr), 5);
  350. END;
  351. IF Rec.FrameRec # NIL THEN
  352. VWindows.SetForeColor( Rec.WindowHandle, SavedFore );
  353. VWindows.SetBackColor( Rec.WindowHandle, SavedBack );
  354. VWindows.SetMonoAttr( Rec.WindowHandle, SavedAttr );
  355. END;
  356. END;
  357. VWindows.GotoXY( Rec.WindowHandle, Rec.Col1 +
  358. TheNdx - ColsScrolled, TheRow);
  359. END AddCLCount;
  360. PROCEDURE CountChars(Rtmptr : CARDINAL; VAR Rchars : LONGINT;
  361. VAR Rlines : CARDINAL; Ttmptr : CARDINAL;
  362. VAR Tchars : LONGINT);
  363. VAR
  364. leng : CARDINAL;
  365. BEGIN
  366. IF NOT Rec.DoCounting THEN
  367. Rchars := NumTypes.L1;
  368. Rlines := 1;
  369. Tchars := NumTypes.L1;
  370. (*Added 25 May 87 to prevent uninitialized values*)
  371. RETURN;
  372. END;
  373. leng := GenLists.ListLength( TheList);
  374. (*count all chars starting WITH Rtmptr*)
  375. Rlines := 0;
  376. Rchars := NumTypes.L1;
  377. (*put 1+ chars and lines before Ttmptr in Tchars and Tlines*)
  378. Tchars := NumTypes.L1;
  379. WHILE Rtmptr <= leng DO
  380. Rlines := Rlines + 1;
  381. IF Rtmptr=Ttmptr THEN
  382. Tchars := Rchars;
  383. END;
  384. Rchars := Rchars + Numbers.Lc( ListUtils.ElmtSize(TheList,Rtmptr) + 2 );
  385. INC( Rtmptr);
  386. END;
  387. END CountChars;
  388. PROCEDURE TheLength(): CARDINAL;
  389. (* Returns length of current line *)
  390. BEGIN
  391. RETURN ListUtils.ElmtSize( TheList, TLine);
  392. END TheLength;
  393. PROCEDURE MoveAcrossTo(NewNdx : INTEGER);
  394. VAR
  395. charsmoved : INTEGER;
  396. redraw : BOOLEAN;
  397. lngth : CARDINAL;
  398. BEGIN
  399. lngth := TheLength();
  400. IF (CARDINAL(NewNdx) >= lngth) AND (TheNdx >= lngth) THEN
  401. charsmoved := 0;
  402. ELSE
  403. IF (CARDINAL(NewNdx) >= lngth) AND
  404. (TheNdx < lngth) THEN
  405. (*We've crossed over to the right of the trailing CR/LF.*)
  406. charsmoved := (lngth - TheNdx) + 2;
  407. ELSIF (CARDINAL(NewNdx) < lngth) AND
  408. (TheNdx >= lngth) THEN
  409. (*We've crossed over to the left of the trailing CR/LF.*)
  410. charsmoved := (NewNdx - INTEGER(lngth)) - 2;
  411. ELSE
  412. charsmoved := NewNdx - INTEGER(TheNdx);
  413. IF (charsmoved = 0) THEN
  414. RETURN;
  415. END;
  416. END;
  417. END;
  418. TheNdx := NewNdx;
  419. IF (TheNdx < ColsScrolled) THEN
  420. ColsScrolled := TheNdx;
  421. redraw := TRUE;
  422. ELSIF (TheNdx > (ColsScrolled + MaxLength - 1)) THEN
  423. ColsScrolled := TheNdx - MaxLength + 1;
  424. redraw := TRUE;
  425. ELSE
  426. redraw := FALSE;
  427. END;
  428. AddCLCount( NumTypes.L0, 0, Numbers.Li(charsmoved), 0);
  429. IF redraw THEN
  430. WriteStrings( TLine -
  431. (TheRow - Rec.Row1), Rec.Row1, Rec.Row2);
  432. END;
  433. END MoveAcrossTo;
  434. PROCEDURE MoveVerticallyTo( NewTLine: CARDINAL );
  435. VAR
  436. TmpSize, ColNow, RowNow, LstLngth, TmpLineCount : CARDINAL;
  437. TmpL, BytesSkipped : LONGINT;
  438. redrawing, MovingUp : BOOLEAN;
  439. addrow, addchar, dist : INTEGER;
  440. BEGIN
  441. LstLngth := GenLists.ListLength( TheList );
  442. addrow := 0;
  443. addchar := 0;
  444. IF NewTLine > LstLngth THEN
  445. (*We'll add a line if the line we're on is the last line
  446. and it isn't blank.*)
  447. IF (TLine = LstLngth) AND
  448. (ListUtils.ElmtSize(TheList, TLine) > 0) THEN
  449. IF CheckMax() THEN
  450. GenLists.ListInsert( '', DumType, TheList, TLine + 1);
  451. addrow := 1;
  452. addchar := 2;
  453. INC( LstLngth );
  454. END;
  455. END;
  456. (*otherwise we don't let them move past last line*)
  457. NewTLine := LstLngth;
  458. ELSIF NewTLine < 1 THEN
  459. NewTLine := 1;
  460. END;
  461. IF TLine > NewTLine THEN
  462. MovingUp := TRUE;
  463. ELSIF TLine < NewTLine THEN
  464. MovingUp := FALSE;
  465. ELSE
  466. RETURN;
  467. END;
  468. (*Now we count the bytes we will be skipping.*)
  469. TmpLineCount := TLine;
  470. BytesSkipped := NumTypes.L0;
  471. IF MovingUp THEN
  472. WHILE (TmpLineCount >= NewTLine) DO
  473. IF TmpLineCount > LstLngth THEN
  474. (*This can happen if we've just deleted the last line
  475. and we're moving up to what is now the new last line.*)
  476. TmpL := NumTypes.L0;
  477. ELSE
  478. TmpL := Numbers.Lc( ListUtils.ElmtSize( TheList,
  479. TmpLineCount ));
  480. (*Workaround for a Logitech LONGINT bug.*)
  481. END;
  482. BytesSkipped := BytesSkipped + TmpL + NumTypes.L2;
  483. DEC( TmpLineCount );
  484. END;
  485. (*Adjust BytesSkipped because we may not have actually skipped
  486. over some of the bytes on the line we were on. It depends
  487. on whether the cursor was beyond the end of the line at the
  488. time.*)
  489. IF TLine > LstLngth THEN
  490. TmpSize := 0;
  491. ELSE
  492. TmpSize := ListUtils.ElmtSize( TheList, TLine );
  493. END;
  494. IF TheNdx < TmpSize THEN
  495. TmpSize := TmpSize - TheNdx + 2;
  496. (*Otherwise the cursor was beyond the end of the line, so
  497. we did skip over the full length of the line plus the
  498. CR/LF at the end of it. We don't have to subtract
  499. anything*)
  500. BytesSkipped := BytesSkipped - Numbers.Lc(TmpSize);
  501. END;
  502. TmpSize := ListUtils.ElmtSize( TheList, NewTLine );
  503. (*Now determine whether we have skipped over all
  504. of the line we're moving to. If we don't adjust
  505. BytesSkipped, it tells AddCLCount that we have
  506. skipped over the whole thing.*)
  507. IF TheNdx < TmpSize THEN
  508. BytesSkipped := BytesSkipped - Numbers.Lc(TheNdx);
  509. ELSE
  510. TmpSize := TmpSize + 2;
  511. BytesSkipped := BytesSkipped - Numbers.Lc(TmpSize);
  512. END;
  513. BytesSkipped := -BytesSkipped;
  514. ELSE
  515. WHILE (TmpLineCount <= NewTLine) DO
  516. TmpL := Numbers.Lc( ListUtils.ElmtSize( TheList, TmpLineCount ));
  517. (*Workaround for a Logitech LONGINT bug.*)
  518. BytesSkipped := BytesSkipped + TmpL + NumTypes.L2;
  519. INC( TmpLineCount );
  520. END;
  521. (*Now we subtract the part of the line we're on that we didn't
  522. actually skip.*)
  523. IF TLine <= LstLngth THEN
  524. TmpL := Numbers.Lc( Numbers.Min(TheNdx, TheLength() ) );
  525. IF Numbers.C(TmpL) >= ListUtils.ElmtSize(TheList, TLine) THEN
  526. TmpL := TmpL + NumTypes.L2;
  527. END;
  528. BytesSkipped := BytesSkipped - TmpL;
  529. END;
  530. (*And now we subtract the part of the new line that we haven't
  531. yet skipped.*)
  532. TmpSize := ListUtils.ElmtSize(TheList, NewTLine);
  533. IF TheNdx < TmpSize THEN
  534. TmpSize := TmpSize - TheNdx + 2;
  535. BytesSkipped := BytesSkipped - Numbers.Lc(TmpSize);
  536. END;
  537. END;
  538. dist := INTEGER(NewTLine) - INTEGER(TLine);
  539. (*Now determine whether we can get by with just moving the cursor
  540. instead of redrawing some or all of the window.*)
  541. IF MovingUp THEN
  542. redrawing := (INTEGER(TheRow) + dist) < INTEGER(Rec.Row1);
  543. ELSE
  544. redrawing := (INTEGER(TheRow) + dist) > INTEGER(Rec.Row2);
  545. END;
  546. IF NOT redrawing THEN
  547. TheRow := INTEGER(INTEGER(TheRow) + dist);
  548. VWindows.GetCursorCoords( Rec.WindowHandle,
  549. ColNow, RowNow );
  550. VWindows.GotoXY( Rec.WindowHandle, ColNow,
  551. CARDINAL(INTEGER(RowNow) + dist) );
  552. AddCLCount( Numbers.Li(addchar), addrow, BytesSkipped, dist );
  553. RETURN;
  554. END;
  555. (*We know we have to redraw at least some of the window. The
  556. next easy case is redrawing the whole thing.*)
  557. IF ABS(dist) >= INTEGER(WindowHeight) THEN
  558. IF (NewTLine > (TheRow - Rec.Row1)) AND
  559. (NOT (NewTLine = LstLngth)) THEN
  560. WriteStrings( NewTLine - (TheRow - Rec.Row1), Rec.Row1, Rec.Row2);
  561. ELSE
  562. (*We're moving more than a page's length, so we'll position the
  563. cursor to the top of the window unless we're going to the
  564. very end--in that case we position it to the bottom.*)
  565. VWindows.GetCursorCoords( Rec.WindowHandle,
  566. ColNow, RowNow );
  567. IF (NewTLine = LstLngth) AND (NewTLine >= WindowHeight) THEN
  568. WriteStrings( NewTLine - WindowHeight + 1, Rec.Row1, Rec.Row2 );
  569. TheRow := Rec.Row2;
  570. VWindows.GotoXY( Rec.WindowHandle, ColNow,
  571. Rec.Row2 );
  572. ELSE
  573. WriteStrings( NewTLine, Rec.Row1, Rec.Row2 );
  574. TheRow := Rec.Row1;
  575. VWindows.GotoXY( Rec.WindowHandle, ColNow,
  576. Rec.Row1 );
  577. END;
  578. END;
  579. AddCLCount( Numbers.Li(addchar), addrow, BytesSkipped, dist );
  580. RETURN;
  581. END;
  582. (*Looks like we'll have to scroll part of the window and redraw
  583. the rest of it.*)
  584. IF NOT VWindows.ScrollVertically( Rec.WindowHandle,
  585. Rec.Col1, Rec.Row1, Rec.Col2, Rec.Row2, dist ) THEN
  586. (*The window manager they've chosen doesn't support a
  587. fast vertical scroll, so we can redraw the whole thing
  588. and leave.*)
  589. WriteStrings( NewTLine - (TheRow - Rec.Row1), Rec.Row1, Rec.Row2);
  590. AddCLCount( Numbers.Li(addchar), addrow, BytesSkipped, dist );
  591. RETURN;
  592. END;
  593. IF MovingUp THEN
  594. (*We have to redraw the top of the window.*)
  595. WriteStrings( NewTLine - (TheRow - Rec.Row1), Rec.Row1,
  596. Rec.Row1 + CARDINAL(ABS(dist)) - 1 );
  597. ELSE
  598. (*We have to redraw the bottom of the window.*)
  599. WriteStrings( NewTLine - CARDINAL(ABS(dist)) + 1,
  600. Rec.Row2 - CARDINAL(ABS(dist)) + 1, Rec.Row2 );
  601. END;
  602. AddCLCount( Numbers.Li(addchar), addrow, BytesSkipped, dist );
  603. END MoveVerticallyTo;
  604. PROCEDURE PageUp();
  605. BEGIN
  606. IF (TheRow > Rec.Row1) OR (TLine = 1) THEN
  607. MoveVerticallyTo( TLine - (TheRow - Rec.Row1) );
  608. ELSIF WindowHeight >= TLine THEN
  609. MoveVerticallyTo( 1 );
  610. ELSE
  611. MoveVerticallyTo( TLine - WindowHeight );
  612. END;
  613. END PageUp;
  614. PROCEDURE PageDown();
  615. BEGIN
  616. IF (TheRow < Rec.Row2) OR (TLine = GenLists.ListLength(TheList)) THEN
  617. MoveVerticallyTo( TLine + (Rec.Row2 - TheRow) );
  618. ELSE
  619. MoveVerticallyTo( TLine + WindowHeight );
  620. END;
  621. END PageDown;
  622. PROCEDURE DeleteAChar( spacesback : CARDINAL);
  623. VAR
  624. tmpadr: SYSTEM.ADDRESS;
  625. null: CHAR;
  626. tmpsize, NewNdx: CARDINAL;
  627. BEGIN
  628. null := 0C;
  629. IF TheNdx > TheLength() THEN
  630. MoveAcrossTo( TheLength() );
  631. END;
  632. NewNdx := TheNdx - spacesback;
  633. MoveAcrossTo( NewNdx );
  634. (*This changes the value of TheNdx. We have to do it
  635. before the ShiftArrayLeft because MoveAcrossTo won't
  636. update our character position if it thinks we're
  637. moving around in the void beyond the end of the line.*)
  638. GenLists.GetElmtAdr( TheList, TLine, tmpadr, tmpsize, DumType);
  639. LowLevel.ShiftArrayLeft( LowLevel.AddAddr(tmpadr, NewNdx),
  640. tmpsize - NewNdx, 1 );
  641. (*Now we have to make sure we've truncated the line, because
  642. the ShiftArrayLeft will only do so if it moves a trailing
  643. null with the rest of the string.*)
  644. IF tmpsize > 0 THEN
  645. ListUtils.OverwriteElmt( TheList, TLine, SYSTEM.ADR(null), 1,
  646. tmpsize - 1 );
  647. END;
  648. WriteStrings( TLine, TheRow, TheRow );
  649. IF NewNdx >= TheLength() THEN
  650. (*We have to increment the character position by 2 if we
  651. wound up beyond the line length--the MoveAcrossTo didn't
  652. know what the ending line length would be.*)
  653. AddCLCount( Numbers.Li(-1), 0, NumTypes.L2, 0);
  654. ELSE
  655. AddCLCount( Numbers.Li(-1), 0, NumTypes.L0, 0);
  656. END;
  657. END DeleteAChar;
  658. PROCEDURE NewLink(VAR oldptr : CARDINAL; curind : CARDINAL);
  659. VAR
  660. newline : LineType;
  661. BEGIN
  662. (*We don't have to check MaxLines here because NewLink is
  663. only called in BumpWord, which we don't call if we're
  664. close to the limit.*)
  665. LowLevel.Fill( SYSTEM.ADR( newline), curind, blank);
  666. StrEdit.SetLength( newline, curind);
  667. GenLists.ListInsert( newline, GenLists.StrCode, TheList, oldptr + 1);
  668. END NewLink;
  669. PROCEDURE ReplaceWith(TheChr : CHAR);
  670. VAR
  671. LinesAdded, CharsAdded : INTEGER;
  672. StartLine, CursorLine, CursorCol: CARDINAL;
  673. RoomOnThisLine, BeyondEnd : BOOLEAN;
  674. BEGIN
  675. (* First we'll put the character into the list. Then we'll worry
  676. about whether we have to wrap or scroll to display it. *)
  677. CharsAdded := 0;
  678. BeyondEnd := (TheNdx >= ListUtils.ElmtSize(TheList, TLine));
  679. IF BeyondEnd THEN
  680. WHILE (TheNdx > ListUtils.ElmtSize(TheList, TLine)) DO
  681. ListUtils.InsertIntoElmt( TheList, TLine,
  682. SYSTEM.ADR(blank), 1, 65535 );
  683. (*pad with blanks out to TheNdx, if necessary*)
  684. INC(CharsAdded);
  685. END;
  686. TCharCnt.longi := TCharCnt.longi - NumTypes.L2;
  687. (*We do this to compensate for the fact that MoveAcrossTo
  688. will think we've crossed over a CR/LF.*)
  689. ListUtils.InsertIntoElmt( TheList, TLine,
  690. SYSTEM.ADR(TheChr), 1, 65535 );
  691. (*append TheChr to the string at position TLine*)
  692. INC(CharsAdded);
  693. ELSE
  694. IF Rec.overwriting THEN
  695. ListUtils.OverwriteElmt( TheList, TLine,
  696. SYSTEM.ADR(TheChr), 1, TheNdx );
  697. CharsAdded := 0;
  698. ELSE
  699. ListUtils.InsertIntoElmt( TheList, TLine,
  700. SYSTEM.ADR(TheChr), 1, TheNdx );
  701. CharsAdded := 1;
  702. END;
  703. END;
  704. RoomOnThisLine := (NOT Rec.Wrapping) OR
  705. (ListUtils.ElmtSize(TheList, TLine) < MaxLength);
  706. IF RoomOnThisLine THEN
  707. MoveAcrossTo( TheNdx + 1 );
  708. WriteStrings( TLine, TheRow, TheRow );
  709. AddCLCount(Numbers.Li(CharsAdded), 0, NumTypes.L0, 0);
  710. ELSE
  711. StartLine := TLine;
  712. CursorLine := TLine;
  713. CursorCol := TheNdx;
  714. ListUtils.ReformPara( TheList,
  715. ListUtils.IndentationAt(TheList, TLine), MaxLength, StartLine,
  716. CursorLine, CursorCol, LinesAdded, CharsAdded, TCharCnt.longi );
  717. AddCLCount( Numbers.Li(CharsAdded), LinesAdded, NumTypes.L0, 0 );
  718. MoveAcrossTo( 0 );
  719. (*Makes sure part of the current word isn't scrolled out of the
  720. window. *)
  721. MoveAcrossTo( CursorCol + 1 );
  722. MoveVerticallyTo( CursorLine );
  723. WriteStrings( TLine - (TheRow - Rec.Row1), Rec.Row1, Rec.Row2);
  724. END;
  725. END ReplaceWith;
  726. PROCEDURE ScrollRegion( row1, row2 : CARDINAL; dist: INTEGER );
  727. VAR
  728. NewTopLine: INTEGER;
  729. BEGIN
  730. NewTopLine := INTEGER(TLine - (TheRow - Rec.Row1)) +
  731. INTEGER(row1 - Rec.Row1) + dist;
  732. IF NOT VWindows.ScrollVertically( Rec.WindowHandle,
  733. Rec.Col1, row1, Rec.Col2, row2, dist ) THEN
  734. NewTopLine := Numbers.Min( NewTopLine, 1 );
  735. WriteStrings( NewTopLine, row1, row2 );
  736. RETURN;
  737. END;
  738. IF NewTopLine < 1 THEN
  739. (*They want to move down by more lines than we have to fill with.*)
  740. NewTopLine := 1 + ABS(dist);
  741. INC( row1, CARDINAL(ABS(dist)) );
  742. END;
  743. IF dist > 0 THEN
  744. WriteStrings( CARDINAL(NewTopLine) + (row2 - row1) -
  745. CARDINAL(dist), Rec.Row2 - CARDINAL(dist) + 1,
  746. Rec.Row2 );
  747. ELSE
  748. WriteStrings( CARDINAL(NewTopLine) + CARDINAL(ABS(dist)),
  749. row1, CARDINAL(INTEGER(row1) + ABS(dist) - 1) );
  750. END;
  751. END ScrollRegion;
  752. PROCEDURE Reformat();
  753. VAR
  754. LinesAdded, CharsAdded: INTEGER;
  755. StartLine, CursorLine, CursorCol: CARDINAL;
  756. BEGIN
  757. StartLine := TLine;
  758. CursorLine := TLine;
  759. CursorCol := TheNdx;
  760. ListUtils.ReformPara( TheList,
  761. ListUtils.IndentationAt(TheList, StartLine), MaxLength, StartLine,
  762. CursorLine, CursorCol, LinesAdded, CharsAdded, TCharCnt.longi );
  763. AddCLCount( Numbers.Li(CharsAdded), LinesAdded, NumTypes.L0, 0 );
  764. MoveAcrossTo( CursorCol );
  765. MoveVerticallyTo( CursorLine );
  766. WriteStrings( TLine - (TheRow - Rec.Row1), Rec.Row1, Rec.Row2);
  767. END Reformat;
  768. PROCEDURE InsertDeleteBuffer();
  769. VAR
  770. BufLngth: CARDINAL;
  771. CharsAdded, tmpl: LONGINT;
  772. BEGIN
  773. BufLngth := GenLists.ListLength( DeleteBuffer );
  774. IF BufLngth = 0 THEN
  775. RETURN;
  776. END;
  777. ListUtils.InsertElmtsOf( DeleteBuffer, 1, BufLngth,
  778. TheList, TLine );
  779. tmpl := ListUtils.CharCount( DeleteBuffer, 1, 65535 );
  780. IF tmpl > NumTypes.L65535 THEN
  781. (*If they try to copy more than 64K at once, we throw
  782. up our hands; the text gets inserted correctly, but
  783. we don't bother to position the cursor after it. We
  784. just go to the top and let them figure out where they
  785. were.*)
  786. RCharCnt.longi := RCharCnt.longi + tmpl;
  787. RLineCnt := RLineCnt + BufLngth;
  788. MoveVerticallyTo( 1 );
  789. MoveAcrossTo( 0 );
  790. CharsAdded := tmpl;
  791. AddCLCount( CharsAdded, BufLngth,
  792. NumTypes.L0, 0 );
  793. END;
  794. CharsAdded := tmpl;
  795. AddCLCount( CharsAdded, BufLngth,
  796. NumTypes.L0, 0 );
  797. WriteStrings( TLine -
  798. (TheRow - Rec.Row1), Rec.Row1, Rec.Row2);
  799. MoveVerticallyTo( TLine + BufLngth );
  800. END InsertDeleteBuffer;
  801. PROCEDURE DeleteALine();
  802. VAR
  803. delsize : INTEGER;
  804. BEGIN
  805. delsize := 2 + ListUtils.ElmtSize( TheList, TLine );
  806. IF TLine # LastLineDeleted THEN
  807. IF GenLists.Initialized( DeleteBuffer ) THEN
  808. GenLists.DisposeList( DeleteBuffer );
  809. END;
  810. GenLists.NewList( DeleteBuffer );
  811. LastLineDeleted := TLine;
  812. END;
  813. ListUtils.InsertElmtsOf( TheList, TLine, 1, DeleteBuffer, 65535 );
  814. GenLists.ListDelete( TheList, TLine, 1);
  815. IF TLine <= GenLists.ListLength( TheList) THEN
  816. (*this isn't the last line*)
  817. WriteStrings( TLine, TheRow, Rec.Row2 );
  818. AddCLCount( Numbers.Li(-delsize), -1, NumTypes.L0, 0);
  819. ELSIF TLine # 1 THEN
  820. (*this is the last line of many*)
  821. VWindows.ClearPart( Rec.WindowHandle, Rec.Col1,
  822. TheRow, Rec.Col2, TheRow);
  823. AddCLCount( Numbers.Li(-delsize), -1, NumTypes.L0, 0);
  824. MoveVerticallyTo( TLine - 1 );
  825. ELSE
  826. (*This is the only line *)
  827. GenLists.ListInsert( '', GenLists.StrCode, TheList, 1);
  828. VWindows.ClearPart( Rec.WindowHandle, Rec.Col1,
  829. TheRow, Rec.Col2, TheRow);
  830. MoveAcrossTo( 0 );
  831. AddCLCount( Numbers.Li(2 - delsize), 0,
  832. Numbers.Li(1 - INTEGER( TCharCnt.locard)), 0);
  833. END;
  834. END DeleteALine;
  835. PROCEDURE JoinLines();
  836. (* joins this line to the previous one
  837. (caused by a BSP in the first column or a del at the end) *)
  838. VAR
  839. addedtoend, firstleng : INTEGER;
  840. tmpsize: CARDINAL;
  841. tmpadr: SYSTEM.ADDRESS;
  842. OnBlankLine : BOOLEAN;
  843. BEGIN
  844. IF TLine = 1 THEN
  845. (* if this isn't the first line *)
  846. RETURN;
  847. END;
  848. OnBlankLine := TheLength() = 0;
  849. MoveAcrossTo( 0 );
  850. GenLists.GetElmtAdr( TheList, TLine - 1, tmpadr, tmpsize, DumType);
  851. firstleng := ListUtils.ElmtSize( TheList, TLine - 1 );
  852. IF (firstleng # 0) AND (ByteFiddler.PeekChar(LowLevel.AddAddr(tmpadr,
  853. firstleng - 1)) # blank[0]) THEN
  854. (* if need a space at end of prior line to separate *)
  855. ListUtils.InsertIntoElmt( TheList, TLine - 1,
  856. SYSTEM.ADR(blank), 1, 65535 );
  857. (*append a blank to end of previous line*)
  858. addedtoend := 1;
  859. ELSE
  860. addedtoend := 0;
  861. END;
  862. AddCLCount( Numbers.Li(addedtoend), 0, Numbers.Li(addedtoend), 0 );
  863. (*update char counts so that MoveTo procedures will count
  864. correctly as line boundary is crossed.*)
  865. MoveVerticallyTo( TLine - 1 );
  866. (*This changes TLine.*)
  867. MoveAcrossTo( TheLength() );
  868. IF NOT OnBlankLine THEN
  869. GenLists.GetElmtAdr( TheList, TLine + 1, tmpadr,
  870. tmpsize, DumType );
  871. ListUtils.InsertIntoElmt( TheList, TLine, tmpadr,
  872. tmpsize, 65535 );
  873. AddCLCount( -NumTypes.L2, -1, -NumTypes.L2, 0 );
  874. (*account for deletion of CR/LF and TLine*)
  875. ELSE
  876. AddCLCount( -NumTypes.L2, -1, NumTypes.L0, 0 );
  877. (*We've lost a line, but we're past the CR/LF
  878. on the line above*)
  879. END;
  880. GenLists.ListDelete( TheList, TLine + 1, 1);
  881. WriteStrings( TLine, TheRow, TheRow );
  882. ScrollRegion( TheRow + 1, Rec.Row2, 1 );
  883. END JoinLines;
  884. PROCEDURE NewLine();
  885. VAR
  886. prvadr: SYSTEM.ADDRESS;
  887. OldNdx, prvsize : CARDINAL;
  888. BEGIN
  889. IF NOT CheckMax() THEN
  890. RETURN;
  891. END;
  892. OldNdx := TheNdx;
  893. MoveAcrossTo( 0 );
  894. GenLists.GetElmtAdr( TheList, TLine, prvadr, prvsize, DumType);
  895. prvsize := ListUtils.ElmtSize( TheList, TLine );
  896. (*Reduces prvsize to number of bytes before the 0C.*)
  897. GenLists.ListInsert( '', GenLists.StrCode, TheList, TLine + 1 );
  898. IF OldNdx = 0 THEN
  899. AddCLCount( NumTypes.L2, 1, NumTypes.L2, 0 );
  900. (*Increment char total for the new CR/LF, and increment the
  901. char position because MoveVerticallyTo won't count the
  902. trailing CR/LF in this case--it thinks we've already
  903. skipped it.*)
  904. ELSE
  905. AddCLCount( NumTypes.L2, 1, NumTypes.L0, 0 );
  906. (*Increment char total for the new CR/LF.*)
  907. END;
  908. IF OldNdx < prvsize THEN
  909. ListUtils.InsertIntoElmt( TheList, TLine + 1,
  910. LowLevel.AddAddr(prvadr, OldNdx), prvsize - OldNdx, 0 );
  911. ByteFiddler.PokeChar( 0C, LowLevel.AddAddr(prvadr, OldNdx) );
  912. END;
  913. WriteStrings( TLine, TheRow, TheRow );
  914. IF TheRow < Rec.Row2 THEN
  915. ScrollRegion( TheRow + 1, Rec.Row2, -1 );
  916. END;
  917. MoveVerticallyTo( TLine + 1 );
  918. END NewLine;
  919. PROCEDURE NextWord();
  920. VAR
  921. tmpcol, leng : INTEGER;
  922. tmpsize: CARDINAL;
  923. txtadr, tmpadr: SYSTEM.ADDRESS;
  924. BEGIN
  925. leng := ListUtils.ElmtSize( TheList, TLine );
  926. IF TheNdx + 1 >= CARDINAL(leng) THEN
  927. MoveVerticallyTo( TLine + 1 );
  928. GenLists.GetElmtAdr( TheList, TLine, txtadr, tmpsize, DumType);
  929. MoveAcrossTo(0);
  930. IF ByteFiddler.PeekChar(txtadr) # blank[0] THEN
  931. RETURN;
  932. END;
  933. END;
  934. GenLists.GetElmtAdr( TheList, TLine, txtadr, tmpsize, DumType);
  935. tmpcol := TheNdx;
  936. LOOP
  937. tmpadr := LowLevel.AddAddr( txtadr, tmpcol );
  938. IF tmpcol + 1 < leng THEN
  939. IF ByteFiddler.PeekChar(tmpadr) = blank[0] THEN
  940. LowLevel.IncAddr( tmpadr, 1 );
  941. dumint := LowLevel.ScanNE(leng - tmpcol - 1, blank, tmpadr);
  942. MoveAcrossTo(tmpcol + 1 + dumint);
  943. RETURN;
  944. ELSE
  945. INC(tmpcol);
  946. END;
  947. ELSE
  948. MoveAcrossTo(leng);
  949. RETURN;
  950. END;
  951. END;
  952. END NextWord;
  953. PROCEDURE LastWord();
  954. VAR
  955. tmpcol : INTEGER;
  956. tmpsize: CARDINAL;
  957. txtadr, tmpadr: SYSTEM.ADDRESS;
  958. BEGIN
  959. tmpcol := TheNdx;
  960. GenLists.GetElmtAdr( TheList, TLine, txtadr, tmpsize, DumType);
  961. LOOP
  962. IF tmpcol > 0 THEN
  963. tmpadr := LowLevel.AddAddr(txtadr, tmpcol - 1);
  964. IF ByteFiddler.PeekChar(tmpadr) # blank[0] THEN
  965. dumint := LowLevel.ScanEQ(-tmpcol,blank,tmpadr);
  966. (* last is + since scan returns neg.*)
  967. MoveAcrossTo( tmpcol + dumint);
  968. EXIT;
  969. ELSE
  970. DEC( tmpcol);
  971. END;
  972. ELSE
  973. MoveVerticallyTo( TLine - 1 );
  974. MoveAcrossTo( TheLength() );
  975. EXIT;
  976. END;
  977. END;
  978. END LastWord;
  979. PROCEDURE KeyResponse();
  980. VAR
  981. OvrStr : ARRAY [0..10] OF CHAR;
  982. SavedFore, SavedBack : MsColors.AColor;
  983. SavedAttr : MsColors.AMonoAttribute;
  984. BEGIN
  985. LOOP
  986. Rec.EdLastKey := KbdInput.KeyHit( KbdInput.AnyKeyNum );
  987. IF Rec.FrameRec # NIL THEN
  988. UpdateFrameRec();
  989. UserOps.TheKeyHandler( Rec.FrameRec, Rec.EdLastKey, Rec.NextFrame );
  990. IF Rec.overwriting THEN
  991. VWindows.SetCursorHeight( Rec.WindowHandle, 2);
  992. ELSE
  993. VWindows.SetCursorHeight( Rec.WindowHandle, 4);
  994. END;
  995. SetAttribOrColor( Rec.EntryForeColor, Rec.EntryBackColor,
  996. Rec.EntryAttrib );
  997. GetFrameRecData();
  998. END;
  999. IF (Rec.EdLastKey = UserOps.SubmitKey)
  1000. OR (Rec.EdLastKey = UserOps.BackupKey)
  1001. OR (Rec.EdLastKey = UserOps.ExitKey) THEN
  1002. EXIT;
  1003. END;
  1004. CASE Rec.EdLastKey OF
  1005. Key.Up : (*up arrow*)
  1006. IF (TLine = 1) AND
  1007. BigSets.InSet( UserOps.FieldExitKeySet, Rec.EdLastKey ) THEN
  1008. (*We're letting the user exit from the editor
  1009. window by pressing the up arrow on the top line
  1010. of the file.*)
  1011. EXIT;
  1012. ELSE
  1013. MoveVerticallyTo( TLine - 1 );
  1014. END;
  1015. | Key.Down : (*down arrow*)
  1016. IF (TLine = GenLists.ListLength(TheList)) AND
  1017. BigSets.InSet( UserOps.FieldExitKeySet, Rec.EdLastKey ) THEN
  1018. (*We're letting the user exit from the editor
  1019. window by pressing the down arrow on the
  1020. bottom line of the file.*)
  1021. EXIT;
  1022. ELSE
  1023. MoveVerticallyTo( TLine + 1 );
  1024. END;
  1025. | Key.Left: (*left arrow*)
  1026. IF TheNdx>0 THEN
  1027. MoveAcrossTo(TheNdx - 1);
  1028. ELSIF BigSets.InSet( UserOps.FieldExitKeySet, Rec.EdLastKey ) THEN
  1029. (*We're letting the user exit from the editor
  1030. window by pressing the left arrow on the
  1031. left edge of the window.*)
  1032. EXIT;
  1033. ELSIF (TheRow # Rec.Row1) THEN
  1034. MoveVerticallyTo( TLine - 1 );
  1035. MoveAcrossTo( TheLength());
  1036. END;
  1037. | Key.Right: (*right arrow*)
  1038. IF TheNdx < TheLength() THEN
  1039. MoveAcrossTo( TheNdx + 1);
  1040. ELSIF BigSets.InSet( UserOps.FieldExitKeySet, Rec.EdLastKey ) THEN
  1041. (*We're letting the user exit from the editor
  1042. window by pressing the right arrow at the end
  1043. of the current line.*)
  1044. EXIT;
  1045. ELSIF (TLine # GenLists.ListLength( TheList)) THEN
  1046. MoveVerticallyTo( TLine + 1 );
  1047. MoveAcrossTo(0);
  1048. END;
  1049. | Key.Tab, Key.CtrlRight: (*Tab and Ctrl-RightArrow*)
  1050. IF TheNdx < TheLength() THEN
  1051. NextWord();
  1052. ELSIF BigSets.InSet( UserOps.FieldExitKeySet, Rec.EdLastKey ) THEN
  1053. (*We're letting the user exit from the editor
  1054. window by pressing the Tab or Ctrl-RightArrow if
  1055. they're in the FieldExitKeySet.*)
  1056. EXIT;
  1057. ELSE
  1058. NextWord();
  1059. END;
  1060. | Key.BackTab, Key.CtrlLeft: (*BackTab and Ctrl-LeftArrow*)
  1061. IF TheNdx>0 THEN
  1062. LastWord();
  1063. ELSIF BigSets.InSet( UserOps.FieldExitKeySet, Rec.EdLastKey ) THEN
  1064. EXIT;
  1065. ELSE
  1066. LastWord();
  1067. END;
  1068. | Key.F4 :
  1069. NextWord();
  1070. | Key.Ins :
  1071. IF NOT Rec.ReadOnly THEN
  1072. Rec.overwriting := NOT Rec.overwriting;
  1073. IF Rec.overwriting THEN
  1074. VWindows.SetCursorHeight( Rec.WindowHandle, 2 );
  1075. ELSE
  1076. VWindows.SetCursorHeight( Rec.WindowHandle, 4 );
  1077. END;
  1078. IF Rec.FrameRec # NIL THEN
  1079. SavedFore := VWindows.ForeColor( Rec.WindowHandle );
  1080. SavedBack := VWindows.BackColor( Rec.WindowHandle );
  1081. SavedAttr := VWindows.MonoAttr( Rec.WindowHandle );
  1082. SetPromptColors( Rec.FrameRec );
  1083. END;
  1084. IF Rec.DoCounting THEN
  1085. OvrOrIns( OvrStr);
  1086. VWindows.DrawStr( Rec.WindowHandle, 71, Rec.CountRow,
  1087. SYSTEM.ADR(OvrStr), M2Strings.Length(OvrStr) );
  1088. END;
  1089. IF Rec.FrameRec # NIL THEN
  1090. VWindows.SetForeColor( Rec.WindowHandle, SavedFore );
  1091. VWindows.SetBackColor( Rec.WindowHandle, SavedBack );
  1092. VWindows.SetMonoAttr( Rec.WindowHandle, SavedAttr );
  1093. END;
  1094. VWindows.GotoXY( Rec.WindowHandle,
  1095. Rec.Col1 + TheNdx - ColsScrolled, TheRow);
  1096. END;
  1097. | Key.Del :
  1098. IF NOT Rec.ReadOnly THEN
  1099. Rec.ChangeMade := TRUE;
  1100. IF TheNdx < TheLength() THEN
  1101. DeleteAChar(0);
  1102. ELSE
  1103. MoveVerticallyTo( TLine + 1 );
  1104. MoveAcrossTo( 0 );
  1105. JoinLines();
  1106. END;
  1107. END;
  1108. | Key.Home:
  1109. (* go to start of current line*)
  1110. MoveAcrossTo(0);
  1111. | Key.AltD :
  1112. IF NOT Rec.ReadOnly THEN
  1113. Rec.ChangeMade := TRUE;
  1114. DeleteALine();
  1115. END;
  1116. | Key.AltI, Key.AltU :
  1117. IF NOT Rec.ReadOnly THEN
  1118. Rec.ChangeMade := TRUE;
  1119. InsertDeleteBuffer();
  1120. END;
  1121. | Key.End: (*End*)
  1122. (* go to end of current line*)
  1123. MoveAcrossTo( TheLength());
  1124. | Key.PgUp: (*PgUp*)
  1125. IF (TLine = 1) AND
  1126. BigSets.InSet( UserOps.FieldExitKeySet, Rec.EdLastKey ) THEN
  1127. (*We're letting the user exit from the editor
  1128. window by pressing PgUp on the top line
  1129. of the file.*)
  1130. EXIT;
  1131. ELSE
  1132. PageUp();
  1133. (* go up one page *)
  1134. END;
  1135. | Key.PgDn: (*PgDn*)
  1136. IF (TLine = GenLists.ListLength(TheList)) AND
  1137. BigSets.InSet( UserOps.FieldExitKeySet, Rec.EdLastKey ) THEN
  1138. (*We're letting the user exit from the editor
  1139. window by pressing the PgDn key on the
  1140. bottom line of the file.*)
  1141. EXIT;
  1142. ELSE
  1143. PageDown();
  1144. (* go down one page *)
  1145. END;
  1146. | Key.CtrlPgUp:
  1147. (* go to top of file *)
  1148. MoveVerticallyTo( 1 );
  1149. | Key.CtrlPgDn:
  1150. (* go to end of text file *)
  1151. MoveVerticallyTo( GenLists.ListLength(TheList) );
  1152. MoveAcrossTo( TheLength() );
  1153. | Key.F7:
  1154. (* pack paragraphs starting at current line and going
  1155. down until indentation changes *)
  1156. IF (Rec.Wrapping) AND (NOT Rec.ReadOnly) THEN
  1157. Rec.ChangeMade := TRUE;
  1158. Reformat();
  1159. END;
  1160. | Key.F7 + Key.FShift:
  1161. (*ShiftF7 toggles between wrapping and not wrapping.*)
  1162. Rec.Wrapping := NOT Rec.Wrapping;
  1163. IF Rec.Wrapping AND (NOT Rec.ReadOnly) THEN
  1164. Rec.ChangeMade := TRUE;
  1165. Reformat();
  1166. END;
  1167. | Key.F8:
  1168. Testing := NOT Testing;
  1169. | Key.BackSpace :
  1170. IF NOT Rec.ReadOnly THEN
  1171. Rec.ChangeMade := TRUE;
  1172. IF TheNdx>0 THEN
  1173. DeleteAChar(1);
  1174. ELSE
  1175. JoinLines();
  1176. END;
  1177. END;
  1178. | Key.Return :
  1179. IF NOT Rec.ReadOnly THEN
  1180. Rec.ChangeMade := TRUE;
  1181. NewLine();
  1182. END;
  1183. ELSE
  1184. IF (NOT Rec.ReadOnly) AND (Rec.EdLastKey # 0)
  1185. AND (Rec.EdLastKey < KbdInput.Extended) THEN
  1186. Rec.ChangeMade := TRUE;
  1187. ReplaceWith( CHR(Rec.EdLastKey) );
  1188. END;
  1189. END;
  1190. END;
  1191. END KeyResponse;
  1192. VAR
  1193. SavedHeight, BxCol1, BxCol2, BxRow1, BxRow2 : CARDINAL;
  1194. BEGIN (*DefaultEditor*)
  1195. GetFrameRecData();
  1196. Rec.ChangeMade := FALSE;
  1197. IF Rec.Col2 < Rec.Col1 THEN
  1198. INC(Rec.Col2, Rec.Col1);
  1199. END;
  1200. ColsScrolled := 0;
  1201. LastLineDeleted := 0;
  1202. Rec.Col1 := Numbers.Between(1, Rec.Col1, DisplayLeng);
  1203. Rec.Row1 := Numbers.Between(1, Rec.Row1, Rec.Row2);
  1204. Rec.Row2 := Numbers.Between(Rec.Row1, Rec.Row2,
  1205. VWindows.EndRow(Rec.WindowHandle));
  1206. Rec.Col2 := Numbers.Between(Rec.Col1, Rec.Col2, DisplayLeng);
  1207. BxCol1 := Rec.Col1;
  1208. BxCol2 := Rec.Col2;
  1209. BxRow1 := Rec.Row1;
  1210. BxRow2 := Rec.Row2;
  1211. IF Rec.FrameRec # NIL THEN
  1212. SavedHeight := VWindows.GetCursorHeight( Rec.FrameRec^.WindowHandle );
  1213. END;
  1214. SetAttribOrColor( Rec.EntryForeBox, Rec.EntryBackBox, Rec.EntryAttrib );
  1215. CASE Rec.EntryBox OF
  1216. (* Draw Entry Box *)
  1217. 2:
  1218. VWindows.DrawBox( Rec.WindowHandle,
  1219. VWindows.DoubleBox, Rec.Col1, Rec.Row1, Rec.Col2,
  1220. Rec.Row2);
  1221. | 1:
  1222. VWindows.DrawBox( Rec.WindowHandle,
  1223. VWindows.SingleBox, Rec.Col1, Rec.Row1, Rec.Col2,
  1224. Rec.Row2);
  1225. ELSE (*do nothing*);
  1226. END;
  1227. IF (Rec.EntryBox # 0) OR (Rec.ExitBox # 0) THEN
  1228. (* Correct coordinates to the area inside the box *)
  1229. INC(Rec.Col1);
  1230. INC(Rec.Row1);
  1231. DEC(Rec.Row2);
  1232. DEC(Rec.Col2);
  1233. END;
  1234. IF Rec.DoCounting AND (Rec.Row2 >= Rec.CountRow) THEN
  1235. Rec.Row2 := Numbers.Min( Rec.Row2, Rec.CountRow - 1 );
  1236. (*This makes sure Row2 doesn't interfere with the
  1237. prompt line.*)
  1238. END;
  1239. WindowHeight := Rec.Row2 - Rec.Row1 + 1;
  1240. Rec.TextRow1 := Numbers.Between(1, Rec.TextRow1,
  1241. GenLists.ListLength(TheList));
  1242. Rec.CursorCol := Numbers.Between(1, Rec.CursorCol,
  1243. (Rec.Col2 - Rec.Col1) + 1 );
  1244. Rec.CursorRow := Numbers.Between(1, Rec.CursorRow,
  1245. WindowHeight );
  1246. Rec.CursorRow := Numbers.Between(1, Rec.CursorRow,
  1247. GenLists.ListLength(TheList) + 1 - Rec.TextRow1 );
  1248. (*We correct Rec.CursorRow again to prevent it from falling
  1249. below the bottom of TheList. Added 16 Nov 86.*)
  1250. SetAttribOrColor( Rec.EntryForeColor, Rec.EntryBackColor,
  1251. Rec.EntryAttrib );
  1252. MaxLength := (Rec.Col2 - Rec.Col1) + 1;
  1253. LowLevel.Fill( SYSTEM.ADR(BlankStr), DisplayLeng + 1, blank);
  1254. Testing := FALSE;
  1255. IF GenLists.ListLength( TheList) # 0 THEN
  1256. WriteStrings( Rec.TextRow1, Rec.Row1, Rec.Row2);
  1257. TLine := Rec.TextRow1 + Rec.CursorRow - 1;
  1258. ELSE
  1259. (* set counter to line one and clear window *)
  1260. GenLists.ListInsert( '', GenLists.StrCode, TheList, 1);
  1261. TLine := 1;
  1262. VWindows.ClearPart( Rec.WindowHandle, Rec.Col1,
  1263. Rec.Row1, Rec.Col2, Rec.Row2);
  1264. END;
  1265. TheRow := Rec.CursorRow + Rec.Row1 - 1;
  1266. TheNdx := Rec.CursorCol - 1;
  1267. CountChars( 1, RCharCnt.longi, RLineCnt, TLine, TCharCnt.longi);
  1268. TCharCnt.longi := TCharCnt.longi + Numbers.Lc( TheNdx );
  1269. IF Rec.DoCounting THEN
  1270. WriteFooter();
  1271. ELSE
  1272. RCharCnt.longi := NumTypes.L1;
  1273. RLineCnt := 1;
  1274. TCharCnt.longi := NumTypes.L1;
  1275. END;
  1276. VWindows.GotoXY( Rec.WindowHandle, Rec.Col1 +
  1277. TheNdx - ColsScrolled, TheRow);
  1278. IF Rec.overwriting THEN
  1279. VWindows.SetCursorHeight( Rec.WindowHandle, 2);
  1280. ELSE
  1281. VWindows.SetCursorHeight( Rec.WindowHandle, 4);
  1282. END;
  1283. KeyResponse();
  1284. Rec.CursorRow := (TheRow + 1) - Rec.Row1;
  1285. Rec.CursorCol := 1 + TheNdx;
  1286. Rec.TextRow1 := TLine + 1 - Rec.CursorRow;
  1287. DoExitBox := ( Rec.ExitBox # Rec.EntryBox) OR
  1288. ( Rec.ExitForeBox # Rec.EntryForeBox) OR
  1289. ( Rec.ExitBackBox # Rec.EntryBackBox) OR
  1290. ( Rec.ExitAttrib # Rec.EntryAttrib);
  1291. (* whether the exit box differs from the entry, and so must
  1292. be re-drawn *)
  1293. IF DoExitBox THEN
  1294. SetAttribOrColor( Rec.ExitForeBox, Rec.ExitBackBox, Rec.ExitAttrib );
  1295. CASE Rec.ExitBox OF
  1296. 2:
  1297. VWindows.DrawBox( Rec.WindowHandle,
  1298. VWindows.DoubleBox, BxCol1, BxRow1, BxCol2,
  1299. BxRow2);
  1300. | 1:
  1301. VWindows.DrawBox( Rec.WindowHandle,
  1302. VWindows.SingleBox, BxCol1, BxRow1, BxCol2,
  1303. BxRow2);
  1304. ELSE
  1305. VWindows.ClearPart( Rec.WindowHandle,
  1306. BxCol1, BxRow1, BxCol2, BxRow2);
  1307. END;
  1308. END;
  1309. SetAttribOrColor( Rec.ExitForeColor, Rec.ExitBackColor,
  1310. Rec.ExitAttrib );
  1311. IF (Rec.EntryForeColor # Rec.ExitForeColor) OR
  1312. (Rec.EntryBackColor # Rec.ExitBackColor) OR
  1313. (Rec.EntryAttrib # Rec.ExitAttrib) OR
  1314. (DoExitBox AND ( Rec.ExitBox = 0)) THEN
  1315. WriteStrings( TLine - (TheRow - Rec.Row1), Rec.Row1, Rec.Row2);
  1316. (* Rewrite the current screen *)
  1317. END;
  1318. IF (Rec.EntryBox # 0) OR (Rec.ExitBox # 0) THEN
  1319. (* Set coordinates back to area that includes box *)
  1320. DEC(Rec.Col1);
  1321. DEC(Rec.Row1);
  1322. INC(Rec.Row2);
  1323. INC(Rec.Col2);
  1324. END;
  1325. UpdateFrameRec();
  1326. IF Rec.FrameRec # NIL THEN
  1327. VWindows.SetCursorHeight( Rec.FrameRec^.WindowHandle, SavedHeight );
  1328. END;
  1329. END DefaultEditor;
  1330. PROCEDURE SetGlobals( VAR Rec: VEditor.AnEdControlRec );
  1331. BEGIN
  1332. overwriting := Rec.overwriting;
  1333. DoCounting := Rec.DoCounting;
  1334. MaxLines := Rec.MaxLines;
  1335. EdLastKey := Rec.EdLastKey;
  1336. ExitBox := Rec.ExitBox;
  1337. EntryBox := Rec.EntryBox;
  1338. CountRow := Rec.CountRow;
  1339. EdPromptFore := Rec.EdPromptFore;
  1340. EdPromptBack := Rec.EdPromptBack;
  1341. EdPromptAttrib := Rec.EdPromptAttrib;
  1342. EntryAttrib := Rec.EntryAttrib;
  1343. ExitAttrib := Rec.ExitAttrib;
  1344. EntryForeColor := Rec.EntryForeColor;
  1345. EntryBackColor := Rec.EntryBackColor;
  1346. ExitForeColor := Rec.ExitForeColor;
  1347. ExitBackColor := Rec.ExitBackColor;
  1348. EntryForeBox := Rec.EntryForeBox;
  1349. EntryBackBox := Rec.EntryBackBox;
  1350. ExitForeBox := Rec.ExitForeBox;
  1351. ExitBackBox := Rec.ExitBackBox;
  1352. END SetGlobals;
  1353. PROCEDURE GetGlobals( VAR Rec: VEditor.AnEdControlRec );
  1354. BEGIN
  1355. Rec.overwriting := overwriting;
  1356. Rec.DoCounting := DoCounting;
  1357. Rec.MaxLines := MaxLines;
  1358. Rec.ExitBox := ExitBox;
  1359. Rec.EntryBox := EntryBox;
  1360. Rec.CountRow := CountRow;
  1361. Rec.EdPromptFore := EdPromptFore;
  1362. Rec.EdPromptBack := EdPromptBack;
  1363. Rec.EdPromptAttrib := EdPromptAttrib;
  1364. Rec.EntryAttrib := EntryAttrib;
  1365. Rec.ExitAttrib := ExitAttrib;
  1366. Rec.EntryForeColor := EntryForeColor;
  1367. Rec.EntryBackColor := EntryBackColor;
  1368. Rec.ExitForeColor := ExitForeColor;
  1369. Rec.ExitBackColor := ExitBackColor;
  1370. Rec.EntryForeBox := EntryForeBox;
  1371. Rec.EntryBackBox := EntryBackBox;
  1372. Rec.ExitForeBox := ExitForeBox;
  1373. Rec.ExitBackBox := ExitBackBox;
  1374. END GetGlobals;
  1375. VAR
  1376. GlobalEdRec: VEditor.AnEdControlRec;
  1377. PROCEDURE ScrnEdit(Col1, Row1, Col2, Row2 : CARDINAL;
  1378. VAR TheList : GenLists.GenList; VAR TextRow1, CursorCol,
  1379. CursorRow: CARDINAL; VAR ChangeMade: BOOLEAN;
  1380. ReadOnly: BOOLEAN; VAR FrameRec: ScrnTypes.DisplayFrame): INTEGER;
  1381. VAR
  1382. LocalRec : VEditor.AnEdControlRec;
  1383. tmpint: INTEGER;
  1384. BEGIN
  1385. VEditor.InitEdRec( LocalRec );
  1386. GetGlobals( LocalRec );
  1387. LocalRec.Wrapping := FALSE;
  1388. LocalRec.NextFrame := '';
  1389. LocalRec.Col1 := Col1;
  1390. LocalRec.Row1 := Row1;
  1391. LocalRec.Col2 := Col2;
  1392. LocalRec.Row2 := Row2;
  1393. LocalRec.TextRow1 := TextRow1;
  1394. LocalRec.CursorCol := CursorCol;
  1395. LocalRec.CursorRow := CursorRow;
  1396. LocalRec.ChangeMade := ChangeMade;
  1397. LocalRec.ReadOnly := ReadOnly;
  1398. LocalRec.FrameRec := FrameRec;
  1399. DefaultEditor( TheList, LocalRec );
  1400. TextRow1 := LocalRec.TextRow1;
  1401. CursorCol := LocalRec.CursorCol;
  1402. CursorRow := LocalRec.CursorRow;
  1403. ChangeMade := LocalRec.ChangeMade;
  1404. IF StrConv.StrToInteger( LocalRec.NextFrame, 0, tmpint ) THEN
  1405. RETURN tmpint;
  1406. ELSE
  1407. RETURN 0;
  1408. END;
  1409. END ScrnEdit;
  1410. PROCEDURE Init();
  1411. BEGIN
  1412. IF Initialized THEN
  1413. RETURN;
  1414. ELSE
  1415. Initialized := TRUE;
  1416. END;
  1417. (*EntryDiag:
  1418. Diagnostics.Init();
  1419. :EntryDiag*)
  1420. BigSets.Init();
  1421. ByteFiddler.Init();
  1422. GenLists.Init();
  1423. KbdInput.Init();
  1424. Key.Init();
  1425. ListUtils.Init();
  1426. LowLevel.Init();
  1427. M2Strings.Init();
  1428. MsColors.Init();
  1429. Numbers.Init();
  1430. NumTypes.Init();
  1431. PosUtils.Init();
  1432. ScrnTypes.Init();
  1433. ScrnUtl1.Init();
  1434. Spkr.Init();
  1435. StrConv.Init();
  1436. StrEdit.Init();
  1437. UserOps.Init();
  1438. VEditor.Init();
  1439. VWindows.Init();
  1440. (*EntryDiag:
  1441. Diagnostics.diagS( 'Entering Editor', '' );
  1442. :EntryDiag*)
  1443. VEditor.InitEdRec( GlobalEdRec );
  1444. SetGlobals( GlobalEdRec );
  1445. blank[0] := ' ';
  1446. GenLists.NilList( DeleteBuffer );
  1447. (*EntryDiag:
  1448. Diagnostics.diagS( 'Exiting Editor', '' );
  1449. :EntryDiag*)
  1450. END Init;
  1451. BEGIN
  1452. Initialized := FALSE;
  1453. Init();
  1454. END Editor.