📄 ws_text_op.h
字号:
/*************************************************** Copyright(C), 2008 , JUST File name: ws_text_op.h Author: StevenZ Version: 0.9 Date: 080906 Description: 点划式网页浏览器层次结构的显示与 正文(三种正文类型)操作 History: 08/07/25 完成单击,双击,上下划动判断 08/08/06 完成按键位置设置 08/08/15 完成页面层次结构的显示 08/08/16 添加语音合成函数 ***************************************************/#ifndef _WS_TEXT_OP_H#define _WS_TEXT_OP_H#include "ws_share_func.h"//公用的相关函数int WebShow_InWhichArea(TS_RET *p);void get_L_ip_port(char ip_port[],char *Ltext);void get_L_text(char text[],char *Ltext);int can_forward(struct websitedata *wsd);void do_forward(struct websitedata *wsd);int can_backward(struct websitedata *wsd);void do_backward(struct websitedata *wsd);int can_link_or_enter(struct websitedata *wsd);void do_web_link(struct websitedata *wsd);void do_text_enter(struct Web_Data *wd);void do_blank_fill(struct websitedata *wsd);void do_web_show_double_click(struct websitedata *wsd);void do_text_up(struct websitedata *wsd);void do_text_down(struct websitedata *wsd);void do_text_stay(struct websitedata *wsd);void * web_show_click(void *data);void web_show(struct websitedata *wsd);void show_wsd(struct websitedata *wsd);void play_mp3();/*判断点了触摸屏具体位置*/int WebShow_InWhichArea(TS_RET *p){ if(p->x<LFA) { if(p->y>MYA) return FAVOR; return BACKWARD; } if(p->x>RFA) { if(p->y>MYA) return WEB_SAVE; return FLUSH; } if(p->y>TYA) return WEB_ADDR; if(p->y<BYA) return EXIT_BACK; return 0;}/*得到tflag=IP_PORT_D时text的网页地址*/void get_L_ip_port(char ip_port[],char *Ltext){ int i,j; for(i=0;;i++) { if(Ltext[i]=='\"') break; } i++; for(j=0;;i++,j++) { if(Ltext[i]=='\"') break; ip_port[j]=Ltext[i]; } ip_port[j]='\0';}/*得到tflag=TEXT_D时text的正文内容*/void get_L_text(char text[],char *Ltext){ int i; for(i=0;;i++) { if(Ltext[i]=='\"') break; text[i]=Ltext[i]; } text[i]='\0';}/*判断是否可以前进,未在程序中使用*/int can_forward(struct websitedata *wsd){ if(wsd->web_data[wsd->website_head].can_text_forward>0) return 1; if(wsd->website_head>=wsd->website_tail) { if(wsd->website_head-wsd->website_tail<wsd->website_total) return 2; } else { if(wsd->website_head+WEBDATASIZE-wsd->website_tail<wsd->website_total) return 2; } return 0;}/*前进处理函数*/void do_forward(struct websitedata *wsd){ int cf; struct Web_Data* wd=&wsd->web_data[wsd->website_head]; cf=can_forward(wsd); switch(cf) { case 1: wd->current=wd->current->child; wd->can_text_backward++; wd->can_text_forward--; break; case 2: NEED_DOWNLOAD_WEB=1; break; default: //语音提示不可前进#ifdef TTS T2S_t2s("不可前进");#endif }}/*判断是否可以后退,及正文级后退还是网页级后退*/int can_backward(struct websitedata *wsd){ DPRINTF("wsd->website_total=%d\n",wsd->website_total); DPRINTF("wsd->website_head=%d\n",wsd->website_head); DPRINTF("wsd->website_tail=%d\n",wsd->website_tail); if(wsd->web_data[wsd->website_head].can_text_backward>0) return 1;//正文级后退 if(wsd->website_head!=wsd->website_tail) { return 2;//网页级后退 } return 0;//不可后退}/*执行后退*/void do_backward(struct websitedata *wsd){ int bf; char temp[1024]; struct Web_Data* wd=&wsd->web_data[wsd->website_head]; bf=can_backward(wsd); switch(bf) { case 1:/*返回至上一级正文*/ DPRINTF("text backward!\n"); for(;;) { if(wd->current->prev==NULL) break; wd->current=wd->current->prev; } wd->current=wd->current->parent; wd->can_text_backward--; wd->can_text_forward++; //语音读出当前text#ifdef TTS switch(wd->current->tflag) { case TEXT_D: strcpy(temp,wd->current->text); if(wd->current->child!=NULL) { strcat(temp,".可进入"); } T2S_t2s(temp); break; case IP_PORT_D: get_L_text(temp,wd->current->text); strcat(temp,".可链接"); T2S_t2s(temp); break; case BLANK_D: T2S_t2s("表单,请双击填写"); break; }#endif DPRINTF("%s\n",wd->current->text); break; case 2: DPRINTF("link backward!\n"); /*网页指针指向上一次打开的网页,返回至上一个网页的进入处*/ if(wsd->website_head-1<0) wsd->website_head=WEBDATASIZE-1; else wsd->website_head--; wsd->website_total--; break; default: //语音提示不可后退#ifdef TTS T2S_t2s("不可后退");#endif DPRINTF("can't backward!!\n"); }}/*判断双击进入的类型,正文级还是网页级*/int can_link_or_enter(struct websitedata *wsd){ if(wsd->web_data[wsd->website_head].current->tflag==IP_PORT_D) { return 1; } if(wsd->web_data[wsd->website_head].current->tflag==BLANK_D) { return 3; } if(wsd->web_data[wsd->website_head].current->child!=NULL) { return 2; } return 0;}static void get_ip(char *s){ int i=0; if(strncmp(s,"http://",7)==0) { i=7; } for(;;i++) { if(s[i]=='/'||s[i]=='\0') break; } if(s[i]=='\0') s[i]='/'; s[i+1]='\0';}static void add_ip_port(char *des,char *ip_port){ char t_des[255]; char t_ip_port[100]; int i,n=strlen(des),count=0; printf("des=%s\nip_port=%s\n",des,ip_port); //sleep(1); if(strncmp(des,"http",4)==0) return; strcpy(t_ip_port,ip_port); get_ip(t_ip_port); printf("get_ip=%s\n",t_ip_port); //sleep(1); strcpy(t_des,des); sprintf(des,"%s%s",t_ip_port,t_des); printf("end des=%s\n",des); //sleep(1); }/*网页进入新的链接网页*/void do_web_link(struct websitedata *wsd) { char temp[255]; /*得到要进入的网页地址*/ get_L_ip_port(temp,wsd->web_data[wsd->website_head].current->text); /*如果没有ip头加ip头*/ add_ip_port(temp,wsd->web_data[wsd->website_head].ip_port); /*使网页指针指向下一个空网页,以便给空网页输入网址*/ if(wsd->website_total!=0) { if((wsd->website_head+1)%WEBDATASIZE==wsd->website_tail) { wsd->website_tail=(wsd->website_tail+1)%WEBDATASIZE; wsd->website_head=(wsd->website_head+1)%WEBDATASIZE; wsd->website_total=10; } else { wsd->website_head=(wsd->website_head+1)%WEBDATASIZE; wsd->website_total++; } } else { wsd->website_total++; } /*将所选的网址信息拷给wsd*/ if(wsd->web_data[wsd->website_head].ip_port) {//清空ip_port free(wsd->web_data[wsd->website_head].ip_port); } wsd->web_data[wsd->website_head].ip_port=(char *)malloc(strlen(temp)+1); strcpy(wsd->web_data[wsd->website_head].ip_port,temp); /*重新下载*/ NEED_DOWNLOAD_WEB=1;}/*进入正文下一级*/void do_text_enter(struct Web_Data *wd){ char temp[1024]; DPRINTF("text entered!\n"); wd->current=wd->current->child; wd->can_text_backward++; wd->can_text_forward--; //语音输出第一个正文或无内容 DPRINTF("wd->current->tflag=%d\n",wd->current->tflag);#ifdef TTS switch(wd->current->tflag) { case TEXT_D: strcpy(temp,wd->current->text); if(wd->current->child!=NULL) { strcat(temp,".可进入"); } T2S_t2s(temp); break; case IP_PORT_D: get_L_text(temp,wd->current->text); strcat(temp,".可链接"); T2S_t2s(temp); break; case BLANK_D: T2S_t2s("表单,请双击填写"); break; }#endif DPRINTF("%s\n",wd->current->text); }/*进行表单操作*/void do_blank_fill(struct websitedata *wsd){ int i,submit_i=0,flg=0; struct Web_Data *wd=&wsd->web_data[wsd->website_head]; BLANK *pblk=wd->current->text; char temp[1000]; DPRINTF("wsd->web_data[wsd->website_head].current->tflag=%d\n", wsd->web_data[wsd->website_head].current->text); DPRINTF("pblk->input_num=%d\n",pblk->input_num); /*依次填写表单*/ for(i=0;i<pblk->input_num;i++) { DPRINTF("(pblk->type_h)[%d]=%s\n",i,(pblk->type_h)[i]); switch((pblk->type_h)[i][0]) { case 't'://text#ifdef TTS strcpy(temp,"请输入"); strcat(temp,(pblk->note_h)[i]); DPRINTF("blank_fill-%s\n",temp); T2S_t2s(temp); stop_t2s(temp);#endif ts_close(); DPRINTF("********use blind ime**********\n"); ShowBitmap(160,120,BGBMPIME); get_blind_words(temp);//调用盲文输入法 ts_open(); if((pblk->value_h)[i]) free((pblk->value_h)[i]); (pblk->value_h)[i]=(char *)malloc(strlen(temp)+1); if((pblk->value_h)[i]==NULL) printf("(pblk->value_h)[%d] mem error!\n",i); strcpy((pblk->value_h)[i],temp); break; case 'h'://hidden break; case 'r'://radio break; case 'c'://checkbox break; case 's'://submit#ifdef TTS strcpy(temp,"是否"); strcat(temp,(pblk->value_h)[i]); T2S_t2s(temp);#endif //提交图片 ShowBitmap(160,120,BGBMPSB); if(select_favor())//左半屏是,右半屏否 { submit_i=1; } ClearBitmap(160,120,BGBMPSB,BGBMPGIRL); break; default: printf("no match input type!!\n"); } } /*根据method选择不同方式发送表单数据*/ DPRINTF("submit_i=%d\n",submit_i); if(submit_i) { switch(pblk->method[0]) { case 'G'://GET /*将各个value值拼接至action之后*/ DPRINTF("wd->ip_port=%s\n",wd->ip_port); //flg=0; for(i=0;;i++) {//得到网址 if(wd->ip_port[i]==TEXT_SEP_CHAR ||wd->ip_port[i]=='\0' ||(wd->ip_port[i]=='/'&&i>6)) break; temp[i]=wd->ip_port[i]; } if(wd->ip_port[i]=='/') temp[i++]='/'; temp[i]='\0'; strcat(temp,pblk->action);//拼接action for(i=0;i<pblk->input_num;i++) {//拼接value if((pblk->name_h)[i][0]=='\0')//name项为空没表单参数 continue; if(i==0) { strcat(temp,"?"); } else { strcat(temp,"&"); } strcat(temp,(pblk->name_h)[i]); strcat(temp,"="); //strcat(temp,"%CC%E1%BD%BB"); strcat(temp,(pblk->value_h)[i]); } DPRINTF("SUBMIT=%s\n",temp); sleep(2); add_ip_port(temp,wsd->web_data[wsd->website_head].ip_port); DPRINTF("SUBMIT=%s\n",temp); sleep(2); /*使网页指针指向下一个空网页,以便给空网页输入网址*/ if(wsd->website_total!=0) { if((wsd->website_head+1)%WEBDATASIZE==wsd->website_tail) { wsd->website_tail=(wsd->website_tail+1)%WEBDATASIZE; wsd->website_head=(wsd->website_head+1)%WEBDATASIZE; wsd->website_total=10; } else { wsd->website_head=(wsd->website_head+1)%WEBDATASIZE; wsd->website_total++; } } else { wsd->website_total++; } /*将所选的网址信息拷给wsd*/ if(wsd->web_data[wsd->website_head].ip_port) {//清空ip_port free(wsd->web_data[wsd->website_head].ip_port); } wsd->web_data[wsd->website_head].ip_port=(char *)malloc(strlen(temp)+1); strcpy(wsd->web_data[wsd->website_head].ip_port,temp); DPRINTF("submit GET ip_port=%s\n",temp); /*重新下载*/ NEED_DOWNLOAD_WEB=1; break; case 'P'://POST //func break; default: printf("no match method type!!\n"); } } else {#ifdef TTS strcpy(temp,"您已放弃表单操作"); T2S_t2s(temp);#endif }}/*根据双击区域执行函数*/void do_web_show_double_click(struct websitedata *wsd)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -