You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

766 lines
23 KiB

18 years ago
18 years ago
18 years ago
17 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
17 years ago
17 years ago
18 years ago
17 years ago
18 years ago
18 years ago
18 years ago
  1. /****************************************************************/
  2. /* EESchema: find.cpp (functions for seraching a schematic item */
  3. /****************************************************************/
  4. /*
  5. * Search a text (text, value, reference) within a component or
  6. * search a component in libraries, a marker ...,
  7. * in current sheet or whole the project
  8. */
  9. #include "fctsys.h"
  10. #include "appl_wxstruct.h"
  11. #include "common.h"
  12. #include "class_drawpanel.h"
  13. #include "confirm.h"
  14. #include "kicad_string.h"
  15. #include "gestfich.h"
  16. #include "program.h"
  17. #include "general.h"
  18. #include "class_marker_sch.h"
  19. #include "protos.h"
  20. #include "class_library.h"
  21. #include <boost/foreach.hpp>
  22. /* Variables Locales */
  23. static int s_ItemsCount, s_MarkerCount;
  24. static wxString s_OldStringFound;
  25. #include "dialog_find.cpp"
  26. /**************************************************************/
  27. void WinEDA_FindFrame::FindMarker( wxCommandEvent& event )
  28. /**************************************************************/
  29. /* Search markers in whole hierarchy.
  30. * Mouse cursor is put on the marker
  31. * search the first marker, or next marker
  32. */
  33. {
  34. int id = event.GetId();
  35. if( id != FIND_NEXT_MARKER )
  36. m_Parent->FindMarker( 0 );
  37. else
  38. m_Parent->FindMarker( 1 );
  39. Close();
  40. }
  41. /************************************************************************/
  42. SCH_ITEM* WinEDA_SchematicFrame::FindComponentAndItem(
  43. const wxString& component_reference, bool Find_in_hierarchy,
  44. int SearchType,
  45. const wxString& text_to_find,
  46. bool mouseWarp )
  47. /************************************************************************/
  48. /**
  49. * Function FindComponentAndItem
  50. * finds a Component in the schematic, and an item in this component.
  51. * @param component_reference The component reference to find.
  52. * @param text_to_find The text to search for, either in value, reference or elsewhere.
  53. * @param Find_in_hierarchy: false => Search is made in current sheet
  54. * true => the whole hierarchy
  55. * @param SearchType: 0 => find component
  56. * 1 => find pin
  57. * 2 => find ref
  58. * 3 => find value
  59. * >= 4 => unused (same as 0)
  60. * @param mouseWarp If true, then move the mouse cursor to the item.
  61. */
  62. {
  63. DrawSheetPath* sheet, * SheetWithComponentFound = NULL;
  64. SCH_ITEM* DrawList = NULL;
  65. SCH_COMPONENT* Component = NULL;
  66. wxSize DrawAreaSize = DrawPanel->GetClientSize();
  67. wxPoint pos, curpos;
  68. bool DoCenterAndRedraw = FALSE;
  69. bool NotFound = true;
  70. wxString msg;
  71. LIB_PIN* pin;
  72. EDA_SheetList SheetList;
  73. sheet = SheetList.GetFirst();
  74. if( !Find_in_hierarchy )
  75. sheet = m_CurrentSheet;
  76. for( ; sheet != NULL; sheet = SheetList.GetNext() )
  77. {
  78. DrawList = (SCH_ITEM*) sheet->LastDrawList();
  79. for( ; (DrawList != NULL) && (NotFound == true); DrawList = DrawList->Next() )
  80. {
  81. if( DrawList->Type() == TYPE_SCH_COMPONENT )
  82. {
  83. SCH_COMPONENT* pSch;
  84. pSch = (SCH_COMPONENT*) DrawList;
  85. if( component_reference.CmpNoCase( pSch->GetRef( sheet ) ) == 0 )
  86. {
  87. Component = pSch;
  88. SheetWithComponentFound = sheet;
  89. switch( SearchType )
  90. {
  91. default:
  92. case 0: // Find component only
  93. NotFound = FALSE;
  94. pos = pSch->m_Pos;
  95. break;
  96. case 1: // find a pin
  97. pos = pSch->m_Pos; // temporary: will be changed if the pin is found
  98. pin = pSch->GetPin( text_to_find );
  99. if( pin == NULL )
  100. break;
  101. NotFound = FALSE;
  102. pos += pin->m_Pos;
  103. break;
  104. case 2: // find reference
  105. NotFound = FALSE;
  106. pos = pSch->GetField( REFERENCE )->m_Pos;
  107. break;
  108. case 3: // find value
  109. pos = pSch->m_Pos;
  110. if( text_to_find.CmpNoCase( pSch->GetField( VALUE )->m_Text ) != 0 )
  111. break;
  112. NotFound = FALSE;
  113. pos = pSch->GetField( VALUE )->m_Pos;
  114. break;
  115. }
  116. }
  117. }
  118. }
  119. if( (Find_in_hierarchy == FALSE) || (NotFound == FALSE) )
  120. break;
  121. }
  122. if( Component )
  123. {
  124. sheet = SheetWithComponentFound;
  125. if( sheet != GetSheet() )
  126. {
  127. sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() );
  128. *m_CurrentSheet = *sheet;
  129. ActiveScreen = m_CurrentSheet->LastScreen();
  130. m_CurrentSheet->UpdateAllScreenReferences();
  131. DoCenterAndRedraw = TRUE;
  132. }
  133. wxPoint delta;
  134. pos -= Component->m_Pos;
  135. delta = TransformCoordinate( Component->m_Transform, pos );
  136. pos = delta + Component->m_Pos;
  137. wxPoint old_cursor_position = sheet->LastScreen()->m_Curseur;
  138. sheet->LastScreen()->m_Curseur = pos;
  139. curpos = DrawPanel->CursorScreenPosition();
  140. DrawPanel->GetViewStart(
  141. &( GetScreen()->m_StartVisu.x ),
  142. &( GetScreen()->m_StartVisu.y ) );
  143. // Calculating cursor position with original screen.
  144. curpos -= GetScreen()->m_StartVisu;
  145. /* There may be need to reframe the drawing */
  146. #define MARGIN 30
  147. if( (curpos.x <= MARGIN) || (curpos.x >= DrawAreaSize.x - MARGIN)
  148. || (curpos.y <= MARGIN) || (curpos.y >= DrawAreaSize.y - MARGIN) )
  149. {
  150. DoCenterAndRedraw = true;;
  151. }
  152. #undef MARGIN
  153. if( DoCenterAndRedraw )
  154. Recadre_Trace( mouseWarp );
  155. else
  156. {
  157. wxClientDC dc( DrawPanel );
  158. DrawPanel->PrepareGraphicContext( &dc );
  159. EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
  160. DrawPanel->CursorOff( &dc );
  161. if( mouseWarp )
  162. DrawPanel->MouseTo( curpos );
  163. EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
  164. DrawPanel->CursorOn( &dc );
  165. }
  166. }
  167. /* Print diaq */
  168. wxString msg_item;
  169. msg = component_reference;
  170. switch( SearchType )
  171. {
  172. default:
  173. case 0:
  174. break; // Find component only
  175. case 1: // find a pin
  176. msg_item = _( "Pin " ) + text_to_find;
  177. break;
  178. case 2: // find reference
  179. msg_item = _( "Ref " ) + text_to_find;
  180. break;
  181. case 3: // find value
  182. msg_item = _( "Value " ) + text_to_find;
  183. break;
  184. case 4: // find field. todo
  185. msg_item = _( "Field " ) + text_to_find;
  186. break;
  187. }
  188. if( Component )
  189. {
  190. if( !NotFound )
  191. {
  192. if( !msg_item.IsEmpty() )
  193. msg += wxT( " " ) + msg_item;
  194. msg += _( " found" );
  195. }
  196. else
  197. {
  198. msg += _( " found" );
  199. if( !msg_item.IsEmpty() )
  200. {
  201. msg += wxT( " but " ) + msg_item + _( " not found" );
  202. }
  203. }
  204. }
  205. else
  206. {
  207. if( !msg_item.IsEmpty() )
  208. msg += wxT( " " ) + msg_item;
  209. msg += _( " not found" );
  210. }
  211. Affiche_Message( msg );
  212. return DrawList;
  213. }
  214. /*****************************************************************/
  215. SCH_ITEM* WinEDA_SchematicFrame::FindMarker( int SearchType )
  216. /*****************************************************************/
  217. /* Search markers in whole the hierarchy.
  218. * Mouse cursor is put on the marker
  219. * SearchType = 0: search the first marker, else search next marker
  220. */
  221. {
  222. DrawSheetPath* sheet, * FirstSheet = NULL;
  223. SCH_ITEM* DrawList, * FirstStruct = NULL, * Struct = NULL;
  224. MARKER_SCH* Marker = NULL;
  225. int StartCount;
  226. bool NotFound;
  227. wxPoint firstpos, pos;
  228. wxSize DrawAreaSize = DrawPanel->GetClientSize();
  229. wxPoint curpos, old_cursor_position;
  230. bool DoCenterAndRedraw = FALSE;
  231. wxString msg, WildText;
  232. g_LastSearchIsMarker = TRUE;
  233. /* Set s_MarkerCount to 0 if we are look for the first marker */
  234. if( SearchType == 0 )
  235. s_MarkerCount = 0;
  236. EDA_SheetList SheetList;
  237. NotFound = TRUE; StartCount = 0;
  238. /* Search for s_MarkerCount markers */
  239. for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
  240. {
  241. DrawList = (SCH_ITEM*) sheet->LastDrawList();
  242. while( DrawList && NotFound )
  243. {
  244. if( DrawList->Type() == TYPE_MARKER_SCH )
  245. {
  246. Marker = (MARKER_SCH*) DrawList;
  247. NotFound = FALSE;
  248. pos = Marker->m_Pos;
  249. if( FirstSheet == NULL ) /* First item found */
  250. {
  251. FirstSheet = sheet; firstpos = pos;
  252. FirstStruct = DrawList;
  253. }
  254. StartCount++;
  255. if( s_MarkerCount >= StartCount )
  256. {
  257. NotFound = TRUE; /* Search for other markers */
  258. }
  259. else /* We have found s_MarkerCount markers -> Ok */
  260. {
  261. Struct = DrawList; s_MarkerCount++; break;
  262. }
  263. }
  264. DrawList = DrawList->Next();
  265. }
  266. if( NotFound == FALSE )
  267. break;
  268. }
  269. if( NotFound && FirstSheet ) // markers are found, but we have reach the last marker */
  270. {
  271. // After the last marker, the first marker is used */
  272. NotFound = FALSE; sheet = FirstSheet;
  273. Struct = FirstStruct;
  274. pos = firstpos; s_MarkerCount = 1;
  275. }
  276. if( NotFound == FALSE )
  277. {
  278. if( sheet != GetSheet() )
  279. {
  280. sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() );
  281. *m_CurrentSheet = *sheet;
  282. ActiveScreen = m_CurrentSheet->LastScreen();
  283. m_CurrentSheet->UpdateAllScreenReferences();
  284. DoCenterAndRedraw = TRUE;
  285. }
  286. old_cursor_position = sheet->LastScreen()->m_Curseur;
  287. sheet->LastScreen()->m_Curseur = pos;
  288. curpos = DrawPanel->CursorScreenPosition();
  289. DrawPanel->GetViewStart( &m_CurrentSheet->LastScreen()->m_StartVisu.x,
  290. &m_CurrentSheet->LastScreen()->m_StartVisu.y );
  291. curpos.x -= m_CurrentSheet->LastScreen()->m_StartVisu.x;
  292. curpos.y -= m_CurrentSheet->LastScreen()->m_StartVisu.y;
  293. // reposition the window if the chosen marker is off screen.
  294. #define MARGIN 30
  295. if( (curpos.x <= MARGIN) || (curpos.x >= DrawAreaSize.x - MARGIN)
  296. || (curpos.y <= MARGIN) || (curpos.y >= DrawAreaSize.y - MARGIN) )
  297. {
  298. DoCenterAndRedraw = true;;
  299. }
  300. #undef MARGIN
  301. if( DoCenterAndRedraw )
  302. Recadre_Trace( TRUE );
  303. else
  304. {
  305. wxClientDC dc( DrawPanel );
  306. DrawPanel->PrepareGraphicContext( &dc );
  307. EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
  308. DrawPanel->CursorOff( &dc );
  309. DrawPanel->MouseTo( curpos );
  310. EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
  311. DrawPanel->CursorOn( &dc );
  312. }
  313. wxString path = sheet->Path();
  314. msg.Printf( _( "Marker %d found in %s" ), s_MarkerCount, path.GetData() );
  315. Affiche_Message( msg );
  316. }
  317. else
  318. {
  319. Affiche_Message( wxEmptyString );
  320. msg = _( "Marker Not Found" );
  321. DisplayError( this, msg, 10 );
  322. }
  323. return Marker;
  324. }
  325. /**************************************************************/
  326. void WinEDA_FindFrame::FindSchematicItem( wxCommandEvent& event )
  327. /**************************************************************/
  328. /* Find a string in schematic.
  329. * Call to WinEDA_SchematicFrame::FindSchematicItem()
  330. */
  331. {
  332. int id = event.GetId();
  333. if( id == FIND_SHEET )
  334. m_Parent->FindSchematicItem( m_NewTextCtrl->GetValue(), 0 );
  335. else if( id == FIND_HIERARCHY )
  336. m_Parent->FindSchematicItem( m_NewTextCtrl->GetValue(), 1 );
  337. else if( id == FIND_NEXT )
  338. m_Parent->FindSchematicItem( wxEmptyString, 2 );
  339. Close();
  340. }
  341. /************************************************************************/
  342. SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem(
  343. const wxString& pattern, int SearchType, bool mouseWarp )
  344. /************************************************************************/
  345. /**
  346. * Function FindSchematicItem
  347. * finds a string in the schematic.
  348. * @param pattern The text to search for, either in value, reference or elsewhere.
  349. * @param SearchType: 0 => Search is made in current sheet
  350. * 1 => the whole hierarchy
  351. * 2 => or for the next item
  352. * @param mouseWarp If true, then move the mouse cursor to the item.
  353. */
  354. {
  355. DrawSheetPath* Sheet, * FirstSheet = NULL;
  356. SCH_ITEM* DrawList = NULL, * FirstStruct = NULL, * Struct = NULL;
  357. int StartCount;
  358. bool NotFound;
  359. wxPoint firstpos, pos, old_cursor_position;
  360. static int Find_in_hierarchy;
  361. wxSize DrawAreaSize = DrawPanel->GetClientSize();
  362. wxPoint curpos;
  363. bool DoCenterAndRedraw = FALSE;
  364. wxString msg, WildText;
  365. g_LastSearchIsMarker = FALSE;
  366. if( SearchType == 0 )
  367. {
  368. s_OldStringFound = pattern;
  369. Find_in_hierarchy = FALSE;
  370. }
  371. if( SearchType == 1 )
  372. {
  373. s_OldStringFound = pattern;
  374. Find_in_hierarchy = TRUE;
  375. }
  376. if( SearchType != 2 )
  377. s_ItemsCount = 0;
  378. WildText = s_OldStringFound;
  379. NotFound = TRUE;
  380. StartCount = 0;
  381. EDA_SheetList SheetList;
  382. Sheet = SheetList.GetFirst();
  383. if( !Find_in_hierarchy )
  384. Sheet = m_CurrentSheet;
  385. for( ; Sheet != NULL; Sheet = SheetList.GetNext() )
  386. {
  387. DrawList = (SCH_ITEM*) Sheet->LastDrawList();
  388. while( DrawList )
  389. {
  390. switch( DrawList->Type() )
  391. {
  392. case TYPE_SCH_COMPONENT:
  393. SCH_COMPONENT * pSch;
  394. pSch = (SCH_COMPONENT*) DrawList;
  395. if( WildCompareString( WildText, pSch->GetRef( Sheet ), FALSE ) )
  396. {
  397. NotFound = FALSE;
  398. pos = pSch->GetField( REFERENCE )->m_Pos;
  399. break;
  400. }
  401. if( WildCompareString( WildText, pSch->GetField( VALUE )->m_Text, FALSE ) )
  402. {
  403. NotFound = FALSE;
  404. pos = pSch->GetField( VALUE )->m_Pos;
  405. }
  406. break;
  407. case TYPE_SCH_LABEL:
  408. case TYPE_SCH_GLOBALLABEL:
  409. case TYPE_SCH_HIERLABEL:
  410. case TYPE_SCH_TEXT:
  411. SCH_TEXT * pDraw;
  412. pDraw = (SCH_TEXT*) DrawList;
  413. if( WildCompareString( WildText, pDraw->m_Text, FALSE ) )
  414. {
  415. NotFound = FALSE;
  416. pos = pDraw->m_Pos;
  417. }
  418. break;
  419. default:
  420. break;
  421. }
  422. if( NotFound == FALSE ) /* Item found ! */
  423. {
  424. if( FirstSheet == NULL ) /* First Item found */
  425. {
  426. FirstSheet = Sheet;
  427. firstpos = pos;
  428. FirstStruct = DrawList;
  429. }
  430. StartCount++;
  431. if( s_ItemsCount >= StartCount )
  432. {
  433. NotFound = TRUE; /* Continue search of the next element */
  434. }
  435. else
  436. {
  437. Struct = DrawList;
  438. s_ItemsCount++;
  439. break;
  440. }
  441. }
  442. if( NotFound == FALSE )
  443. break;
  444. DrawList = DrawList->Next();
  445. }
  446. if( NotFound == FALSE )
  447. break;
  448. if( Find_in_hierarchy == FALSE )
  449. break;
  450. }
  451. if( NotFound && FirstSheet )
  452. {
  453. NotFound = FALSE;
  454. Sheet = FirstSheet;
  455. Struct = FirstStruct;
  456. pos = firstpos;
  457. s_ItemsCount = 1;
  458. }
  459. if( NotFound == FALSE )
  460. {
  461. if( Sheet != GetSheet() )
  462. {
  463. Sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() );
  464. *m_CurrentSheet = *Sheet;
  465. ActiveScreen = m_CurrentSheet->LastScreen();
  466. m_CurrentSheet->UpdateAllScreenReferences();
  467. DoCenterAndRedraw = TRUE;
  468. }
  469. /* the struct is a TYPE_SCH_COMPONENT type,
  470. * coordinates must be computed according to its orientation matrix
  471. */
  472. if( Struct->Type() == TYPE_SCH_COMPONENT )
  473. {
  474. SCH_COMPONENT* pSch = (SCH_COMPONENT*) Struct;
  475. pos -= pSch->m_Pos;
  476. pos = TransformCoordinate( pSch->m_Transform, pos );
  477. pos += pSch->m_Pos;
  478. }
  479. old_cursor_position = Sheet->LastScreen()->m_Curseur;
  480. Sheet->LastScreen()->m_Curseur = pos;
  481. curpos = DrawPanel->CursorScreenPosition();
  482. DrawPanel->GetViewStart(
  483. &( GetScreen()->m_StartVisu.x ),
  484. &( GetScreen()->m_StartVisu.y ) );
  485. curpos -= m_CurrentSheet->LastScreen()->m_StartVisu;
  486. /* There may be need to reframe the drawing */
  487. #define MARGIN 30
  488. if( (curpos.x <= MARGIN) || (curpos.x >= DrawAreaSize.x - MARGIN)
  489. || (curpos.y <= MARGIN) || (curpos.y >= DrawAreaSize.y - MARGIN) )
  490. {
  491. DoCenterAndRedraw = true;
  492. }
  493. if( DoCenterAndRedraw )
  494. Recadre_Trace( mouseWarp );
  495. else
  496. {
  497. wxClientDC dc( DrawPanel );
  498. DrawPanel->PrepareGraphicContext( &dc );
  499. EXCHG( old_cursor_position, Sheet->LastScreen()->m_Curseur );
  500. DrawPanel->CursorOff( &dc );
  501. if( mouseWarp )
  502. DrawPanel->MouseTo( curpos );
  503. EXCHG( old_cursor_position, Sheet->LastScreen()->m_Curseur );
  504. DrawPanel->CursorOn( &dc );
  505. }
  506. msg = WildText + _( " Found in " ) + Sheet->Last()->m_SheetName;
  507. Affiche_Message( msg );
  508. }
  509. else
  510. {
  511. Affiche_Message( wxEmptyString );
  512. if( !mouseWarp )
  513. {
  514. // if called from RemoteCommand() don't popup the dialog which
  515. // needs to be dismissed, user is in PCBNEW, and does'nt want to
  516. // bother with dismissing the dialog in EESCHEMA.
  517. msg = WildText + _( " Not Found" );
  518. DisplayError( this, msg, 10 );
  519. }
  520. }
  521. return DrawList;
  522. }
  523. /*
  524. * Search for a given component.
  525. *
  526. * The search is made in loaded libraries, and if not found in all libraries
  527. * found in lib paths.
  528. */
  529. void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event )
  530. {
  531. wxArrayString nameList;
  532. wxString Text, FindList;
  533. bool FoundInLib = false;
  534. Text = m_NewTextCtrl->GetValue();
  535. if( Text.IsEmpty() )
  536. {
  537. Close();
  538. return;
  539. }
  540. s_OldStringFound = Text;
  541. if( CMP_LIBRARY::GetLibraryCount() == 0 )
  542. {
  543. DisplayError( this, _( "No component libraries are loaded." ) );
  544. Close();
  545. return;
  546. }
  547. int nbitemsFound = 0;
  548. BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
  549. {
  550. nameList.Clear();
  551. lib.SearchEntryNames( nameList, Text );
  552. if( nameList.IsEmpty() )
  553. continue;
  554. nbitemsFound += nameList.GetCount();
  555. if( !lib.IsCache() )
  556. FoundInLib = true;
  557. for( size_t i = 0; i < nameList.GetCount(); i++ )
  558. {
  559. if( !FindList.IsEmpty() )
  560. FindList += wxT( "\n" );
  561. FindList << _( "Found " ) + nameList[i] + _( " in library " )
  562. + lib.GetName();
  563. }
  564. }
  565. if( !FoundInLib )
  566. {
  567. if( nbitemsFound )
  568. FindList = wxT( "\n" ) + Text + _( " found only in cache" );
  569. else
  570. FindList = Text + _( " not found" );
  571. FindList += _( "\nExplore All Libraries?" );
  572. if( IsOK( this, FindList ) )
  573. {
  574. FindList.Empty();
  575. ExploreAllLibraries( Text, FindList );
  576. if( FindList.IsEmpty() )
  577. DisplayInfoMessage( this, _( "Nothing found" ) );
  578. else
  579. DisplayInfoMessage( this, FindList );
  580. }
  581. }
  582. else
  583. {
  584. DisplayInfoMessage( this, FindList );
  585. }
  586. Close();
  587. }
  588. /***************************************************************************************/
  589. int WinEDA_FindFrame::ExploreAllLibraries( const wxString& wildmask, wxString& FindList )
  590. /***************************************************************************************/
  591. {
  592. wxString FullFileName;
  593. FILE* file;
  594. int nbitems = 0, LineNum = 0;
  595. char Line[2048], * name;
  596. wxString path;
  597. for( unsigned ii = 0; ii < wxGetApp().GetLibraryPathList().GetCount(); ii++ )
  598. {
  599. path = wxGetApp().GetLibraryPathList()[ii] + STRING_DIR_SEP;
  600. FullFileName = wxFindFirstFile( path + wxT( "*." ) + CompLibFileExtension );
  601. while( !FullFileName.IsEmpty() )
  602. {
  603. file = wxFopen( FullFileName, wxT( "rt" ) );
  604. if( file == NULL )
  605. continue;
  606. while( GetLine( file, Line, &LineNum, sizeof(Line) ) )
  607. {
  608. if( strnicmp( Line, "DEF", 3 ) == 0 )
  609. {
  610. /* Read one DEF part from library: DEF 74LS00 U 0 30 Y Y 4 0 N */
  611. strtok( Line, " \t\r\n" );
  612. name = strtok( NULL, " \t\r\n" );
  613. wxString st_name = CONV_FROM_UTF8( name );
  614. if( WildCompareString( wildmask, st_name, FALSE ) )
  615. {
  616. nbitems++;
  617. if( !FindList.IsEmpty() )
  618. FindList += wxT( "\n" );
  619. FindList << _( "Found " ) << CONV_FROM_UTF8( name )
  620. << _( " in lib " ) << FullFileName;
  621. }
  622. }
  623. else if( strnicmp( Line, "ALIAS", 5 ) == 0 )
  624. {
  625. /* Read one ALIAS part from library: ALIAS 74HC00 74HCT00 7400 74LS37 */
  626. strtok( Line, " \t\r\n" );
  627. while( ( name = strtok( NULL, " \t\r\n" ) ) != NULL )
  628. {
  629. wxString st_name = CONV_FROM_UTF8( name );
  630. if( WildCompareString( wildmask, st_name, FALSE ) )
  631. {
  632. nbitems++;
  633. if( !FindList.IsEmpty() )
  634. FindList += wxT( "\n" );
  635. FindList << _( "Found " ) << CONV_FROM_UTF8( name )
  636. << _( " in lib " ) << FullFileName;
  637. }
  638. }
  639. }
  640. }
  641. fclose( file );
  642. FullFileName = wxFindNextFile();
  643. }
  644. }
  645. return nbitems;
  646. }