// F E D I T L O O P (PREPRESS) // // FEDIT -- font editor for low resolution fonts. // //Bcpl/f FEditLoop.bcpl // //Last modified February 5, 1980 1:16 PM by Kerry A. LaPrade, XEOS // Split out initialization stuff. Added full octal capability // for "Show TypeIn". Reworked "File Character" section of // user interface. //Modified: December 17, 1979 10:40 AM (by LaPrade) // Added gnat to update box; changed Consec box default //Modified: December 10, 1979 11:15 AM (by LaPrade) //Modified: December 3, 1979 10:52 AM (by LaPrade) //Modified: November 30, 1979 9:47 AM (by LaPrade) //Modified: September 12, 1978 (by LaPrade) get "AuxiliaryMenuDefs.d" get "FEdit.DFS" get "FEditNames.d" // outgoing procedures external [ ClearEditWindow FEditLoop WriteCharCodes ] // outgoing statics external [ @backgroundArea @backgroundOn @backgroundView @bits //bits!0 = #100000 @currentCharacterCode //0 to 377b @currentCharacterWidths @editBox @editBoxXSize @editBoxYSize @EFactorX //Enlargement factor of background @EFactorY @FEditMenu @foregroundView @readBBT @readBit @showBox @showBoxXSize @showBoxYSize @showTypeInString @updateBox @WidthChanged //true if width marker moved @WidthMarker //Vector of width information (index by border #) ] static [ @backgroundArea @backgroundOn = true @backgroundView @bits //bits!0 = #100000 @currentCharacterCode = 377b //0 to 377b @currentCharacterWidths @editBox @editBoxXSize @editBoxYSize @EFactorX //Enlargement factor of background @EFactorY @FEditMenu @foregroundView @readBBT @readBit @showBox @showBoxXSize @showBoxYSize @showTypeInString @updateBox @WidthChanged = false //true if width marker moved @WidthMarker //Vector of width information (index by border #) ] // incoming procedures external [ //FEDITFILE // Area EditFindChar EditReadChar EditUnWriteChar EditWriteChar // EFileFinish // EFileStart //FEDITUTIL FEditMemoryAlloc FlipGrid PaintString PaintWidthMarker ReadCharBit TurnGridOff WriteCharBit //FLOAT FDV FLDI //PREPRESSUTIL FSGetX FSPut IllCommand //SCAN AppendChar SearchChar StringToValue TypeForm //STRINGSTREAMS CreateStringStream //STRINGUTIL CopyString ExtractSubstring ] // incoming statics external [ //FEDITFILE @LastCharCodeWritten //FEDITUTIL @gridIsDesired //True if user wants grid displayed @gridIsOn //True if grid is on //PREPRESSMENU1 @selectedBoxNum @selectedButton ] // internal statics static [ editState currentBackgroundOffsetx //Current background offset in x. currentBackgroundOffsety // ditto for y cursorPattern gnatIsDesired = true needToGetBackground startSequenceChar = 0 widthsMode = false ] manifest [ backSpace = 10b editStateGetDelete = 1 editStatePutCancel = 2 editStateGetUnwrite = 3 ] //Procedures //********************************************************* let FEditLoop() be //********************************************************* [FEditLoop [EditLooprepeat unless (gridIsDesired eqv gridIsOn) do FlipGrid() //Poll "active" boxes. // ScanMenu(Menu, loopOverMenu [true], returnKey [false], sweep [false]) let s = ScanMenu(FEditMenu, false, true) selectedBoxNum = s<>VIEW.dotSize let dy = - (xyPair2!1 - xyPair1!1) / backgroundView>>VIEW.dotSize GetBackground(currentCharacterCode, currentBackgroundOffsetx + dx, currentBackgroundOffsety + dy) return // break ] ] repeatuntil CursorInside(FEditMenu!bShiftBackground) & GetButtons() ] ] while GetButtons() do Noop() ] //********************************************************* and ActivateWidths() be //********************************************************* [ OutlineBorderBoxes(black) let t = table [ 000000b; 000000b; 000000b; 000000b; 000400b; 000400b; 000400b; 007740b; 000400b; 000400b; 000400b; 000000b; 000000b; 000000b; 000000b; 000000b; ] cursorPattern = t ChangeCursor(cursorPattern) needToGetBackground = false widthsMode = true ] //********************************************************* and TickMarks() be //********************************************************* [ CheckTickMark(bLeftBorder, left, 1) CheckTickMark(bRightBorder, right, 1) CheckTickMark(bBottomBorder, bottom, 0) CheckTickMark(bTopBorder, top, 0) ] //********************************************************* and CheckTickMark(borderBoxNum, border, n) be //********************************************************* [ // n = 0 if interested in x coordinate // n = 1 if interested in y coordinate let xyPair = vec 1 if CursorInside2(FEditMenu!borderBoxNum, 4, 4, xyPair) & GetButtons() then [ ChangeBoxes(editStatePutCancel) PaintWidthMarker(border, (n * foregroundView>>VIEW.nDotsY) + (1 - 2 * n) * (xyPair!n / (foregroundView>>VIEW.dotSize))) WidthChanged = true if (border eq left) % (border eq bottom) then needToGetBackground = true ] ] //********************************************************* and DeActivateWidths() be //********************************************************* [ ChangeCursor(cursorPattern) OutlineBorderBoxes(white) if needToGetBackground then GetBackground(currentCharacterCode, currentBackgroundOffsetx, currentBackgroundOffsety) FillBox(FEditMenu!bWidths, flip) widthsMode = false ] //********************************************************* and OutlineBorderBoxes (color) be //********************************************************* [ OutlineBox(FEditMenu!bLeftBorder, 1, color) OutlineBox(FEditMenu!bRightBorder, 1, color) OutlineBox(FEditMenu!bBottomBorder, 1, color) OutlineBox(FEditMenu!bTopBorder, 1, color) ] //********************************************************* and Show() be //********************************************************* [ let string = vec 127 switchon selectedBoxNum into [ case bShowSequence: [ string!0 = 0 unless selectedButton eq 3 do [ until Endofs(keys) do Gets(keys) Ws("Start string with: ") startSequenceChar = Gets(keys) if startSequenceChar eq $*N then startSequenceChar = currentCharacterCode Puts(dsp, startSequenceChar); Wl("") ] for I = startSequenceChar to startSequenceChar + 376b do AppendChar(((I gr 377b)?I - 400b, I), string) endcase ] case bShowTypeIn: unless selectedButton eq 3 do [ let numberString = nil let numberPosition = nil let char = nil until Endofs(keys) do Gets(keys) OverwriteBox(FEditMenu!bShowBox, showTypeInString) FillBox(showBox, flip) char = Gets(keys) unless char eq $*n do [ showTypeInString!0 = 0 [ switchon char into [ case $*n: break endcase case backSpace: unless showTypeInString>> STRING.length eq 0 do showTypeInString>> STRING.length = showTypeInString>> STRING.length - 1 endcase case $x: test kbdAd!3 eq 177773b ifso [ numberPosition = valof [ for I = showTypeInString>> STRING.length to 1 by -1 do if showTypeInString>> STRING.char^I eq $# then resultis I resultis 0 ] if numberPosition gr 0 then [ numberString = ExtractSubstring(showTypeInString, numberPosition + 1) if numberString>> STRING.length le 3 then [ showTypeInString>> STRING.length = numberPosition - 1 AppendChar(StringToValue(numberString, 8), showTypeInString) ] Free(sysZone, numberString) ] ] ifnot AppendChar(char, showTypeInString) endcase default: AppendChar(char, showTypeInString) endcase ] OverwriteBox(showBox, showTypeInString) FillBox(showBox, flip) char = Gets(keys) ] repeat ] ] CopyString(string, showTypeInString) endcase case bShowBox: string!0 = 0 let tempChar = (selectedButton eq 3) ? currentCharacterCode, $H AppendChar(tempChar, string) AppendChar(currentCharacterCode, string) AppendChar(tempChar, string) endcase ] //end switchon if SearchChar(string, currentCharacterCode) then PutChar() PaintString(string) if selectedBoxNum eq bShowBox then FillBox(showBox, flip) ] //********************************************************* and Draw() be //********************************************************* [Draw let xyPair, squareSize = vec 1, foregroundView>>VIEW.dotSize let lastX, strokeBeginX, lastY, strokeBeginY = -1, -1, nil, nil while CursorInside2(editBox, -4, -4, xyPair) do [ let x = xyPair!0 / squareSize let y = (editBoxYSize - xyPair!1) / squareSize //foregroundView>>VIEW.nDotsY - xyPair!1 / squareSize if x ne lastX % y ne lastY then [ FlipGnat(lastX, lastY) //Gets clipped if lastX ls 0 FlipGnat(x, y) lastX, lastY = x, y ] let buttons = GetButtons() test buttons ifso [ let paint, string = true, "Flip" test buttons<>VIEW.nDotsY - y - 1, 1, 1) //********************************************************* and GetButtons() = (not @177030b) & 7 //********************************************************* //********************************************************* and ChangeBoxes(newEditState; numargs na) be //********************************************************* [ DefaultArgs(lv na, 0, editStateGetDelete) editState = newEditState let string, inactive = nil, true OverwriteBox(FEditMenu!bGetPut, "Get") switchon editState into [ case editStateGetDelete: string = "Delete" inactive = false endcase case editStatePutCancel: OverwriteBox(FEditMenu!bGetPut, "Put") string = "Cancel" endcase case editStateGetUnwrite: string = "Unput" endcase ] OverwriteBox(FEditMenu!bDeleteCancelUnwrite, string) (FEditMenu!bSymbol) >>BOX.inactive = inactive (FEditMenu!bOctal) >>BOX.inactive = inactive ] //********************************************************* and DeleteCancelUnwrite(s) be //********************************************************* [ switchon editState into [ //Delete case editStateGetDelete: unless ConfirmMenuSelection("Remove this character from file?", s) do return DeleteThisCharacter() ClearEditWindow() endcase //Cancel case editStatePutCancel: PartialFillBox(editBox, grayFlip, 0) unless ConfirmMenuSelection("Wipe the screen?", s) do [ PartialFillBox(editBox, grayFlip, 0) return ] ClearEditWindow() NewChar() endcase //Unwrite case editStateGetUnwrite: PartialFillBox(editBox, grayFlip, 0) test ConfirmMenuSelection("*"Undo*" previously-Put changes to this character?", s) ifso [ Wl("Reverting to prior version of this character.") EditUnWriteChar(currentCharacterCode) ClearEditWindow() NewChar(selectedButton ne 2) ChangeBoxes(editStatePutCancel) PutChar() ] ifnot [ PartialFillBox(editBox, grayFlip, 0) return ] endcase ] FillBox(FEditMenu!bDeleteCancelUnwrite, flip) ] //********************************************************* and Area() be //********************************************************* [ //Compute area of char on screen let ar = 0 Wl("Computing area") for x = 0 to foregroundView>>VIEW.nDotsX - 1 do for y = 0 to foregroundView>>VIEW.nDotsY - 1 do if ReadCharBit(foregroundView, x, y) then ar = ar + 1 TypeForm("Area: ", 10, ar, ". Background area: ") FLDI(1, backgroundArea) FLDI(2, EFactorX); FLDI(3, EFactorY) FDV(1, 2); FDV(1, 3) TypeForm(2, 1, 0) ]