/* * sync_project_with_scm.e * * Update the current project's file list, based on dir list definitions in * this macro file. * * Eventually maybe there will be a configuration dialog. Until then, edit * the "projects" array below. * * Long term, SlickEdit needs improved native support for efficiently * automatically updating the list of files in a project. */ #include "slick.sh" /* * TODO: (chrisant) The file system scan takes a long time for large projects. * Either make the scan an interruptible state machine on idle, or move it to * a DLL on a background thread. * * TODO: (chrisant) Measure how long it takes SlickEdit to build the hash and * update the project file list. Investigate if the instant-replace logic * from my old PROJ macro/DLL can be used somehow in SlickEdit. */ /** * Structure that defines one directory to scan. *
Implementation Notes:
* The current implementation will go into an infinite loop if there is a
* cycle in the expanded env vars. Since I've never encountered such a
* situation in the real world, and I don't know offhand how CMD or etc
* resolve such situation, I'm sticking my head in the sand and pretending
* such things don't happen. Please try not to prove me wrong.
*
* @param s String in which to expand env vars.
*
* @return _str String with the expanded env vars.
*/
static _str expand_env_vars( _str s )
{
_str new_s = '';
while ( pos( '(%([A-Za-z_0-9]+)%)', s, 1, 'U' ) )
{
int cchBefore = pos( 'S1' ) - 1;
int cchAfter = length( s ) - ( pos( 'S1' ) + pos( '1' ) - 1 );
new_s = '';
if ( cchBefore )
new_s = new_s :+ substr( s, 1, cchBefore );
new_s = new_s :+ get_env( substr( s, pos( 'S2' ), pos( '2' ) ) );
if ( cchAfter )
new_s = new_s :+ substr( s, length( s ) - ( cchAfter - 1 ), cchAfter );
s = new_s;
}
return s;
}
/**
* Builds a hash array of the files in the project.
*/
static void ssync_getprojectfilelist(_str ProjectName, int (&projectfiles_list):[])
{
_str filelist = "";
int file_view_id = 0;
int orig_view_id = p_window_id;
GetProjectFiles(ProjectName, file_view_id);
p_window_id = file_view_id;
top();
up();
while(!down())
{
_str filename;
get_line(filename);
filename = strip(filename, 'B');
if(filename != "")
{
if(_fpos_case != '')
{
filename = lowcase(filename);
}
projectfiles_list:[filename] = 0;
}
}
p_window_id = orig_view_id;
_delete_temp_view(file_view_id);
}