diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch) | |
tree | 2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /kate/cppsymbolviewer | |
download | tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kate/cppsymbolviewer')
-rw-r--r-- | kate/cppsymbolviewer/Makefile.am | 17 | ||||
-rw-r--r-- | kate/cppsymbolviewer/cpp_parser.cpp | 335 | ||||
-rw-r--r-- | kate/cppsymbolviewer/katecppsymbolviewer.desktop | 115 | ||||
-rw-r--r-- | kate/cppsymbolviewer/plugin_katesymbolviewer.cpp | 337 | ||||
-rw-r--r-- | kate/cppsymbolviewer/plugin_katesymbolviewer.h | 300 | ||||
-rw-r--r-- | kate/cppsymbolviewer/tcl_parser.cpp | 150 | ||||
-rw-r--r-- | kate/cppsymbolviewer/testfile.c | 59 | ||||
-rw-r--r-- | kate/cppsymbolviewer/ui.rc | 9 |
8 files changed, 1322 insertions, 0 deletions
diff --git a/kate/cppsymbolviewer/Makefile.am b/kate/cppsymbolviewer/Makefile.am new file mode 100644 index 0000000..8bf46f0 --- /dev/null +++ b/kate/cppsymbolviewer/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = $(all_includes) +METASOURCES = AUTO + +# Install this plugin in the KDE modules directory +kde_module_LTLIBRARIES = katecppsymbolviewerplugin.la + +katecppsymbolviewerplugin_la_SOURCES = cpp_parser.cpp tcl_parser.cpp plugin_katesymbolviewer.cpp +katecppsymbolviewerplugin_la_LIBADD = -lkateinterfaces +katecppsymbolviewerplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) + +pluginsdir = $(kde_datadir)/kate/plugins/katecppsymbolviewer +plugins_DATA = ui.rc + +kde_services_DATA = katecppsymbolviewer.desktop + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/katecppsymbolviewer.pot diff --git a/kate/cppsymbolviewer/cpp_parser.cpp b/kate/cppsymbolviewer/cpp_parser.cpp new file mode 100644 index 0000000..01ee919 --- /dev/null +++ b/kate/cppsymbolviewer/cpp_parser.cpp @@ -0,0 +1,335 @@ +/*************************************************************************** + cpp_parser.cpp - description + ------------------- + begin : Apr 2 2003 + author : 2003 Massimo Callegari + email : massimocallegari@yahoo.it + ***************************************************************************/ + /*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "plugin_katesymbolviewer.h" + +void KatePluginSymbolViewerView::parseCppSymbols(void) +{ + if (!win->viewManager()->activeView()) + return; + + QString cl; // Current Line + QString stripped; + uint i, j, tmpPos = 0; + int par = 0, graph = 0, retry = 0; + char mclass = 0, block = 0, comment = 0; // comment: 0-no comment 1-inline comment 2-multiline comment 3-string + char macro = 0, macro_pos = 0, func_close = 0; + bool structure = false; + QPixmap cls( ( const char** ) class_xpm ); + QPixmap sct( ( const char** ) struct_xpm ); + QPixmap mcr( ( const char** ) macro_xpm ); + QPixmap mtd( ( const char** ) method_xpm ); + QListViewItem *node = NULL; + QListViewItem *mcrNode = NULL, *sctNode = NULL, *clsNode = NULL, *mtdNode = NULL; + QListViewItem *lastMcrNode = NULL, *lastSctNode = NULL, *lastClsNode = NULL, *lastMtdNode = NULL; + + + Kate::Document *kv = win->viewManager()->activeView()->getDoc(); + //kdDebug(13000)<<"Lines counted :"<<kv->numLines()<<endl; + if(treeMode) + { + mcrNode = new QListViewItem(symbols, symbols->lastItem(), i18n("Macros")); + sctNode = new QListViewItem(symbols, symbols->lastItem(), i18n("Structures")); + clsNode = new QListViewItem(symbols, symbols->lastItem(), i18n("Functions")); + mcrNode->setPixmap(0, (const QPixmap &)mcr); + sctNode->setPixmap(0, (const QPixmap &)sct); + clsNode->setPixmap(0, (const QPixmap &)cls); + if (expanded_on) + { + mcrNode->setOpen(TRUE); + sctNode->setOpen(TRUE); + clsNode->setOpen(TRUE); + } + lastMcrNode = mcrNode; + lastSctNode = sctNode; + lastClsNode = clsNode; + mtdNode = clsNode; + lastMtdNode = clsNode; + symbols->setRootIsDecorated(1); + } + else symbols->setRootIsDecorated(0); + + for (i=0; i<kv->numLines(); i++) + { + cl = kv->textLine(i); + cl = cl.stripWhiteSpace(); + func_close = 0; + if(cl.at(0) == '/' && cl.at(1) == '/') continue; + if(cl.find("/*") == 0 && (cl.find("*/") == ((signed)cl.length() - 2)) && graph == 0) continue; // workaround :( + if(cl.find("/*") >= 0 && graph == 0) comment = 1; + if(cl.find("*/") >= 0 && graph == 0) comment = 0; + if(cl.find("#") >= 0 && graph == 0 ) macro = 1; + if (comment != 1) + { + /* *********************** MACRO PARSING *****************************/ + if(macro == 1) + { + //macro_pos = cl.find("#"); + for (j = 0; j < cl.length(); j++) + { + if(cl.at(j)=='/' && cl.at(j+1)=='/') { macro = 4; break; } + if( (uint)cl.find("define") == j && + !((uint)cl.find("defined") == j)) + { + macro = 2; + j += 6; // skip the word "define" + } + if(macro == 2 && cl.at(j) != ' ') macro = 3; + if(macro == 3) + { + if (cl.at(j) >= 0x20) stripped += cl.at(j); + if (cl.at(j) == ' ' || j == cl.length() - 1) + macro = 4; + } + //kdDebug(13000)<<"Macro -- Stripped : "<<stripped<<" macro = "<<macro<<endl; + } + // I didn't find a valid macro e.g. include + if(j == cl.length() && macro == 1) macro = 0; + if(macro == 4) + { + //stripped.replace(0x9, " "); + stripped = stripped.stripWhiteSpace(); + if (macro_on == true) + { + if (treeMode) + { + node = new QListViewItem(mcrNode, lastMcrNode, stripped); + lastMcrNode = node; + } + else node = new QListViewItem(symbols, symbols->lastItem(), stripped); + node->setPixmap(0, (const QPixmap &)mcr); + node->setText(1, QString::number( i, 10)); + } + macro = 0; + macro_pos = 0; + stripped = ""; + //kdDebug(13000)<<"Macro -- Inserted : "<<stripped<<" at row : "<<i<<endl; + if (cl.at(cl.length() - 1) == '\\') macro = 5; // continue in rows below + continue; + } + } + if (macro == 5) + { + if (cl.at(cl.length() - 1) != '\\') + macro = 0; + continue; + } + + /* ******************************************************************** */ + + if ((cl.find("class") >= 0 && graph == 0 && block == 0)) + { + mclass = 1; + for (j = 0; j < cl.length(); j++) + { + if(cl.at(j)=='/' && cl.at(j+1)=='/') { mclass = 2; break; } + if(cl.at(j)=='{') { mclass = 4; break;} + stripped += cl.at(j); + } + if(func_on == true) + { + if (treeMode) + { + node = new QListViewItem(clsNode, lastClsNode, stripped); + if (expanded_on) node->setOpen(TRUE); + lastClsNode = node; + mtdNode = lastClsNode; + lastMtdNode = lastClsNode; + } + else node = new QListViewItem(symbols, symbols->lastItem(), stripped); + node->setPixmap(0, (const QPixmap &)cls); + node->setText(1, QString::number( i, 10)); + stripped = ""; + if (mclass == 1) mclass = 3; + } + continue; + } + if (mclass == 3) + { + if (cl.find('{') >= 0) + { + cl = cl.right(cl.find('{')); + mclass = 4; + } + } + + if(cl.find("(") >= 0 && cl.at(0) != '#' && block == 0 && comment != 2) + { structure = false; block = 1; } + if((cl.find("typedef") >= 0 || cl.find("struct") >= 0) && + graph == 0 && block == 0) + { structure = true; block = 2; stripped = ""; } + //if(cl.find(";") >= 0 && graph == 0) + // block = 0; + + if(block > 0 && mclass != 1 ) + { + for (j = 0; j < cl.length(); j++) + { + if (cl.at(j) == '/' && (cl.at(j + 1) == '*')) comment = 2; + if (cl.at(j) == '*' && (cl.at(j + 1) == '/')) { comment = 0; j+=2; } + // Handles a string. Those are freaking evilish ! + if (cl.at(j) == '"' && comment == 3) { comment = 0; j++; } + else if (cl.at(j) == '"' && comment == 0) comment = 3; + if(cl.at(j)=='/' && cl.at(j+1)=='/' && comment == 0) + { if(block == 1 && stripped.isEmpty()) block = 0; break; } + if (comment != 2 && comment != 3) + { + if (block == 1 && graph == 0 ) + { + if(cl.at(j) >= 0x20) stripped += cl.at(j); + if(cl.at(j) == '(') par++; + if(cl.at(j) == ')') + { + par--; + if(par == 0) + { + stripped = stripped.stripWhiteSpace(); + stripped.remove("static "); + //kdDebug(13000)<<"Function -- Inserted : "<<stripped<<" at row : "<<i<<endl; + block = 2; + tmpPos = i; + } + } + } // BLOCK 1 + if(block == 2 && graph == 0) + { + if(cl.at(j)=='/' && cl.at(j+1)=='/' && comment == 0) break; + //if(cl.at(j)==':' || cl.at(j)==',') { block = 1; continue; } + if(cl.at(j)==':') { block = 1; continue; } + if(cl.at(j)==';') + { + stripped = ""; + block = 0; + structure = false; + break; + } + + if(cl.at(j)=='{' && structure == false && cl.find(";") < 0 || + cl.at(j)=='{' && structure == false && cl.find('}') > (int)j) + { + stripped.replace(0x9, " "); + if(func_on == true) + { + if (types_on == false) + { + while (stripped.find('(') >= 0) + stripped = stripped.left(stripped.find('(')); + while (stripped.find("::") >= 0) + stripped = stripped.mid(stripped.find("::") + 2); + stripped = stripped.stripWhiteSpace(); + while (stripped.find(0x20) >= 0) + stripped = stripped.mid(stripped.find(0x20, 0) + 1); + } + //kdDebug(13000)<<"Function -- Inserted: "<<stripped<<" at row: "<<tmpPos<<" mclass: "<<(uint)mclass<<endl; + if (treeMode) + { + if (mclass == 4) + { + node = new QListViewItem(mtdNode, lastMtdNode, stripped); + lastMtdNode = node; + } + else + { + node = new QListViewItem(clsNode, lastClsNode, stripped); + lastClsNode = node; + } + } + else + node = new QListViewItem(symbols, symbols->lastItem(), stripped); + if (mclass == 4) node->setPixmap(0, (const QPixmap &)mtd); + else node->setPixmap(0, (const QPixmap &)cls); + node->setText(1, QString::number( tmpPos, 10)); + } + stripped = ""; + retry = 0; + block = 3; + } + if(cl.at(j)=='{' && structure == true) + { + block = 3; + tmpPos = i; + } + if(cl.at(j)=='(' && structure == true) + { + retry = 1; + block = 0; + j = 0; + //kdDebug(13000)<<"Restart from the beginning of line..."<<endl; + stripped = ""; + break; // Avoid an infinite loop :( + } + if(structure == true && cl.at(j) >= 0x20) stripped += cl.at(j); + } // BLOCK 2 + + if (block == 3) + { + // A comment...there can be anything + if(cl.at(j)=='/' && cl.at(j+1)=='/' && comment == 0) break; + if(cl.at(j)=='{') graph++; + if(cl.at(j)=='}') + { + graph--; + if (graph == 0 && structure == false) { block = 0; func_close = 1; } + if (graph == 0 && structure == true) block = 4; + } + } // BLOCK 3 + + if (block == 4) + { + if(cl.at(j) == ';') + { + //stripped.replace(0x9, " "); + stripped.remove('{'); + stripped.replace('}', " "); + if(struct_on == true) + { + if (treeMode) + { + node = new QListViewItem(sctNode, lastSctNode, stripped); + lastSctNode = node; + } + else node = new QListViewItem(symbols, symbols->lastItem(), stripped); + node->setPixmap(0, (const QPixmap &)sct); + node->setText(1, QString::number( tmpPos, 10)); + } + //kdDebug(13000)<<"Structure -- Inserted : "<<stripped<<" at row : "<<i<<endl; + stripped = ""; + block = 0; + structure = false; + //break; + continue; + } + if (cl.at(j) >= 0x20) stripped += cl.at(j); + } // BLOCK 4 + } // comment != 2 + //kdDebug(13000)<<"Stripped : "<<stripped<<" at row : "<<i<<endl; + } // End of For cycle + } // BLOCK > 0 + if (mclass == 4 && block == 0 && func_close == 0) + { + if (cl.find('}') >= 0) + { + cl = cl.right(cl.find('}')); + mclass = 0; + } + } + } // Comment != 1 + } // for kv->numlines + + //for (i= 0; i < (symbols->itemIndex(node) + 1); i++) + // kdDebug(13000)<<"Symbol row :"<<positions.at(i) <<endl; +} + + diff --git a/kate/cppsymbolviewer/katecppsymbolviewer.desktop b/kate/cppsymbolviewer/katecppsymbolviewer.desktop new file mode 100644 index 0000000..77716b4 --- /dev/null +++ b/kate/cppsymbolviewer/katecppsymbolviewer.desktop @@ -0,0 +1,115 @@ +[Desktop Entry] +Type=Service +ServiceTypes=Kate/Plugin +X-KDE-Library=katecppsymbolviewerplugin +X-Kate-Version=2.5 +Name=Kate C/C++ Symbol Viewer +Name[ar]=مستعرض الرموز C/C++ لِــ Kate +Name[br]=Gweller an arouezoù C/C++ evit Kate +Name[bs]=Kate C/C++ preglednik simbola +Name[ca]=Visor de símbols C/C++ per a Kate +Name[cs]=Prohlížeč symbolů C/C++ pro Kate +Name[da]=Kate C/C++ symbolfremviser +Name[de]=C/C++-Symbolbetrachter für Kate +Name[el]=Προβολέας συμβόλων Kate C/C++ +Name[eo]=Kodredaktila C/C++ simbolvidilo +Name[es]=Visor de símbolos de Kate C/C++ +Name[et]=Kate C/C++ sümbolite näitaja +Name[eu]=Kateren C/C++ sinbolo ikustailea +Name[fa]=مشاهدهگر نماد Kate C/C++ +Name[fi]=Katen C/C++-symboleiden näyttäjä +Name[fr]=Visualiseur de symboles C/C++ pour Kate +Name[fy]=Kate C/C++ symboalen-werjefteprogramma +Name[ga]=Amharcán Siombailí C/C++ le haghaidh Kate +Name[gl]=Visor de Símbolos C/C++ para Kate +Name[he]=מציג סמלים של C/C++ עבור Kate +Name[hi]=के-एटीई C/C++ प्रतीक प्रदर्शक +Name[hr]=Kate C/C++ preglednik znakova +Name[hu]=Kate-bővítőmodul C/C++-szimbólumok megjelenítéséhez +Name[is]=Kate C/C++ táknabirtir +Name[it]=Visualizzatore Kate per simboli C/C++ +Name[ja]=Kate C/C++ シンボルビューア +Name[ka]=Kate C/C++სიმბოლოთა მხილველი +Name[kk]=Kate C/C++ карап-шығушысы +Name[km]=កម្មវិធីមើលនិមិត្តសញ្ញា Kate C/C++ +Name[lt]=Kate C/C++ simbolių žiūryklė +Name[mk]=Прегледувач на C/C++ симболи за Кате +Name[ms]=Kate C/C++ Pemapar Simbol +Name[nb]=Kate C/C++ symbolviser +Name[nds]=C/C++-Symboolkieker för Kate +Name[ne]=केट C/C++ सङ्केत दर्शक +Name[nl]=Kate C/C++ symbolen-weergaveprogramma +Name[nn]=Kate C/C++-symbolvisar +Name[pa]=ਕੇਟ C/C++ ਨਿਸ਼ਾਨ ਦਰਸ਼ਕ +Name[pl]=Przeglądarka symboli C/C++ dla Kate +Name[pt]=Visualizador de Símbolos C/C++ do Kate +Name[pt_BR]=Visualizador de símbolos C/C++ do Kate +Name[ru]=Вывод идентификаторов C/C++ +Name[sk]=Prehliadač symbolov C/C++ pre Kate +Name[sl]=Pregledovalnik simbolov C/C++ v Kate +Name[sr]=Прегледање C/C++ симбола за Kate +Name[sr@Latn]=Pregledanje C/C++ simbola za Kate +Name[sv]=Kate C/C++-symbolvisning +Name[ta]=Kate C/C++ குறி பார்வையாளர் +Name[tg]=Хориҷи нишондиҳандаҳои C/C++ +Name[tr]=Kate C/C++ Sembol Görüntüleyici +Name[uk]=Kate переглядач символів C/C++ +Name[vi]=Bộ xem ký hiệu C/C++ Kate +Name[zh_CN]=Kate C/C++ 符号查看器 +Name[zh_TW]=Kate C/C++ 符號檢視器 +Comment=This plugin extracts and shows C/C++ symbols from source +Comment[ar]=هذا الملحق يستخرج و يعرض الرموز C/C++ من المصدرية +Comment[az]=Bu əlavə mənbədəki C/C++ simvollarını açır və göstərir +Comment[bg]=Приставка за извличане и показване на символите C/C++ от изходния код +Comment[bs]=Ovaj plugin raspakuje i prikazuje C/C++ simbole iz izvornog koda +Comment[ca]=Aquest connector extrau i mostra els símbols C/C++ des de la font +Comment[cs]=Tento modul extrahuje a ukazuje C/C++ symboly ze zdroje +Comment[cy]=Alldynna'r ategyn yma symbolau C/C++ o darddiad a'u dangos. +Comment[da]=Dette plugin trækker C/C++ symboler ud fra kilde og viser dem +Comment[de]=Dieses Modul liest C/C++-Symbole vom Quelltext ein und zeigt sie an. +Comment[el]=Αυτό το πρόσθετο εξάγει και εμφανίζει σύμβολα C/C++ από τον πηγαίο κώδικα +Comment[eo]=Tiu kromaĵo eltiras kaj montras C/C++ simbolojn el fonto +Comment[es]=Este complemento extrae y muestra símbolos C/C++ desde los fuentes +Comment[et]=See plugin leiab lähtetekstist C/C++ sümbolid ja näitab neid +Comment[eu]=Plugin honek C/C++ sinboloak iturburutik atera eta erakutsi egiten ditu +Comment[fa]=این وصله نمادهای C/C++ را از متن استخراج کرده و نمایش میدهد +Comment[fi]=Tämä liitännäinen hakee ja näyttää C/C++-symbolit lähdekoodista +Comment[fr]=Ce module extrait et affiche les symboles C/C++ du source +Comment[fy]=Dizze plugin hellet de C/C++-symboalen út de boarnekoade en toant se +Comment[ga]=Baineann an breiseán seo siombailí C/C++ as cód foinseach agus taispeánann sé iad +Comment[gl]=Este plugin extrai e mostra símbolos C/C++ do código fonte +Comment[he]= תוסף זה מוציא ומראה סמלים מתוך קבצי C/C++ +Comment[hi]=यह प्लगइन स्रोत में से C/C++ प्रतीकों को उद्धृत कर प्रदर्शित करता है +Comment[hr]=Dodatak za izvlačenje i prikazivanje simbola C/C++ iz izvornog koda +Comment[hu]=Ezzel a bővítőmodullal C/C++-os forrásfájlokból lehet kilistázni a szimbólumokat +Comment[is]=Þetta íforrit sækir og birtir C/C++ tákn úr frumkóða +Comment[it]=Questo plugin estrae e mostra simboli C/C++ dal sorgente +Comment[ja]=ソースから C/C++ のシンボルを抽出して表示します +Comment[ka]=ეს მოდული წყაროდან იღებს და აჩვენებს C/C++ სიმბოლოებს +Comment[kk]=C/C++ идентификаторларды мәтінде бөліп көрсететін плагин модулі +Comment[km]=កម្មវិធីជំនួយនេះស្រង់ចេញ និងបង្ហាញនិមិត្តសញ្ញា C/C++ ពីប្រភព +Comment[lt]=Šis priedas iš šaltinių ištraukia ir parodo C/C++ simbolius +Comment[mk]=Овој приклучок извлекува и прикажува C/C++ симболи од изворен код +Comment[ms]=Plug masuk ekstrak dan papar simbol C/C++ dari sumber +Comment[nb]=Denne modulen finner og viser C/C++-symboler fra kildekoden +Comment[nds]=Dit Moduul treckt Symbolen ut C/C++-Bornkode rut un wiest disse +Comment[ne]=यो प्लगइनले निष्कर्षण गर्दछ र स्रोतबाट C/C++ सङ्केत देखाउछ +Comment[nl]=Deze plugin haalt de C/C++-symbolen uit de broncode en toont deze +Comment[nn]=Dette programtillegget hentar ut og viser C/C++-symbol frå kjeldekode +Comment[pl]=Ta wtyczka pokazuje symbole C/C++ znalezione w pliku źródłowym +Comment[pt]=Este 'plugin' extrai e mostra símbolos C/C++ do código fonte +Comment[pt_BR]=Este plugin extrai e exibe símbolos C/C++ do código-fonte +Comment[ro]=Acest modul extrage şi afişează simbolurile C/C++ din fişierele sursă +Comment[ru]=Извлекает и показывает идентификаторы C/C++ из исходного кода +Comment[sk]=Tento modul získa a zobrazí symboly C/C++ zo zdrojového kódu +Comment[sl]=Ta vstavek izvleče in prikaže simbole C/C++ iz izvorne kode +Comment[sr]=Овај прикључак извлачи и приказује C/C++ симболе из извора +Comment[sr@Latn]=Ovaj priključak izvlači i prikazuje C/C++ simbole iz izvora +Comment[sv]=Insticksprogram som hämtar och visar C/C++-symboler från källkoden +Comment[ta]= இந்த சொருகுபொருள் மூலத்தில் இருந்து C/C++ குறீயீடுகளை சுருக்கி காட்டும் +Comment[tg]=Бароварда ва нишон додани нишондиҳандаҳои C/C++ аз коди баромад +Comment[tr]=Bu plugini seçip çıkarır ve C/C++ simge kaynağını gösterir +Comment[uk]=Цей втулок добуває і показує символи коду джерела C/C++ +Comment[vi]=Bổ sung này rút và hiển thị các ký hiệu C/C++ từ nguồn +Comment[zh_CN]=此插件将从源代码中提取并显示 C/C++ 符号 +Comment[zh_TW]=此外掛程式展開並顯示源碼中的 C/C++ 符號。 diff --git a/kate/cppsymbolviewer/plugin_katesymbolviewer.cpp b/kate/cppsymbolviewer/plugin_katesymbolviewer.cpp new file mode 100644 index 0000000..3e18097 --- /dev/null +++ b/kate/cppsymbolviewer/plugin_katesymbolviewer.cpp @@ -0,0 +1,337 @@ +/*************************************************************************** + * plugin_katesymbolviewer.cpp - description + * ------------------- + * begin : Apr 2 2003 + * author : 2003 Massimo Callegari + * email : massimocallegari@yahoo.it + * + * Changes: + * Nov 09 2004 v.1.3 - For changelog please refer to KDE CVS + * Nov 05 2004 v.1.2 - Choose parser from the current highlight. Minor i18n changes. + * Nov 28 2003 v.1.1 - Structured for multilanguage support + * Added preliminary Tcl/Tk parser (thanks Rohit). To be improved. + * Various bugfixing. + * Jun 19 2003 v.1.0 - Removed QTimer (polling is Evil(tm)... ) + * - Captured documentChanged() event to refresh symbol list + * - Tooltips vanished into nowhere...sigh :( + * May 04 2003 v 0.6 - Symbol List becomes a KListView object. Removed Tooltip class. + * Added a QTimer that every 200ms checks: + * * if the list width has changed + * * if the document has changed + * Added an entry in the popup menu to switch between List and Tree mode + * Various bugfixing. + * Apr 24 2003 v 0.5 - Added three check buttons in popup menu to show/hide symbols + * Apr 23 2003 v 0.4 - "View Symbol" moved in Settings menu. "Refresh List" is no + * longer in Kate menu. Moved into a popup menu activated by a + * mouse right button click. + Bugfixing. + * Apr 22 2003 v 0.3 - Added macro extraction + several bugfixing + * Apr 19 2003 v 0.2 - Added to CVS. Extract functions and structures + * Apr 07 2003 v 0.1 - First version. + * + ***************************************************************************/ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "plugin_katesymbolviewer.h" +#include "plugin_katesymbolviewer.moc" + +#include <kaction.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kgenericfactory.h> +#include <kfiledialog.h> + +#include <qlayout.h> +#include <qgroupbox.h> + +K_EXPORT_COMPONENT_FACTORY( katecppsymbolviewerplugin, KGenericFactory<KatePluginSymbolViewer>( "katesymbolviewer" ) ) + +KatePluginSymbolViewerView::KatePluginSymbolViewerView(Kate::MainWindow *w) +{ + KGlobal::locale()->insertCatalogue("katecppsymbolviewer"); + KToggleAction* act = new KToggleAction ( i18n("Hide Symbols"), 0, this, SLOT( slotInsertSymbol() ), actionCollection(), "view_insert_symbolviewer" ); + act->setCheckedState(i18n("Show Symbols")); + + setInstance (new KInstance("kate")); + setXMLFile("plugins/katecppsymbolviewer/ui.rc"); + w->guiFactory()->addClient (this); + win = w; + symbols = 0; + + m_Active = false; + popup = new QPopupMenu(); + popup->insertItem(i18n("Refresh List"), this, SLOT(slotRefreshSymbol())); + popup->insertSeparator(); + m_macro = popup->insertItem(i18n("Show Macros"), this, SLOT(toggleShowMacros())); + m_struct = popup->insertItem(i18n("Show Structures"), this, SLOT(toggleShowStructures())); + m_func = popup->insertItem(i18n("Show Functions"), this, SLOT(toggleShowFunctions())); + popup->insertSeparator(); + popup->insertItem(i18n("List/Tree Mode"), this, SLOT(slotChangeMode())); + m_sort = popup->insertItem(i18n("Enable sorting"), this, SLOT(slotEnableSorting())); + + popup->setItemChecked(m_macro, true); + popup->setItemChecked(m_struct, true); + popup->setItemChecked(m_func, true); + macro_on = true; + struct_on = true; + func_on = true; + slotInsertSymbol(); +} + +KatePluginSymbolViewerView::~KatePluginSymbolViewerView() +{ + win->guiFactory()->removeClient (this); + delete dock; + delete popup; +} + +void KatePluginSymbolViewerView::toggleShowMacros(void) +{ + bool s = !popup->isItemChecked(m_macro); + popup->setItemChecked(m_macro, s); + macro_on = s; + slotRefreshSymbol(); +} + +void KatePluginSymbolViewerView::toggleShowStructures(void) +{ + bool s = !popup->isItemChecked(m_struct); + popup->setItemChecked(m_struct, s); + struct_on = s; + slotRefreshSymbol(); +} + +void KatePluginSymbolViewerView::toggleShowFunctions(void) +{ + bool s = !popup->isItemChecked(m_func); + popup->setItemChecked(m_func, s); + func_on = s; + slotRefreshSymbol(); +} + +void KatePluginSymbolViewerView::slotInsertSymbol() +{ + QPixmap cls( ( const char** ) class_xpm ); + + if (m_Active == false) + { + dock = win->toolViewManager()->createToolView("kate_plugin_cppsymbolviewer", Kate::ToolViewManager::Left, cls, i18n("Symbol List")); + + symbols = new KListView(dock); + treeMode = 0; + + connect(symbols, SIGNAL(executed(QListViewItem *)), this, SLOT(goToSymbol(QListViewItem *))); + connect(symbols, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint&, int)), + SLOT(slotShowContextMenu(QListViewItem *, const QPoint&, int))); + connect(win->viewManager(), SIGNAL(viewChanged()), this, SLOT(slotDocChanged())); + //connect(symbols, SIGNAL(resizeEvent(QResizeEvent *)), this, SLOT(slotViewChanged(QResizeEvent *))); + + m_Active = true; + //symbols->addColumn(i18n("Symbols"), symbols->parentWidget()->width()); + symbols->addColumn(i18n("Symbols")); + symbols->addColumn(i18n("Position")); + symbols->setColumnWidthMode(1, QListView::Manual); + symbols->setColumnWidth ( 1, 0 ); + symbols->setSorting(-1, FALSE); + symbols->setRootIsDecorated(0); + symbols->setTreeStepSize(10); + symbols->setShowToolTips(TRUE); + + /* First Symbols parsing here...*/ + parseSymbols(); + } + else + { + delete dock; + dock = 0; + symbols = 0; + m_Active = false; + } +} + +void KatePluginSymbolViewerView::slotRefreshSymbol() +{ + if (!symbols) + return; + symbols->clear(); + parseSymbols(); +} + +void KatePluginSymbolViewerView::slotChangeMode() +{ + treeMode = !treeMode; + symbols->clear(); + parseSymbols(); +} + +void KatePluginSymbolViewerView::slotEnableSorting() +{ + lsorting = !lsorting; + popup->setItemChecked(m_sort, lsorting); + symbols->clear(); + if (lsorting == TRUE) + symbols->setSorting(0, TRUE); + else + symbols->setSorting(-1, FALSE); + + parseSymbols(); +} + +void KatePluginSymbolViewerView::slotDocChanged() +{ + //kdDebug(13000)<<"Document changed !!!!"<<endl; + slotRefreshSymbol(); +} + +void KatePluginSymbolViewerView::slotViewChanged(QResizeEvent *) +{ + kdDebug(13000)<<"View changed !!!!"<<endl; + symbols->setColumnWidth(0, symbols->parentWidget()->width()); +} + +void KatePluginSymbolViewerView::slotShowContextMenu(QListViewItem *, const QPoint &p, int) +{ + popup->popup(p); +} + +void KatePluginSymbolViewerView::parseSymbols(void) +{ + unsigned int hlMode = 0; + + if (!win->viewManager()->activeView()) + return; + + Kate::Document *kv = win->viewManager()->activeView()->getDoc(); + + // be sure we have some document around ! + if (!kv) + return; + + /** Get the current highlighting mode */ + hlMode = kv->hlMode(); + QString hlModeName = kv->hlModeName(hlMode); + + //QListViewItem mcrNode = new QListViewItem(symbols, symbols->lastItem(), hlModeName); + + if (hlModeName == "C++" || hlModeName == "C") + parseCppSymbols(); + else if (hlModeName == "Tcl/Tk") + parseTclSymbols(); + else if (hlModeName == "Java") + parseCppSymbols(); +} + +void KatePluginSymbolViewerView::goToSymbol(QListViewItem *it) +{ + Kate::View *kv = win->viewManager()->activeView(); + + // be sure we really have a view ! + if (!kv) + return; + + kdDebug(13000)<<"Slot Activated at pos: "<<symbols->itemIndex(it) <<endl; + kv->gotoLineNumber(it->text(1).toInt(NULL, 10) + 10); + kv->setFocus(); + kv->gotoLineNumber(it->text(1).toInt(NULL, 10)); +} + +KatePluginSymbolViewer::KatePluginSymbolViewer( QObject* parent, const char* name, const QStringList& ) + : Kate::Plugin ( (Kate::Application*)parent, name ), + pConfig("katecppsymbolviewerpluginrc") +{ + pConfig.setGroup("global"); +} + +KatePluginSymbolViewer::~KatePluginSymbolViewer() +{ + pConfig.sync(); +} + +void KatePluginSymbolViewer::addView (Kate::MainWindow *win) +{ + KatePluginSymbolViewerView *view = new KatePluginSymbolViewerView (win); + m_views.append (view); + view->types_on = pConfig.readBoolEntry("view_types", true); + view->expanded_on = pConfig.readBoolEntry("expand_tree", false); +} + +void KatePluginSymbolViewer::removeView(Kate::MainWindow *win) +{ + for (uint z=0; z < m_views.count(); z++) + if (m_views.at(z)->win == win) + { + KatePluginSymbolViewerView *view = m_views.at(z); + m_views.remove (view); + pConfig.writeEntry("view_types", view->types_on); + pConfig.writeEntry("expand_tree", view->expanded_on); + delete view; + return; + } +} + +Kate::PluginConfigPage* KatePluginSymbolViewer::configPage( + uint, QWidget *w, const char* /*name*/) +{ + KatePluginSymbolViewerConfigPage* p = new KatePluginSymbolViewerConfigPage(this, w); + initConfigPage( p ); + connect( p, SIGNAL(configPageApplyRequest(KatePluginSymbolViewerConfigPage*)), + SLOT(applyConfig(KatePluginSymbolViewerConfigPage *)) ); + return (Kate::PluginConfigPage*)p; +} + +void KatePluginSymbolViewer::initConfigPage( KatePluginSymbolViewerConfigPage* p ) +{ + p->viewReturns->setChecked(pConfig.readBoolEntry("view_types", true)); + p->expandTree->setChecked(pConfig.readBoolEntry("expand_tree", false)); +} + +void KatePluginSymbolViewer::applyConfig( KatePluginSymbolViewerConfigPage* p ) +{ + for (uint z=0; z < m_views.count(); z++) + { + m_views.at(z)->types_on = p->viewReturns->isChecked(); + m_views.at(z)->expanded_on = p->expandTree->isChecked(); + //kdDebug(13000)<<"KatePluginSymbolViewer: Configuration applied.("<<m_SymbolView->types_on<<")"<<endl; + m_views.at(z)->slotRefreshSymbol(); + } + + pConfig.writeEntry("view_types", p->viewReturns->isChecked()); + pConfig.writeEntry("expand_tree", p->expandTree->isChecked()); +} + +// BEGIN KatePluginSymbolViewerConfigPage +KatePluginSymbolViewerConfigPage::KatePluginSymbolViewerConfigPage( + QObject* /*parent*/ /*= 0L*/, QWidget *parentWidget /*= 0L*/) + : Kate::PluginConfigPage( parentWidget ) +{ + QVBoxLayout* top = new QVBoxLayout(this, 0, + KDialogBase::spacingHint()); + + QGroupBox* gb = new QGroupBox( i18n("Parser Options"), + this, "cppsymbolviewer_config_page_layout" ); + gb->setColumnLayout(1, Qt::Horizontal); + gb->setInsideSpacing(KDialogBase::spacingHint()); + viewReturns = new QCheckBox(i18n("Display functions parameters"), gb); + expandTree = new QCheckBox(i18n("Automatically expand nodes in tree mode"), gb); + + top->add(gb); + top->addStretch(1); +// throw signal changed + connect(viewReturns, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + connect(expandTree, SIGNAL(toggled(bool)), this, SIGNAL(changed())); +} + +KatePluginSymbolViewerConfigPage::~KatePluginSymbolViewerConfigPage() {} + +void KatePluginSymbolViewerConfigPage::apply() +{ + emit configPageApplyRequest( this ); +} +// END KatePluginSymbolViewerConfigPage + diff --git a/kate/cppsymbolviewer/plugin_katesymbolviewer.h b/kate/cppsymbolviewer/plugin_katesymbolviewer.h new file mode 100644 index 0000000..f20f097 --- /dev/null +++ b/kate/cppsymbolviewer/plugin_katesymbolviewer.h @@ -0,0 +1,300 @@ +/*************************************************************************** + plugin_katesymbolviewer.h - description + ------------------- + begin : Apr 2 2003 + author : 2003 Massimo Callegari + email : massimocallegari@yahoo.it + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _PLUGIN_KATE_SYMBOLVIEWER_H_ +#define _PLUGIN_KATE_SYMBOLVIEWER_H_ + +#include <kate/application.h> +#include <kate/documentmanager.h> +#include <kate/document.h> +#include <kate/mainwindow.h> +#include <kate/plugin.h> +#include <kate/view.h> +#include <kate/viewmanager.h> +#include <kate/toolviewmanager.h> +#include <kate/pluginconfiginterface.h> +#include <kate/pluginconfiginterfaceextension.h> + +#include <kdebug.h> +#include <qmemarray.h> +#include <qpopupmenu.h> +#include <qevent.h> +#include <qcheckbox.h> +//#include <qprocess.h> +#include <qregexp.h> +#include <klibloader.h> +#include <klocale.h> +#include <klistview.h> +#include <kiconloader.h> +#include <kconfig.h> + + +class KatePluginSymbolViewerView : public QObject, public KXMLGUIClient +{ + Q_OBJECT + + public: + KatePluginSymbolViewerView (Kate::MainWindow *w); + virtual ~KatePluginSymbolViewerView (); + + void parseSymbols(void); + + public slots: + void slotInsertSymbol(); + void slotRefreshSymbol(); + void slotChangeMode(); + void slotEnableSorting(); + void slotDocChanged(); + void goToSymbol(QListViewItem *); + void slotShowContextMenu(QListViewItem *, const QPoint&, int); + void toggleShowMacros(void); + void toggleShowStructures(void); + void toggleShowFunctions(void); + protected: + void slotViewChanged(QResizeEvent *e); + private: + QPopupMenu *popup; + KListView *symbols; + QWidget *dock; + bool m_Active; + int m_macro, m_struct, m_func, m_sort; + bool macro_on, struct_on, func_on; + bool treeMode, lsorting; + void parseCppSymbols(void); + void parseTclSymbols(void); + public: + Kate::MainWindow *win; + bool types_on; + bool expanded_on; +}; + +/** + * Plugin's config page + */ +class KatePluginSymbolViewerConfigPage : public Kate::PluginConfigPage +{ + Q_OBJECT + + friend class KatePluginSymbolViewer; + + public: + KatePluginSymbolViewerConfigPage (QObject* parent = 0L, QWidget *parentWidget = 0L); + ~KatePluginSymbolViewerConfigPage (); + + /** + * Reimplemented from Kate::PluginConfigPage + * just emits configPageApplyRequest( this ). + */ + virtual void apply(); + + virtual void reset () { ; } + virtual void defaults () { ; } + + signals: + /** + * Ask the plugin to set initial values + */ + void configPageApplyRequest( KatePluginSymbolViewerConfigPage* ); + + /** + * Ask the plugin to apply changes + */ + void configPageInitRequest( KatePluginSymbolViewerConfigPage* ); + + private: + QCheckBox* viewReturns; + QCheckBox* expandTree; +}; + +class KatePluginSymbolViewer : public Kate::Plugin, Kate::PluginViewInterface, Kate::PluginConfigInterfaceExtension +{ + Q_OBJECT + + public: + KatePluginSymbolViewer( QObject* parent = 0, const char* name = 0, const QStringList& = QStringList() ); + virtual ~KatePluginSymbolViewer(); + + void addView (Kate::MainWindow *win); + void removeView (Kate::MainWindow *win); + + uint configPages () const { return 1; } + Kate::PluginConfigPage *configPage (uint , QWidget *w, const char *name=0); + QString configPageName(uint) const { return i18n("Symbol Viewer"); } + QString configPageFullName(uint) const { return i18n("Symbol Viewer Configuration Page"); } + QPixmap configPagePixmap (uint , int ) const { return 0L; } + + public slots: + void applyConfig( KatePluginSymbolViewerConfigPage* ); + + private: + void initConfigPage( KatePluginSymbolViewerConfigPage* ); + + private: + QPtrList<KatePluginSymbolViewerView> m_views; + KConfig pConfig; +}; + +/* XPM */ +static const char* const class_xpm[] = { +"16 16 10 1", +" c None", +". c #000000", +"+ c #A4E8FC", +"@ c #24D0FC", +"# c #001CD0", +"$ c #0080E8", +"% c #C0FFFF", +"& c #00FFFF", +"* c #008080", +"= c #00C0C0", +" .. ", +" .++.. ", +" .+++@@. ", +" .@@@@@#... ", +" .$$@@##.%%.. ", +" .$$$##.%%%&&. ", +" .$$$#.&&&&&*. ", +" ...#.==&&**. ", +" .++..===***. ", +" .+++@@.==**. ", +" .@@@@@#..=*. ", +" .$$@@##. .. ", +" .$$$###. ", +" .$$$##. ", +" ..$#. ", +" .. "}; +static const char * const class_int_xpm[] = { +"16 16 10 1", +" c None", +". c #000000", +"+ c #B8B8B8", +"@ c #8A8A8A", +"# c #212121", +"$ c #575757", +"% c #CCCCCC", +"& c #9A9A9A", +"* c #4D4D4D", +"= c #747474", +" .. ", +" .++.. ", +" .+++@@. ", +" .@@@@@#... ", +" .$$@@##.%%.. ", +" .$$$##.%%%&&. ", +" .$$$#.&&&&&*. ", +" ...#.==&&**. ", +" .++..===***. ", +" .+++@@.==**. ", +" .@@@@@#..=*. ", +" .$$@@##. .. ", +" .$$$###. ", +" .$$$##. ", +" ..$#. ", +" .. "}; + +static const char* const struct_xpm[] = { +"16 16 14 1", +" c None", +". c #000000", +"+ c #C0FFC0", +"@ c #00FF00", +"# c #008000", +"$ c #00C000", +"% c #C0FFFF", +"& c #00FFFF", +"* c #008080", +"= c #00C0C0", +"- c #FFFFC0", +"; c #FFFF00", +"> c #808000", +", c #C0C000", +" .. ", +" .++.. ", +" .+++@@. ", +" .@@@@@#... ", +" .$$@@##.%%.. ", +" .$$$##.%%%&&. ", +" .$$$#.&&&&&*. ", +" ...#.==&&**. ", +" .--..===***. ", +" .---;;.==**. ", +" .;;;;;>..=*. ", +" .,,;;>>. .. ", +" .,,,>>>. ", +" .,,,>>. ", +" ..,>. ", +" .. "}; + +static const char* const macro_xpm[] = { +"16 16 14 1", +" c None", +". c #000000", +"+ c #FF7FE5", +"@ c #FF00C7", +"# c #7F0066", +"$ c #BC0096", +"% c #C0FFFF", +"& c #00FFFF", +"* c #008080", +"= c #00C0C0", +"- c #D493FF", +"; c #A100FF", +"> c #470082", +", c #6B00B7", +" .. ", +" .++.. ", +" .+++@@. ", +" .@@@@@#... ", +" .$$@@##.%%.. ", +" .$$$##.%%%&&. ", +" .$$$#.&&&&&*. ", +" ...#.==&&**. ", +" .--..===***. ", +" .---;;.==**. ", +" .;;;;;>..=*. ", +" .,,;;>>. .. ", +" .,,,>>>. ", +" .,,,>>. ", +" ..,>. ", +" .. "}; + +static const char* const method_xpm[] = { + "16 16 5 1", + " c None", + ". c #000000", + "+ c #FCFC80", + "@ c #E0BC38", + "# c #F0DC5C", + " ", + " ", + " ", + " .. ", + " .++.. ", + " .+++++. ", + " .+++++@. ", + " .. .##++@@. ", + " .++..###@@@. ", + " .+++++.##@@. ", + " .+++++@..#@. ", + " .##++@@. .. ", + " .###@@@. ", + " .###@@. ", + " ..#@. ", + " .. " +}; + +#endif diff --git a/kate/cppsymbolviewer/tcl_parser.cpp b/kate/cppsymbolviewer/tcl_parser.cpp new file mode 100644 index 0000000..ff51e60 --- /dev/null +++ b/kate/cppsymbolviewer/tcl_parser.cpp @@ -0,0 +1,150 @@ +/*************************************************************************** + tcl_parser.cpp - description + ------------------- + begin : Apr 2 2003 + author : 2003 Massimo Callegari + email : massimocallegari@yahoo.it + ***************************************************************************/ + /*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "plugin_katesymbolviewer.h" + +void KatePluginSymbolViewerView::parseTclSymbols(void) +{ + if (!win->viewManager()->activeView()) + return; + + QString currline, prevline; + bool prevComment = false; + QString varStr("set "); + QString procStr("proc"); + QString stripped; + uint i, j, args_par = 0, graph = 0; + char block = 0, parse_func = 0; + + QListViewItem *node = NULL; + QListViewItem *mcrNode = NULL, *clsNode = NULL; + QListViewItem *lastMcrNode = NULL, *lastClsNode = NULL; + + QPixmap mcr( ( const char** ) macro_xpm ); + QPixmap cls( ( const char** ) class_xpm ); + + if(treeMode) + { + clsNode = new QListViewItem(symbols, symbols->lastItem(), i18n("Functions")); + mcrNode = new QListViewItem(symbols, symbols->lastItem(), i18n("Globals")); + lastMcrNode = mcrNode; + lastClsNode = clsNode; + if (expanded_on) + { + clsNode->setOpen(TRUE); + mcrNode->setOpen(TRUE); + } + symbols->setRootIsDecorated(1); + } + else + symbols->setRootIsDecorated(0); + + Kate::Document *kDoc = win->viewManager()->activeView()->getDoc(); + + //positions.resize(kDoc->numLines() + 3); // Maximum symbols number o.O + //positions.fill(0); + + for (i = 0; i<kDoc->numLines(); i++) + { + currline = kDoc->textLine(i); + currline = currline.stripWhiteSpace(); + bool comment = false; + kdDebug(13000)<<currline<<endl; + if(currline.at(0) == '#') comment = true; + + if(i > 0) + { + prevline = kDoc->textLine(i-1); + if(prevline.endsWith("\\") && prevComment) comment = true; + } + prevComment = comment; + + if(!comment) + { + if(currline.startsWith(varStr) && block == 0) + { + if (macro_on == true) // not really a macro, but a variable + { + stripped = currline.right(currline.length() - 3); + stripped = stripped.simplifyWhiteSpace(); + int fnd = stripped.find(' '); + //fnd = stripped.find(";"); + if(fnd > 0) stripped = stripped.left(fnd); + + if (treeMode) + { + node = new QListViewItem(mcrNode, lastMcrNode, stripped); + lastMcrNode = node; + } + else + node = new QListViewItem(symbols, symbols->lastItem(), stripped); + + node->setPixmap(0, (const QPixmap &)mcr); + node->setText(1, QString::number( i, 10)); + stripped = ""; + }//macro + } // starts with "set" + + else if(currline.startsWith(procStr)) { parse_func = 1; } + + if (parse_func == 1) + { + for (j = 0; j < currline.length(); j++) + { + if (block == 1) + { + if(currline.at(j)=='{') graph++; + if(currline.at(j)=='}') + { + graph--; + if (graph == 0) { block = 0; parse_func = 0; continue; } + } + } + if (block == 0) + { + stripped += currline.at(j); + if(currline.at(j) == '{') args_par++; + if(currline.at(j) == '}') + { + args_par--; + if (args_par == 0) + { + //stripped = stripped.simplifyWhiteSpace(); + if(func_on == true) + { + if (treeMode) + { + node = new QListViewItem(clsNode, lastClsNode, stripped); + lastClsNode = node; + } + else + node = new QListViewItem(symbols, symbols->lastItem(), stripped); + node->setPixmap(0, (const QPixmap &)cls); + node->setText(1, QString::number( i, 10)); + } + stripped = ""; + block = 1; + } + } + } // block = 0 + } // for j loop + }//func_on + } // not a comment + } //for i loop + + //positions.resize(symbols->itemIndex(node) + 1); +} + diff --git a/kate/cppsymbolviewer/testfile.c b/kate/cppsymbolviewer/testfile.c new file mode 100644 index 0000000..8f5f959 --- /dev/null +++ b/kate/cppsymbolviewer/testfile.c @@ -0,0 +1,59 @@ +/** Test File...very demoniac for parsing... **/ +#include <stdio.h> +#include <stdlib.h> + +#ifdef (_cplusplus) +{ +#define VALUE 5 + +#define MACRO(x) (x^2) + +# define abs_float(x) \ + ( ((x)<0) ? -(x) : (x) ) + + +typedef struct + { + pTest *pNext; + pTest *pPrev; + } + Another_test, *pTest; + +typedef struct xauth +{ + unsigned short family; + char *address; +} Xauth; + +typedef struct { + color to_move; + occupant board[8][8]; + } game; + +typedef game gt_data; + +/* + A comment with a function hello() { } +*/ +// Continued... + +RockType * + MyMusicFunction( + void *Red, + int Hot, // Comment double slash + char Chili, /* Comment inline */ + unsigned long Peppers) +// A comment..just to make some noise... +{ + // Passed first stage ??? + // Ok..get ready for the second one ! + if(I_Have_Failed() >= 0 && /* comments everywhere :} */ + This_Appears() == 1) + { + printf("Damn !!! Better going to bed :(("); + if ( vs ) // here you are ;} + activateSpace( vs->currentView() ); + } +} + + } diff --git a/kate/cppsymbolviewer/ui.rc b/kate/cppsymbolviewer/ui.rc new file mode 100644 index 0000000..7827306 --- /dev/null +++ b/kate/cppsymbolviewer/ui.rc @@ -0,0 +1,9 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="katesymbolviewer" library="libkatesymbolviewerplugin" version="2"> +<MenuBar> + <Menu name="view"><Text>&Settings</Text> + <Separator /> + <Action name="view_insert_symbolviewer" /> + </Menu> +</MenuBar> +</kpartplugin> |