diff -urN stardict-2.4.5/src/floatwin.cpp stardict/src/floatwin.cpp
--- stardict-2.4.5/src/floatwin.cpp 2005-07-18 09:29:50.000000000 +0000
+++ stardict/src/floatwin.cpp 2005-08-05 13:03:48.000000000 +0000
@@ -174,51 +174,51 @@
void FloatWin::ShowText(gchar **word, gchar **data,const gchar * sOriginWord)
{
- QueryingWord = sOriginWord;
- found_result = FLOAT_WIN_FOUND;
- std::string mark;
- gchar *m_str;
- mark = "";
- m_str = g_markup_escape_text(sOriginWord,-1);
- mark += m_str;
- g_free(m_str);
- mark += "";
-
- gchar *p;
+ QueryingWord = sOriginWord;
+ found_result = FLOAT_WIN_FOUND;
+ std::string mark;
+ gchar *m_str;
+ mark = "";
+ m_str = g_markup_escape_text(sOriginWord,-1);
+ mark += m_str;
+ g_free(m_str);
+ mark += "";
+
+ gchar *p;
guint32 data_size, sec_size=0;
for (int i=0;i< gpAppFrame->oAppCore.oLibs.total_libs();i++) {
- if (word[i]) {
- mark += "\n*--- ";
- m_str = g_markup_escape_text(gpAppFrame->oAppCore.oLibs.GetBookname(i),-1);
- mark += m_str;
- g_free(m_str);
- mark += " ---*";
-
- if (strcmp(word[i],sOriginWord)) {
- mark += "\n";
- m_str = g_markup_escape_text(word[i],-1);
- mark += m_str;
- g_free(m_str);
- mark += "";
- }
- }
- if (data[i]) {
+ if (word[i]) {
+ mark += "\n*--- ";
+ m_str = g_markup_escape_text(gpAppFrame->oAppCore.oLibs.GetBookname(i),-1);
+ mark += m_str;
+ g_free(m_str);
+ mark += " ---*";
+
+ if (strcmp(word[i],sOriginWord)) {
+ mark += "\n";
+ m_str = g_markup_escape_text(word[i],-1);
+ mark += m_str;
+ g_free(m_str);
+ mark += "";
+ }
+ }
+ if (data[i]) {
p=data[i];
data_size=*reinterpret_cast(p);
p+=sizeof(guint32);
- while (guint32(p - (data[i] + sizeof(guint32)))< data_size) {
+ while (guint32(p - data[i])< data_size) {
switch (*p++) {
- case 'm':
+ case 'm':
case 'l'://need more work
sec_size = strlen(p);
- if (sec_size) {
- mark+= "\n";
+ if (sec_size) {
+ mark+= "\n";
m_str = g_markup_escape_text(p, sec_size);
- mark += m_str;
- g_free(m_str);
- }
- sec_size++;
- break;
+ mark += m_str;
+ g_free(m_str);
+ }
+ sec_size++;
+ break;
case 'g':
sec_size = strlen(p);
if (sec_size) {
@@ -227,149 +227,149 @@
}
sec_size++;
break;
- case 't':
+ case 't':
sec_size = strlen(p);
- if (sec_size) {
- mark += "\n[";
+ if (sec_size) {
+ mark += "\n[";
m_str = g_markup_escape_text(p, sec_size);
- mark += m_str;
- g_free(m_str);
- mark+= "]";
- }
- sec_size++;
- break;
- case 'y':
+ mark += m_str;
+ g_free(m_str);
+ mark+= "]";
+ }
+ sec_size++;
+ break;
+ case 'y':
sec_size = strlen(p);
- if (sec_size) {
- mark += "\n[";
+ if (sec_size) {
+ mark += "\n[";
m_str = g_markup_escape_text(p, sec_size);
- mark += m_str;
- g_free(m_str);
- mark+= "]";
- }
- sec_size++;
- break;
- case 'W':
+ mark += m_str;
+ g_free(m_str);
+ mark+= "]";
+ }
+ sec_size++;
+ break;
+ case 'W':
sec_size=*reinterpret_cast(p);
sec_size=g_ntohl(sec_size);
- //enbale sound button.
+ //enbale sound button.
sec_size+=sizeof(guint32);
- break;
- case 'P':
+ break;
+ case 'P':
sec_size=*reinterpret_cast(p);
sec_size=g_ntohl(sec_size);
sec_size+= sizeof(guint32);
- break;
+ break;
default:
/*nothing*/;
- }
+ }
p += sec_size;
- }
- }
- }
- SetText(mark.c_str());
-
- gboolean canRead = gpAppFrame->oReadWord.canRead(sOriginWord);
- if (canRead) {
- PronounceWord = sOriginWord;
+ }
+ }
+ }
+ SetText(mark.c_str());
+
+ gboolean canRead = gpAppFrame->oReadWord.canRead(sOriginWord);
+ if (canRead) {
+ PronounceWord = sOriginWord;
} else {
- for (int i=0;i< gpAppFrame->oAppCore.oLibs.total_libs(); i++) {
- if (word[i] && strcmp(word[i], sOriginWord)) {
- if (gpAppFrame->oReadWord.canRead(word[i])) {
- canRead = true;
- PronounceWord = word[i];
- }
- break;
- }
- }
- }
- gtk_widget_set_sensitive(PronounceWordButton, canRead);
- Popup(true);
-
- if (canRead && conf->get_pronounce_when_popup())
- gpAppFrame->oReadWord.read(PronounceWord.c_str());
+ for (int i=0;i< gpAppFrame->oAppCore.oLibs.total_libs(); i++) {
+ if (word[i] && strcmp(word[i], sOriginWord)) {
+ if (gpAppFrame->oReadWord.canRead(word[i])) {
+ canRead = true;
+ PronounceWord = word[i];
+ }
+ break;
+ }
+ }
+ }
+ gtk_widget_set_sensitive(PronounceWordButton, canRead);
+ Popup(true);
+
+ if (canRead && conf->get_pronounce_when_popup())
+ gpAppFrame->oReadWord.read(PronounceWord.c_str());
}
void FloatWin::ShowText(gchar *** pppWord, gchar *** pppWordData,
const gchar ** ppOriginWord, gint count,
const gchar * sOriginWord)
{
- QueryingWord = sOriginWord;
- found_result = FLOAT_WIN_FUZZY_FOUND;
- std::string mark;
- gchar *m_str;
- mark = _("Fuzzy query");
- mark += " ";
- m_str = g_markup_escape_text(sOriginWord,-1);
- mark += m_str;
- g_free(m_str);
- mark += " ";
- mark += _("has succeeded.\n");
- mark += _("Found ");
- if (count ==1)
- mark+= _("1 word:\n");
+ QueryingWord = sOriginWord;
+ found_result = FLOAT_WIN_FUZZY_FOUND;
+ std::string mark;
+ gchar *m_str;
+ mark = _("Fuzzy query");
+ mark += " ";
+ m_str = g_markup_escape_text(sOriginWord,-1);
+ mark += m_str;
+ g_free(m_str);
+ mark += " ";
+ mark += _("has succeeded.\n");
+ mark += _("Found ");
+ if (count ==1)
+ mark+= _("1 word:\n");
else {
- m_str=g_strdup_printf("%d",count);
- mark += m_str;
- g_free(m_str);
- mark+= _(" words:\n");
- }
- int j;
+ m_str=g_strdup_printf("%d",count);
+ mark += m_str;
+ g_free(m_str);
+ mark+= _(" words:\n");
+ }
+ int j;
for (j=0; j";
+ mark += "";
m_str = g_markup_escape_text(ppOriginWord[j], -1);
- mark += m_str;
- g_free(m_str);
- mark += " ";
- }
- mark += "";
- m_str = g_markup_escape_text(ppOriginWord[count-1],-1);
- mark += m_str;
- g_free(m_str);
- mark += "";
-
- gchar *p;
+ mark += m_str;
+ g_free(m_str);
+ mark += " ";
+ }
+ mark += "";
+ m_str = g_markup_escape_text(ppOriginWord[count-1],-1);
+ mark += m_str;
+ g_free(m_str);
+ mark += "";
+
+ gchar *p;
guint32 data_size,sec_size=0;
for (j=0; j#----- ";
- m_str = g_markup_escape_text(ppOriginWord[j],-1);
- mark += m_str;
- g_free(m_str);
- mark += " -----#";
-
+ mark += "\n\n#----- ";
+ m_str = g_markup_escape_text(ppOriginWord[j],-1);
+ mark += m_str;
+ g_free(m_str);
+ mark += " -----#";
+
for (int i=0; ioAppCore.oLibs.total_libs(); i++) {
- if (pppWord[j][i]) {
- mark += "\n*--- ";
- m_str = g_markup_escape_text(gpAppFrame->oAppCore.oLibs.GetBookname(i),-1);
- mark += m_str;
- g_free(m_str);
- mark += " ---*";
-
- if (strcmp(ppOriginWord[j],pppWord[j][i])) {
- mark += "\n";
- m_str = g_markup_escape_text(pppWord[j][i],-1);
- mark += m_str;
- g_free(m_str);
- mark += "";
- }
- }
- if (pppWordData[j][i]) {
+ if (pppWord[j][i]) {
+ mark += "\n*--- ";
+ m_str = g_markup_escape_text(gpAppFrame->oAppCore.oLibs.GetBookname(i),-1);
+ mark += m_str;
+ g_free(m_str);
+ mark += " ---*";
+
+ if (strcmp(ppOriginWord[j],pppWord[j][i])) {
+ mark += "\n";
+ m_str = g_markup_escape_text(pppWord[j][i],-1);
+ mark += m_str;
+ g_free(m_str);
+ mark += "";
+ }
+ }
+ if (pppWordData[j][i]) {
p=pppWordData[j][i];
data_size=*reinterpret_cast(p);
p+=sizeof(guint32);
- while (guint32(p - (pppWordData[j][i] + sizeof(guint32)))< data_size) {
+ while (guint32(p - pppWordData[j][i])< data_size) {
switch (*p++) {
- case 'm':
+ case 'm':
case 'l': //need more work...
sec_size = strlen(p);
- if (sec_size) {
- mark+= "\n";
+ if (sec_size) {
+ mark+= "\n";
m_str = g_markup_escape_text(p,sec_size);
- mark += m_str;
- g_free(m_str);
- }
- sec_size++;
- break;
+ mark += m_str;
+ g_free(m_str);
+ }
+ sec_size++;
+ break;
case 'g':
sec_size = strlen(p);
if (sec_size) {
@@ -378,57 +378,57 @@
}
sec_size++;
break;
- case 't':
+ case 't':
sec_size = strlen(p);
- if (sec_size) {
- mark += "\n[";
+ if (sec_size) {
+ mark += "\n[";
m_str = g_markup_escape_text(p, sec_size);
- mark += m_str;
- g_free(m_str);
- mark+= "]";
- }
- sec_size++;
- break;
- case 'y':
+ mark += m_str;
+ g_free(m_str);
+ mark+= "]";
+ }
+ sec_size++;
+ break;
+ case 'y':
sec_size = strlen(p);
- if (sec_size) {
- mark += "\n[";
+ if (sec_size) {
+ mark += "\n[";
m_str = g_markup_escape_text(p, sec_size);
- mark += m_str;
- g_free(m_str);
- mark+= "]";
- }
- sec_size++;
- break;
- case 'W':
+ mark += m_str;
+ g_free(m_str);
+ mark+= "]";
+ }
+ sec_size++;
+ break;
+ case 'W':
sec_size=*reinterpret_cast(p);
sec_size=g_ntohl(sec_size);
- //enbale sound button.
+ //enbale sound button.
sec_size+= sizeof(guint32);
- break;
- case 'P':
+ break;
+ case 'P':
sec_size=*reinterpret_cast(p);
sec_size=g_ntohl(sec_size);
sec_size+= sizeof(guint32);
- break;
+ break;
default:
/*nothing*/;
- }
+ }
p += sec_size;
- }
- }
- }
- }
- SetText(mark.c_str());
- gboolean canRead = gpAppFrame->oReadWord.canRead(sOriginWord);
- if (canRead)
- PronounceWord = sOriginWord;
- gtk_widget_set_sensitive(PronounceWordButton, canRead);
-
- Popup(false);
-
- if (canRead && conf->get_pronounce_when_popup())
- gpAppFrame->oReadWord.read(PronounceWord.c_str());
+ }
+ }
+ }
+ }
+ SetText(mark.c_str());
+ gboolean canRead = gpAppFrame->oReadWord.canRead(sOriginWord);
+ if (canRead)
+ PronounceWord = sOriginWord;
+ gtk_widget_set_sensitive(PronounceWordButton, canRead);
+
+ Popup(false);
+
+ if (canRead && conf->get_pronounce_when_popup())
+ gpAppFrame->oReadWord.read(PronounceWord.c_str());
}
void FloatWin::ShowNotFound(const char* sWord,const char* sReason, gboolean fuzzy)
diff -urN stardict-2.4.5/src/lib.cpp stardict/src/lib.cpp
--- stardict-2.4.5/src/lib.cpp 2005-07-19 14:20:01.000000000 +0000
+++ stardict/src/lib.cpp 2005-08-05 16:48:29.000000000 +0000
@@ -121,32 +121,33 @@
return false;
return true;
}
+
+inline gint stardict_strcmp(const gchar *s1, const gchar *s2)
+{
#ifndef NEW_CMP
-inline gint stardict_strcmp(const gchar *s1, const gchar *s2) {
gint a=g_ascii_strcasecmp(s1, s2);
if (a == 0)
return strcmp(s1, s2);
else
return a;
-}
#else
-inline gint stardict_strcmp2(const gchar *s1, const gchar *s2) {
- gint res=0;
- while (*s1 && *s2) {
- res=g_unichar_tolower(g_utf8_get_char(s1))-g_unichar_tolower(g_utf8_get_char(s2));
- if (res!=0)
- return res;
- s1=g_utf8_next_char(s1);
- s2=g_utf8_next_char(s2);
- }
-
- if (*s1 && !*s2)
- return 1;
- if (!*s1 && *s2)
- return -1;
- return 0;
-}
+ gint res=0;
+ while (*s1 && *s2) {
+ res=g_unichar_tolower(g_utf8_get_char(s1))-g_unichar_tolower(g_utf8_get_char(s2));
+ if (res!=0)
+ return res;
+ s1=g_utf8_next_char(s1);
+ s2=g_utf8_next_char(s2);
+ }
+
+ if (*s1 && !*s2)
+ return 1;
+ if (!*s1 && *s2)
+ return -1;
+ return 0;
#endif
+}
+
bool DictInfo::load_from_ifo_file(const gchar *ifofilename,
bool istreedict)
{
@@ -284,109 +285,109 @@
{
for (int i=0; i(p2);
sec_size += sizeof(guint32);
- memcpy(p1, p2, sec_size);
+ memcpy(p1, p2, sec_size);
p1+=sec_size;
p2+=sec_size;
- break;
- }
- }
- //calculate the last item 's size.
- sec_size = idxitem_size - (p2-origin_data);
+ break;
+ }
+ }
+ //calculate the last item 's size.
+ sec_size = idxitem_size - (p2-origin_data);
*p1=sametypesequence[sametypesequence_len-1];
p1+=sizeof(gchar);
- switch (sametypesequence[sametypesequence_len-1]) {
- case 'm':
- case 't':
- case 'y':
+ switch (sametypesequence[sametypesequence_len-1]) {
+ case 'm':
+ case 't':
+ case 'y':
case 'l':
case 'g':
- memcpy(p1, p2, sec_size);
- p1 += sec_size;
+ memcpy(p1, p2, sec_size);
+ p1 += sec_size;
*p1='\0';//add the end up '\0';
- break;
- case 'W':
- case 'P':
+ break;
+ case 'W':
+ case 'P':
*reinterpret_cast(p1)=sec_size;
p1 += sizeof(guint32);
- memcpy(p1, p2, sec_size);
- break;
- }
- g_free(origin_data);
+ memcpy(p1, p2, sec_size);
+ break;
+ }
+ g_free(origin_data);
*reinterpret_cast(data)=data_size;
} else {
data = (gchar *)g_malloc(idxitem_size + sizeof(guint32));
- if (dictfile)
+ if (dictfile)
fread(data+sizeof(guint32), idxitem_size, 1, dictfile);
- else
+ else
dict_data_read(dictdzfile, data+sizeof(guint32), idxitem_offset, idxitem_size);
- *reinterpret_cast(data)=idxitem_size;
- }
- g_free(cache[cache_cur].data);
-
- cache[cache_cur].data = data;
- cache[cache_cur].offset = idxitem_offset;
- cache_cur++;
- if (cache_cur==WORDDATA_CACHE_NUM)
+ *reinterpret_cast(data)=idxitem_size+sizeof(guint32);
+ }
+ g_free(cache[cache_cur].data);
+
+ cache[cache_cur].data = data;
+ cache[cache_cur].offset = idxitem_offset;
+ cache_cur++;
+ if (cache_cur==WORDDATA_CACHE_NUM)
cache_cur = 0;
- return data;
+ return data;
}
@@ -507,11 +508,7 @@
}
inline bool less_for_compare(const char *lh, const char *rh) {
-#ifndef NEW_CMP
return stardict_strcmp(lh, rh)<0;
-#else
- return stardict_strcmp2(lh, rh)<0;
-#endif
}
#ifdef NEW_CMP
struct CharacterArea1 {
@@ -588,11 +585,11 @@
#endif
}
#ifdef NEW_CMP
-class StarDictCompare2 {
+class StarDictCompare {
public:
- explicit StarDictCompare2(const gchar *data_value) : data(data_value) {}
+ explicit StarDictCompare(const gchar *data_value) : data(data_value) {}
bool operator()(const Lib::WordCoord & lh, const Lib::WordCoord & rh) {
- return stardict_strcmp2(data+lh.offset, data+rh.offset)<0;
+ return stardict_strcmp(data+lh.offset, data+rh.offset)<0;
}
private:
const gchar *data;
@@ -663,8 +660,8 @@
++ptr;
}
- StarDictCompare2 stardict_compare2(idxdatabuffer);
- std::sort(wordoffset, wordoffset+wordcount, stardict_compare2);
+ StarDictCompare stardict_compare(idxdatabuffer);
+ std::sort(wordoffset, wordoffset+wordcount, stardict_compare);
#endif
}
@@ -675,21 +672,15 @@
#endif
bool bFound=false;
glong iTo=wordcount-1;
-#ifndef NEW_CMP
- if (stardict_strcmp(sWord, GetWord(0))<0) {
-#else
- if (stardict_strcmp2(sWord, GetWord(0))<0) {
-#endif
- *pIndex = 0;
-#ifndef NEW_CMP
+
+ if (stardict_strcmp(sWord, GetWord(0))<0) {
+ *pIndex = 0;
+
} else if (stardict_strcmp(sWord, GetWord(iTo)) >0) {
-#else
- } else if (stardict_strcmp2(sWord, GetWord(iTo)) >0) {
-#endif
- *pIndex = INVALID_INDEX;
+ *pIndex = INVALID_INDEX;
} else {
- glong iThisIndex=0;
- glong iFrom=0;
+ glong iThisIndex=0;
+ glong iFrom=0;
#ifdef NEW_CMP
#if 1
Character first;
@@ -708,38 +699,35 @@
#endif
gint cmpint;
while (iFrom<=iTo) {
- iThisIndex=(iFrom+iTo)/2;
-#ifndef NEW_CMP
- cmpint = stardict_strcmp(sWord, GetWord(iThisIndex));
-#else
- cmpint = stardict_strcmp2(sWord, GetWord(iThisIndex));
-#endif
-
+ iThisIndex=(iFrom+iTo)/2;
+
+ cmpint = stardict_strcmp(sWord, GetWord(iThisIndex));
+
if (cmpint>0)
- iFrom=iThisIndex+1;
+ iFrom=iThisIndex+1;
else if (cmpint<0)
- iTo=iThisIndex-1;
+ iTo=iThisIndex-1;
else {
bFound=true;
break;
- }
- }
-
+ }
+ }
+
if (!bFound) {
- /*glong len = g_utf8_strlen(sWord, -1);
- gchar *last_str = g_utf8_offset_to_pointer(sWord, len-1);
- gunichar last = g_utf8_get_char(last_str);
- if (((g_unichar_isspace(last) || g_unichar_ispunct(last)) || g_unichar_isdigit(last))
- && (g_ascii_strncasecmp(sWord, GetWord(iTo), (last_str - sWord))==0))
- *pIndex = iTo; //previous
- else
- *pIndex = iFrom; //next
- */
- *pIndex = iFrom; //next
+ /*glong len = g_utf8_strlen(sWord, -1);
+ gchar *last_str = g_utf8_offset_to_pointer(sWord, len-1);
+ gunichar last = g_utf8_get_char(last_str);
+ if (((g_unichar_isspace(last) || g_unichar_ispunct(last)) || g_unichar_isdigit(last))
+ && (g_ascii_strncasecmp(sWord, GetWord(iTo), (last_str - sWord))==0))
+ *pIndex = iTo; //previous
+ else
+ *pIndex = iFrom; //next
+ */
+ *pIndex = iFrom; //next
} else
- *pIndex = iThisIndex;
- }
-
+ *pIndex = iThisIndex;
+ }
+
#ifdef MEASURE_TIME
t=clock()-t;
middle_lookup_time*=measure_time;
@@ -937,28 +925,24 @@
gchar *Libs::poGetCurrentWord(glong * iCurrent)
{
- gchar * poCurrentWord = NULL;
- gchar *word;
- for (int iLib=0;iLib=iLength(iLib) || iCurrent[iLib]<0)
- continue;
- if ( poCurrentWord == NULL ) {
- poCurrentWord = poGetWord(iCurrent[iLib],iLib);
- }
- else {
- word = poGetWord(iCurrent[iLib],iLib);
-#ifndef NEW_CMP
- if (stardict_strcmp(poCurrentWord, word) > 0 )
-#else
- if (stardict_strcmp2(poCurrentWord, word) > 0 )
-#endif
- poCurrentWord = word;
- }
- }
- return poCurrentWord;
- }
+ gchar * poCurrentWord = NULL;
+ gchar *word;
+ for (int iLib=0;iLib=iLength(iLib) || iCurrent[iLib]<0)
+ continue;
+ if ( poCurrentWord == NULL ) {
+ poCurrentWord = poGetWord(iCurrent[iLib],iLib);
+ } else {
+ word = poGetWord(iCurrent[iLib],iLib);
+
+ if (stardict_strcmp(poCurrentWord, word) > 0 )
+ poCurrentWord = word;
+ }
+ }
+ return poCurrentWord;
+}
gchar *
Libs::poGetNextWord(const gchar *sWord, glong * iCurrent)
@@ -983,11 +967,8 @@
}
else {
word = poGetWord(iCurrent[iLib],iLib);
-#ifndef NEW_CMP
+
if ( stardict_strcmp(poCurrentWord, word) > 0 ) {
-#else
- if ( stardict_strcmp2(poCurrentWord, word) > 0 ) {
-#endif
poCurrentWord = word;
iCurrentLib = iLib;
}
@@ -1030,11 +1011,7 @@
}
else {
word = poGetWord(iCurrent[iLib]-1,iLib);
-#ifndef NEW_CMP
if (stardict_strcmp(poCurrentWord, word) < 0 ) {
-#else
- if (stardict_strcmp2(poCurrentWord, word) < 0 ) {
-#endif
poCurrentWord = word;
iCurrentLib = iLib;
}
@@ -1399,11 +1376,7 @@
return lh.iMatchWordDistance=0 &&
stardict_strcmp(sWord, poGetWord(iLength(iLib)-1,iLib))<=0) {
-#else
- if (stardict_strcmp2(sWord, poGetWord(0,iLib))>=0 &&
- stardict_strcmp2(sWord, poGetWord(iLength(iLib)-1,iLib))<=0) {
-#endif
//there are Chinese dicts and English dicts...
const int iwords = iLength(iLib);
for (int index=0; indexoAppCore.oLibs.total_libs(); i++) {
- if (Word[i]) {
- gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "<--- ",-1, "DictNameTag", NULL);
+ if (Word[i]) {
+ gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "<--- ",-1, "DictNameTag", NULL);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, gpAppFrame->oAppCore.oLibs.GetBookname(i),
-1, "DictNameTag", NULL);
- gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, " --->\n",-1, "DictNameTag", NULL);
- gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, Word[i],-1, "WordTag", NULL);
- gtk_text_buffer_insert (buffer, &iter,"\n", 1);
- }
- if (WordData[i]) {
+ gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, " --->\n",-1, "DictNameTag", NULL);
+ gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, Word[i],-1, "WordTag", NULL);
+ gtk_text_buffer_insert (buffer, &iter,"\n", 1);
+ }
+ if (WordData[i]) {
p=WordData[i];
data_size=*reinterpret_cast(p);
p+=sizeof(guint32);
- while (guint32(p - (WordData[i] + sizeof(guint32)))< data_size) {
+ while (guint32(p - WordData[i])< data_size) {
switch (*p++) {
- case 'm':
+ case 'm':
case 'l'://need more work...
sec_size = strlen(p);
if (sec_size)
gtk_text_buffer_insert(buffer, &iter, p, sec_size);
- sec_size++;
- break;
+ sec_size++;
+ break;
case 'g':
sec_size = strlen(p);
if (sec_size) {
@@ -1374,74 +1374,74 @@
}
sec_size++;
break;
- case 't':
+ case 't':
sec_size = strlen(p);
- if (sec_size) {
+ if (sec_size) {
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "[", 1, "PhoneticTag", NULL);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, p, sec_size, "PhoneticTag", NULL);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "]", 1, "PhoneticTag", NULL);
- }
- sec_size++;
- break;
- case 'y':
+ }
+ sec_size++;
+ break;
+ case 'y':
sec_size = strlen(p);
- if (sec_size) {
+ if (sec_size) {
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "[", 1, "YinBiaoTag", NULL);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, p, sec_size, "YinBiaoTag", NULL);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "]", 1, "YinBiaoTag", NULL);
- }
- sec_size++;
- break;
- case 'W':
+ }
+ sec_size++;
+ break;
+ case 'W':
sec_size=*reinterpret_cast(p);
sec_size=g_ntohl(sec_size);
- //enbale sound button.
+ //enbale sound button.
sec_size += sizeof(guint32);
- break;
- case 'P':
+ break;
+ case 'P':
sec_size=*reinterpret_cast(p);
sec_size=g_ntohl(sec_size);
- //show this picture.
+ //show this picture.
sec_size += sizeof(guint32);
- break;
+ break;
default:
/*nothing*/;
- }
+ }
gtk_text_buffer_insert(buffer, &iter, "\n", 1);
p += sec_size;
- }
- }
- }
- gtk_text_buffer_end_user_action(buffer);
+ }
+ }
+ }
+ gtk_text_buffer_end_user_action(buffer);
}
void TextWin::ShowTreeDictData(const gchar *data)
{
- GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
- gtk_text_buffer_begin_user_action(buffer);
-
- GtkTextIter start, end;
- gtk_text_buffer_get_bounds(buffer,&start,&end);
- gtk_text_buffer_delete(buffer,&start,&end);
- gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW(scrolled_window)), 0);
-
- GtkTextIter iter;
- gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
-
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+ gtk_text_buffer_begin_user_action(buffer);
+
+ GtkTextIter start, end;
+ gtk_text_buffer_get_bounds(buffer,&start,&end);
+ gtk_text_buffer_delete(buffer,&start,&end);
+ gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW(scrolled_window)), 0);
+
+ GtkTextIter iter;
+ gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
+
guint32 data_size,sec_size=0;
const gchar *p=data;
data_size=*reinterpret_cast(p);
p+=sizeof(guint32);
- while (guint32(p - (data + sizeof(guint32)))< data_size) {
+ while (guint32(p - data)< data_size) {
switch (*p++) {
- case 'm':
+ case 'm':
case 'l'://need more work...
sec_size = strlen(p);
- if (sec_size)
+ if (sec_size)
gtk_text_buffer_insert(buffer, &iter, p, sec_size);
- sec_size++;
- break;
+ sec_size++;
+ break;
case 'g':
sec_size=strlen(p);
if (sec_size) {
@@ -1453,43 +1453,43 @@
}
sec_size++;
break;
- case 't':
+ case 't':
sec_size = strlen(p);
- if (sec_size) {
+ if (sec_size) {
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "[", 1, "PhoneticTag", NULL);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, p, sec_size, "PhoneticTag", NULL);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "]", 1, "PhoneticTag", NULL);
- }
- sec_size++;
- break;
- case 'y':
+ }
+ sec_size++;
+ break;
+ case 'y':
sec_size = strlen(p);
- if (sec_size) {
+ if (sec_size) {
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "[", 1, "YinBiaoTag", NULL);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, p, sec_size, "YinBiaoTag", NULL);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "]", 1, "YinBiaoTag", NULL);
- }
- sec_size++;
- break;
- case 'W':
+ }
+ sec_size++;
+ break;
+ case 'W':
sec_size=*reinterpret_cast(p);
sec_size=g_ntohl(sec_size);
- //enbale sound button.
+ //enbale sound button.
sec_size += sizeof(guint32);
- break;
- case 'P':
+ break;
+ case 'P':
sec_size=*reinterpret_cast(p);
sec_size=g_ntohl(sec_size);
- //show this picture.
+ //show this picture.
sec_size += sizeof(guint32);
- break;
+ break;
default:
/*nothing*/;
- }
+ }
gtk_text_buffer_insert(buffer, &iter,"\n", 1);
p += sec_size;
- }
- gtk_text_buffer_end_user_action(buffer);
+ }
+ gtk_text_buffer_end_user_action(buffer);
}
gboolean TextWin::Find (const gchar *text, gboolean start)