home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22033 < prev    next >
Encoding:
Text File  |  1993-01-24  |  1.9 KB  |  57 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!convex!convex!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!news.funet.fi!funic!nntp.hut.fi!cs.hut.fi!aleskine
  3. From: aleskine@cs.hut.fi (Arto Leskinen)
  4. Subject: reading multibyte chars
  5. Message-ID: <ALESKINE.93Jan23204652@cardhu.cs.hut.fi>
  6. Lines: 43
  7. Sender: usenet@nntp.hut.fi (Usenet pseudouser id)
  8. Nntp-Posting-Host: cardhu.cs.hut.fi
  9. Organization: Helsinki University of Technology, Finland
  10. Distribution: comp.sys.mac.programmer
  11. Date: Sat, 23 Jan 1993 18:47:03 GMT
  12. Lines: 43
  13.  
  14. I have following code for eventloop (important parts)
  15. do {
  16.   SystemTask ();
  17.   mTIdle( NULL );
  18.   if (GetNextEvent (everyEvent, &event))
  19.   {
  20.     switch (event.what) {
  21.       case keyDown:
  22.     doKeyDown(&event);
  23.         break;
  24.   ...
  25.     }
  26.   }
  27. } while (..);
  28. and following in the part where i read characters. But this does not work
  29. with 2 byte chars. I only get one keydown event for 2 byte chars. 
  30. ...
  31. switch (CharByte(&c,0)) {
  32. case smFirstByte:         /*First byte of multi byte char*/
  33.   doubleByte[0] = c;
  34.   break;
  35. case smLastByte:        /*Last byte of multi byte char*/
  36.   doubleByte[1] = c;
  37.   addChars(mTRecH, doubleByte,2);    /*Changes currChar, charsTotal */
  38.   line = (*mTRecH)->currLine;
  39.   calcLines(mTRecH, line);
  40.   drawLines(mTRecH, line);    /* Changes lineStarts, currLine */
  41.   mTCalcCaretVPos(mTRecH);     /* Puts the selRect into new place */
  42.   break;
  43. case smSingleByte:                /*Single byte char*/
  44.   addChar(mTRecH, c);
  45.   line = (*mTRecH)->currLine;
  46.   calcLines(mTRecH, line);
  47.   drawLines(mTRecH, line);    /* Changes lineStarts, currLine */    
  48.   mTCalcCaretVPos(mTRecH);     /* Puts the selRect into new place */
  49. }
  50. What is wrong here? addChar does like it sounds, calcLines updates linestart 
  51. array, drawlines draws current and following lines and mtCalcCaretVPos keeps
  52. track of carets place.
  53. I would love to hear any ideas. Thank you.
  54. Arto Leskinen.
  55. aleskine@cs.hut.fi
  56.  
  57.