Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!lll-winken!uwm.edu!linac!att!oucsboss!oucsace!tswingle From: tswingle@oucsace.cs.OHIOU.EDU (Tom Swingle) Newsgroups: comp.lang.pascal Subject: Re: Reading characters in graphics mode Message-ID: <3528@oucsace.cs.OHIOU.EDU> Date: 18 Jun 91 05:32:22 GMT References: <1991Jun14.150309.5126@cunixf.cc.columbia.edu> Organization: Ohio University CS Dept., Athens Lines: 55 In article <1991Jun14.150309.5126@cunixf.cc.columbia.edu> stone@cunixb.cc.columbia.edu (Glenn Stone) writes: >There must an easy way to do this but I seem to have a mental block. >I'm writing a graphics mode equivalent of READLN(StringVariable) in >TP 5.5. This loop reads characters and tacks them onto a string >called T. The problem is in dealing with the backspace; I want the >pointer to back up and erase the last character, but the ' ' in >graphics mode doesn't do this. I need the equivalent of ClrEol. >How do you do it? Thanks in advance... > > done := false; > t := ''; > repeat > c := ReadKey; > case c of > #13 : done := true; { CR } > #8 : begin { backspace } > OutTextXY(GetX-TextWidth(t[length(t)]),GetY,' '); ^ ^ |--- Replace this line as described below ---| > delete(t,length(t),1); > end; > else begin { append char } > t := t + c; > MoveTo(x,y); > OutText(t); > end; > end; > until done; How about, before each character is added to the string and printed on the screen, using GetImage to save a piece of screen of width TextWidth(c) and height TextHeight(c) right under where the character is to go. Then, rather than an OutTextXY call to delete a character, use a call to PutImage to put back the area that was saved. What you will probably need is an array of tiny buffers large enough to hold a screen image the size of the largest character that could be printed. Then, as you read characters, store the characters in the string, and at the same time, store the corresponding screen images in the array of buffers. The array of buffers would need to contain the same number of buffers as the maximum length of the string to be read. Of course, if you know that the screen under the character to be printed will be blank, all you need is a call to Bar with the drawing color set to the current background color. The width of the bar should be TextWidth(c), and the height should be TextHeight(c). If you're not familiar with these procedures, mail me and I will provide more details. It's too late at night right now to come up with good explanations of the procedures, but I assume you would be familiar with them since you are creating a graphics application. I hope I have been clear enough with this explanation. It's late and I really should be in bed. -- "The problem you are experiencing is | "To be sure of hitting the target, not with the network nor with the | shoot first and, whatever you hit, station. Please adjust your set." | call it the target."