易码技术论坛

 找回密码
 加入易码
搜索
查看: 63451|回复: 2

[求助]谁有MrBlock0x的Inputw函数

[复制链接]
发表于 2005-4-27 22:57:00 | 显示全部楼层
楼上的指的什么东东?是C么?
发表于 2005-4-27 23:01:00 | 显示全部楼层
支持lavax1.0

  1. long inputw(long object,char maxlenth,char start,char type)
  2. {
  3. //Basic module.
  4. //object: It desides where to store the input string.
  5. //maxlenth: It desides how many characters can be input once at the most.
  6. //start: It decides where to start inputing string on the screen.
  7. //type: bit 0~1:getword mode; bit 2:1 clear object before input; bit 3:1 ESC=Enter, bit 4:1 Blank string allowed
  8. //It will return how many characters are input, and -1 means user pressed ESC when bit3 equals 0.
  9. //Its disadvantage is that you can't input characters more than one screen.
  10. //Common keyborad is demanded.
  11. //Operation: Left, right, up, down; PageUp: clear the string; F3: go to the start; F4: go to the end.
  12.     char i,col,row;
  13.     char cc,cr,ch;
  14.     char insmd;
  15.     char inpmd;
  16.     int word[2];
  17.     char hz;
  18.     char bk;
  19.     char fl;
  20.     char lenth;
  21.     int n;
  22.     hz=0;
  23.     insmd=0;
  24.     inpmd=0;
  25.     row=start/20;
  26.     col=start%20;
  27.     if (type & 4)
  28.     {
  29.         memset (object,0,maxlenth);
  30.     }
  31.     inpmd=type & 3;
  32.     lenth=strlen(object);
  33.     n=lenth;
  34.     for (;;)
  35.     {
  36.         lenth=strlen(object);
  37.         if (n>lenth)
  38.         {
  39.             n=lenth;
  40.         }
  41.         fl=n;
  42.         memset (_TEXT+start,0,100-start);
  43.         Locate (row,col);
  44.         printf("%s",object);
  45.         //利用printf自动在屏幕上排版
  46.         bk=0;
  47.         i=row;
  48.         while (i*20+18<start+fl)
  49.         {
  50.             if (*(_TEXT+i*20+19)==0)
  51.             {
  52.                 fl++;
  53.             }
  54.             if (*(_TEXT+i*20+19)==32)
  55.             {
  56.                 if (*(object+i*20+19-start-fl+n)!=32)
  57.                 {
  58.                     fl++;
  59.                 }
  60.             }
  61.             i++;
  62.         }
  63.         cr=(start+fl)/20;
  64.         cc=(start+fl)%20;
  65.         if ((cc==0)&&(n==lenth))
  66.         {
  67.             word[0]=start+fl-1;
  68.             if (word[0]>start)
  69.             {
  70.                 if (*(_TEXT+word[0])==0)
  71.                 {
  72.                     fl--;
  73.                 }
  74.                 if (*(_TEXT+word[0])==32)
  75.                 {
  76.                     if (*(object+strlen(object)-1)!=32)
  77.                     {
  78.                         fl--;
  79.                     }
  80.                 }
  81.             }
  82.             cr=(start+fl)/20;
  83.             cc=(start+fl)%20;
  84.         }
  85.         if (*(object+n)&128)
  86.         {
  87.             ch=2;
  88.         } else {
  89.             ch=1;
  90.         }
  91.         if (insmd==1)
  92.         {
  93.             Box(8*cc,16*cr,8*(cc+ch)-1,16*(cr+1)-1,1,2);
  94.         } else {
  95.             Line(8*cc,16*cr+15,8*(cc+ch),16*cr+15,2);
  96.         }
  97.         word[0]=GetWord(inpmd);
  98.         inpmd=3;
  99.         ch=word[0]&255;
  100.         if (ch&96)
  101.         {
  102.             if (ch&128)
  103.             {
  104.                 bk=2;
  105.             } else {
  106.                 bk=1;
  107.             }
  108.             if ((insmd==0)||(n==lenth))
  109.             {
  110.                 i=0;
  111.             } else {
  112.                 if (*(object+n)&128)
  113.                 {
  114.                     i=2;
  115.                 } else {
  116.                     i=1;
  117.                 }
  118.             }
  119.             if (lenth+bk-i>=maxlenth)
  120.             {
  121.                 Beep();
  122.                 continue;
  123.             }
  124.             if (bk-i)
  125.             {
  126.                 memmove (object+n,object+n-bk+i,strlen(object+n)+1+bk-i);
  127.             }
  128.             memcpy (object+n,word,bk);
  129.             if (n==lenth)
  130.             {
  131.                 n=strlen(object);
  132.                 continue;
  133.             }
  134.             n++;
  135.             if (word[0]&128)
  136.             {
  137.                 n++;
  138.             }
  139.             continue;
  140.         } else if (ch==LT_KEY)
  141.         {
  142.             n--;
  143.             if (*(object+n)&128)
  144.             {
  145.                 n--;
  146.             }
  147.             if (n<0)
  148.             {
  149.                 n=lenth;
  150.             }
  151.             continue;
  152.         } else if (ch==RT_KEY)
  153.         {
  154.             n++;
  155.             if (*(object+n-1)&128)
  156.             {
  157.                 n++;
  158.             }
  159.             if (n>lenth)
  160.             {
  161.                 n=0;
  162.             }
  163.             continue;
  164.         } else if (ch==UP_KEY)
  165.         //对于上下键要特别注意移行后的中文
  166.         {
  167.             if (n<21)
  168.             {
  169.                 n=0;
  170.                 continue;
  171.             }
  172.             if (*(object+n-21)&128==0)
  173.             {
  174.                 n=n-21;
  175.                 continue;
  176.             }
  177.             bk=0;
  178.             for (i=n-1;i>n-21;i--)
  179.             {
  180.                 bk=bk^*(object+i);
  181.             }
  182.             //逐一检查之间的字节中最高位为1的字节个数
  183.             //通过奇偶判断
  184.             if (bk&128)
  185.             {
  186.                 n=n-21;
  187.             } else {
  188.                 n=n-20;
  189.             }
  190.             if (n<0)
  191.             {
  192.                 n=0;
  193.             }
  194.             continue;
  195.         } else if (ch==DN_KEY)
  196.         {
  197.             if (n+21>lenth)
  198.             {
  199.                 n=lenth;
  200.                 continue;
  201.             }
  202.             if (*(object+n+21)&128==0)
  203.             {
  204.                 n=n+21;
  205.                 continue;
  206.             }
  207.             bk=0;
  208.             for (i=n;i<n+20;i++)
  209.             {
  210.                 bk=bk^*(object+i);
  211.             }
  212.             if (bk&128)
  213.             {
  214.                 n=n+21;
  215.             } else {
  216.                 n=n+20;
  217.             }
  218.             if (n>lenth)
  219.             {
  220.                 n=lenth;
  221.             }
  222.             continue;
  223.         } else if (ch==F2_KEY&&lenth)
  224.         {
  225.             bk=0;
  226.             if (n^lenth)
  227.             {
  228.                 if (*(object+n)&128)
  229.                 {
  230.                     i=2;
  231.                 } else {
  232.                     i=1;
  233.                 }
  234.                 memmove (object+n,object+n+i,strlen(object+n)+1-i);
  235.             } else {
  236.                 n--;
  237.                 if (*(object+n)&128)
  238.                 {
  239.                     n--;
  240.                     memset(object+n,0,2);
  241.                 } else {
  242.                     *(object+n)=0;
  243.                 }
  244.             }
  245.             continue;
  246.         } else if (ch==F3_KEY)
  247.         {
  248.             n=0;
  249.             continue;
  250.         } else if (ch==F4_KEY)
  251.         {
  252.             n=lenth;
  253.             continue;
  254.         } else if (ch==ENTER_KEY)
  255.         {
  256. GtRt:
  257.             lenth=strlen(object);
  258.             memset (object+lenth,0,maxlenth-lenth);
  259.             SetScreen (1);
  260.             if ((lenth==0)&&(type&16==0))
  261.             {
  262.                 return -1;
  263.             } else {
  264.                 return lenth;
  265.             }
  266.         } else if (ch==ESC_KEY)
  267.         {
  268.             if (type&8)
  269.             {
  270.                 goto GtRt;
  271.             } else {
  272.                 memset (object,0,maxlenth);
  273.                 SetScreen (1);
  274.                 return -1;
  275.             }
  276.         } else if (ch==F1_KEY)
  277.         {
  278.             insmd=1-insmd;
  279.         } else if (ch==PU_KEY)
  280.         {
  281.             memset (object,0,maxlenth);
  282.             n=0;
  283.         }
  284.     }
  285. }
复制代码

 楼主| 发表于 2005-4-5 00:10:41 | 显示全部楼层 |阅读模式
如题...有的发个上来

先谢啦
您需要登录后才可以回帖 登录 | 加入易码

本版积分规则

Archiver|手机版|小黑屋|EMAX Studio

GMT+8, 2025-6-15 15:01 , Processed in 0.010269 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表