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.

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