Example #1
0
File: Env.cpp Project: boulerne/e
void cxEnv::AddSystemVars(const bool isUnix, const wxString &baseAppPath) {
	// TM_SUPPORT_PATH
	wxFileName supportPath = baseAppPath;
	supportPath.AppendDir(wxT("Support"));
	const bool supportPathExists = supportPath.DirExists();
	if (supportPathExists) {
		const wxString tmSupportPath = isUnix ? eDocumentPath::WinPathToCygwin(supportPath) : supportPath.GetPath();
		this->SetEnv(wxT("TM_SUPPORT_PATH"), tmSupportPath);

		// TM_BASH_INIT
		if (isUnix) {
			wxFileName bashInit = supportPath;
			bashInit.AppendDir(wxT("lib"));
			bashInit.SetFullName(wxT("cygwin_bash_init.sh"));
			if (bashInit.FileExists()) {
				wxString s_tmBashInit = eDocumentPath::WinPathToCygwin(bashInit);
				this->SetEnv(wxT("TM_BASH_INIT"), s_tmBashInit);
			}
		}
	}

	// PATH
	wxString envPath;
	if (wxGetEnv(wxT("PATH"), &envPath)) {
#ifdef __WXMSW__
		// Check if cygwin is on the path
		if (!eDocumentPath::CygwinPath().empty()) {
			if (!envPath.Contains(eDocumentPath::CygwinPath())) {
				const wxString binPath = eDocumentPath::CygwinPath() + wxT("\\bin");
				const wxString x11Path = eDocumentPath::CygwinPath() + wxT("\\usr\\X11R6\\bin");

				if (!envPath.empty()) {
					envPath = binPath + wxT(";") + x11Path + wxT(";") + envPath;
				}
			}
		}
#endif // __WXMSW__

		// Add TM_SUPPORT_PATH/bin to the PATH
		if (supportPathExists) {
			wxFileName supportBinPath = supportPath;
			supportBinPath.AppendDir(wxT("bin"));
			if (supportBinPath.DirExists()) {
				envPath = supportBinPath.GetPath() + wxT(";") + envPath;
			}
		}

		this->SetEnv(wxT("PATH"), envPath);
	}

	// TM_APPPATH
	wxString appPath = baseAppPath;
	if (isUnix) appPath = eDocumentPath::WinPathToCygwin(appPath);
	this->SetEnv(wxT("TM_APPPATH"), appPath);

	// TM_FULLNAME
	this->SetEnv(wxT("TM_FULLNAME"), wxGetUserName());
}
Example #2
0
int main(int argc,char **argv)
{
	wxPuts(wxGetHomeDir());
	wxPuts(wxGetOsDescription());
	wxPuts(wxGetUserName());
	wxPuts(wxGetFullHostName());

	long mem = wxGetFreeMemory().ToLong();
	wxPrintf(wxT("Memory: %d\n"),mem);
	return 0;
}
Example #3
0
wxString wxGetUserName()
{
    static const int maxUserNameLen = 1024; // FIXME arbitrary number

    wxString buf;
    bool ok = wxGetUserName(wxStringBuffer(buf, maxUserNameLen), maxUserNameLen);

    if ( !ok )
        buf.Empty();

    return buf;
}
wxString CppCommentCreator::ClassComment()
{
	wxDateTime now = wxDateTime::Now();
	wxString comment;
	comment << wxT("/**\n");
	comment << wxT(" * \\class ") << m_tag->GetName() << wxT("\n");
	comment << wxT(" * \\brief \n");
	comment << wxT(" * \\author ") << wxGetUserName() << wxT("\n");
	comment << wxT(" * \\date ") << now.FormatDate() << wxT("\n");
	comment << wxT(" */\n");
	return comment;
}
Example #5
0
int t04()
{
    wxPuts(wxGetHomeDir());
    wxPuts(wxGetOsDescription());
    wxPuts(wxGetUserName());
    wxPuts(wxGetFullHostName());

    wxMemorySize mem = wxGetFreeMemory();

    wxPrintf(wxT("Memory: %s\n"), mem.ToString());
    return EXIT_SUCCESS;
}
Example #6
0
void InteractiveOutputTestCase::TestUserInfo()
{
#ifdef TEST_INFO_FUNCTIONS
    wxPuts(wxT("*** Testing user info functions ***\n"));

    wxPrintf(wxT("User id is:\t%s\n"), wxGetUserId().c_str());
    wxPrintf(wxT("User name is:\t%s\n"), wxGetUserName().c_str());
    wxPrintf(wxT("Home dir is:\t%s\n"), wxGetHomeDir().c_str());
    wxPrintf(wxT("Email address:\t%s\n"), wxGetEmailAddress().c_str());

    wxPuts(wxEmptyString);
#endif // TEST_INFO_FUNCTIONS
}
Example #7
0
bool wxEmail::Send(wxMailMessage& message, const wxString& profileName, const wxString& WXUNUSED(sendMail))
{
    wxASSERT (message.m_to.GetCount() > 0) ;

    wxString profile(profileName);
    if (profile.IsEmpty())
        profile = wxGetUserName();

    wxMapiSession session;

    if (!session.MapiInstalled())
        return FALSE;
    if (!session.Logon(profile))
        return FALSE;

    return session.Send(message);
}
Example #8
0
int main( int argc, char** argv )
{
    // initialize wxWidgets
    wxInitializer init;

    wxPrintf( wxT("Hello in wxWidgets World!\n\n") );

    // print some system info...
    wxPuts(wxGetHomeDir());
    wxPuts(wxGetOsDescription());
    wxPuts(wxGetUserName());
    wxPuts(wxGetFullHostName());

    long mem = wxGetFreeMemory().ToLong();
    wxPrintf(wxT("Memory: %ld\n"), mem);

    return 0;
}
Example #9
0
bool wxEmail::Send(wxMailMessage& message,  int sendMethod, const wxString& profileName,
    const wxString& sendMail2, const wxString& sendMail1, const wxString& sendMail0)
{
   // wxASSERT (message.m_to.GetCount() > 0) ;
    wxASSERT (!message.m_to.IsEmpty()) ;
    wxString profile(profileName);
    if (profile.IsEmpty())
        profile = wxGetUserName();

    wxMapiSession session;

    if (!session.MapiInstalled())
        return FALSE;
    if (!session.Logon(profile))
        return FALSE;

    return session.Send(message);
}
Example #10
0
static wxString __get_user_name()
{
    wxString squashedname, name = wxGetUserName();

    // The wx doc says that 'name' may now be e.g. "Mr. John Smith"
    // So try to make it more suitable to be an extension
    name.MakeLower();
    name.Replace(wxT(" "), wxT("_"));
    for(size_t i = 0; i < name.Len(); ++i) {
        wxChar ch = name.GetChar(i);
        if((ch < wxT('a') || ch > wxT('z')) && ch != wxT('_')) {
            // Non [a-z_] character: skip it
        } else {
            squashedname << ch;
        }
    }

    return (squashedname.IsEmpty() ? wxString(wxT("someone")) : squashedname);
}
Example #11
0
EWXWEXPORT(wxString*,ELJApp_GetUserName)()
{
	wxString *result = new wxString();
	*result = wxGetUserName();
	return result;
}
Example #12
0
// Get user ID e.g. jacs
bool wxGetUserId(wxChar *buf, int maxSize)
{
    return wxGetUserName(buf, maxSize);
}
Example #13
0
wxString MacroManager::DoExpand(
    const wxString& expression, IManager* manager, const wxString& project, bool applyEnv, const wxString& confToBuild)
{
    wxString expandedString(expression);
    clCxxWorkspace* workspace = clCxxWorkspaceST::Get();

    if(!manager) {
        manager = clGetManager();
    }

    size_t retries = 0;
    wxString dummyname, dummfullname;
    while((retries < 5) && FindVariable(expandedString, dummyname, dummyname)) {
        ++retries;
        DollarEscaper de(expandedString);
        if(workspace) {
            expandedString.Replace(wxT("$(WorkspaceName)"), workspace->GetName());
            ProjectPtr proj = workspace->GetProject(project);
            if(proj) {
                wxString prjBuildWd;
                wxString prjRunWd;

                wxString project_name(proj->GetName());

                // make sure that the project name does not contain any spaces
                project_name.Replace(wxT(" "), wxT("_"));

                BuildConfigPtr bldConf = workspace->GetProjBuildConf(proj->GetName(), confToBuild);
                if(bldConf) {
                    bool isCustom = bldConf->IsCustomBuild();
                    expandedString.Replace(wxT("$(ProjectOutputFile)"), bldConf->GetOutputFileName());
                    // An alias
                    expandedString.Replace(wxT("$(OutputFile)"), bldConf->GetOutputFileName());

                    // When custom build project, use the working directory set in the
                    // custom build tab, otherwise use the project file's path
                    prjBuildWd = isCustom ? bldConf->GetCustomBuildWorkingDir() : proj->GetFileName().GetPath();
                    prjRunWd = bldConf->GetWorkingDirectory();
                }

                expandedString.Replace(wxT("$(ProjectWorkingDirectory)"), prjBuildWd);
                expandedString.Replace(wxT("$(ProjectRunWorkingDirectory)"), prjRunWd);
                expandedString.Replace(wxT("$(ProjectPath)"), proj->GetFileName().GetPath());
                expandedString.Replace(wxT("$(WorkspacePath)"), workspace->GetWorkspaceFileName().GetPath());
                expandedString.Replace(wxT("$(ProjectName)"), project_name);

                if(bldConf) {
                    expandedString.Replace(wxT("$(IntermediateDirectory)"), bldConf->GetIntermediateDirectory());
                    expandedString.Replace(wxT("$(ConfigurationName)"), bldConf->GetName());
                    expandedString.Replace(wxT("$(OutDir)"), bldConf->GetIntermediateDirectory());
                }

                if(expandedString.Find(wxT("$(ProjectFiles)")) != wxNOT_FOUND)
                    expandedString.Replace(wxT("$(ProjectFiles)"), proj->GetFiles());

                if(expandedString.Find(wxT("$(ProjectFilesAbs)")) != wxNOT_FOUND)
                    expandedString.Replace(wxT("$(ProjectFilesAbs)"), proj->GetFiles(true));
            }
        }

        if(manager) {
            IEditor* editor = manager->GetActiveEditor();
            if(editor) {
                wxFileName fn(editor->GetFileName());

                expandedString.Replace(wxT("$(CurrentFileName)"), fn.GetName());

                wxString fpath(fn.GetPath());
                fpath.Replace(wxT("\\"), wxT("/"));
                expandedString.Replace(wxT("$(CurrentFilePath)"), fpath);
                expandedString.Replace(wxT("$(CurrentFileExt)"), fn.GetExt());
                expandedString.Replace(wxT("$(CurrentFileFullName)"), fn.GetFullName());

                wxString ffullpath(fn.GetFullPath());
                ffullpath.Replace(wxT("\\"), wxT("/"));
                expandedString.Replace(wxT("$(CurrentFileFullPath)"), ffullpath);
                expandedString.Replace(wxT("$(CurrentSelection)"), editor->GetSelection());
                if(expandedString.Find(wxT("$(CurrentSelectionRange)")) != wxNOT_FOUND) {
                    int start = editor->GetSelectionStart(), end = editor->GetSelectionEnd();

                    wxString output = wxString::Format(wxT("%i:%i"), start, end);
                    expandedString.Replace(wxT("$(CurrentSelectionRange)"), output);
                }
            }
        }

        // exapand common macros
        wxDateTime now = wxDateTime::Now();
        expandedString.Replace(wxT("$(User)"), wxGetUserName());
        expandedString.Replace(wxT("$(Date)"), now.FormatDate());

        if(manager && applyEnv) {
            expandedString.Replace(wxT("$(CodeLitePath)"), manager->GetInstallDirectory());

            // Apply the environment and expand the variables
            EnvSetter es(NULL, NULL, project, confToBuild);
            expandedString = manager->GetEnv()->ExpandVariables(expandedString, false);
        }
    }
    return expandedString;
}
Example #14
0
void WizardsPlugin::DoCreateNewPlugin()
{
    //Load the wizard
    PluginWizard wiz(wxTheApp->GetTopWindow());
    NewPluginData data;
    if (wiz.Run(data)) {
        //load the template file and replace all variables with the
        //actual values provided by user
        wxString filename(m_mgr->GetStartupDirectory() + wxT("/templates/gizmos/liteeditor-plugin.project.wizard"));
        wxString content;
        if (!ReadFileWithConversion(filename, content)) {
            return;
        }
        
        // Convert the paths provided by user to relative paths
        wxFileName fn(data.GetCodelitePath(), "");
        if ( !fn.MakeRelativeTo( wxFileName(data.GetProjectPath()).GetPath()) ) {
            wxLogMessage(wxT("Warning: Failed to convert paths to relative path."));
        }

#ifdef __WXMSW__
        wxString dllExt(wxT("dll"));
#else
        wxString dllExt(wxT("so"));
#endif

        wxString clpath = fn.GetFullPath();
        fn.Normalize(); // Remove all .. and . from the path
        
        if ( clpath.EndsWith("/") || clpath.EndsWith("\\") ) {
            clpath.RemoveLast();
        }
        
        content.Replace(wxT("$(CodeLitePath)"), clpath);
        content.Replace(wxT("$(DllExt)"), dllExt);
        content.Replace(wxT("$(PluginName)"), data.GetPluginName());
        wxString baseFileName = data.GetPluginName();
        baseFileName.MakeLower();
        content.Replace(wxT("$(BaseFileName)"), baseFileName);
        content.Replace(wxT("$(ProjectName)"), data.GetPluginName());

        //save the file to the disk
        wxString projectFileName;
        projectFileName << data.GetProjectPath();
        {
            wxLogNull noLog;
            ::wxMkdir( wxFileName(data.GetProjectPath()).GetPath() );
        }
        wxFFile file;
        if (!file.Open(projectFileName, wxT("w+b"))) {
            return;
        }

        file.Write(content);
        file.Close();

        //Create the plugin source and header files
        wxFileName srcFile(wxFileName(data.GetProjectPath()).GetPath(), baseFileName);
        srcFile.SetExt("cpp");
        
        wxFileName headerFile(wxFileName(data.GetProjectPath()).GetPath(), baseFileName);
        headerFile.SetExt("h");

        //---------------------------------------------------------------
        //write the content of the file based on the file template
        //---------------------------------------------------------------

        //Generate the source files
        filename = m_mgr->GetStartupDirectory() + wxT("/templates/gizmos/plugin.cpp.wizard");
        content.Clear();
        if (!ReadFileWithConversion(filename, content)) {
            wxMessageBox(_("Failed to load wizard's file 'plugin.cpp.wizard'"), _("CodeLite"), wxICON_WARNING | wxOK);
            return;
        }

        // Expand macros
        content.Replace(wxT("$(PluginName)"), data.GetPluginName());
        content.Replace(wxT("$(BaseFileName)"), baseFileName);
        content.Replace(wxT("$(PluginShortName)"), data.GetPluginName());
        content.Replace(wxT("$(PluginLongName)"), data.GetPluginDescription());
        content.Replace(wxT("$(UserName)"), wxGetUserName().c_str());
        
        // Notify the formatter plugin to format the plugin source files
        clSourceFormatEvent evtFormat(wxEVT_FORMAT_STRING);
        evtFormat.SetInputString( content );
        EventNotifier::Get()->ProcessEvent( evtFormat );
        content = evtFormat.GetFormattedString();
        
        // Write it down
        file.Open(srcFile.GetFullPath(), wxT("w+b"));
        file.Write(content);
        file.Close();
        
        //create the header file
        filename = m_mgr->GetStartupDirectory() + wxT("/templates/gizmos/plugin.h.wizard");
        content.Clear();
        if (!ReadFileWithConversion(filename, content)) {
            wxMessageBox(_("Failed to load wizard's file 'plugin.h.wizard'"), _("CodeLite"), wxICON_WARNING | wxOK);
            return;
        }

        // Expand macros
        content.Replace(wxT("$(PluginName)"), data.GetPluginName());
        content.Replace(wxT("$(BaseFileName)"), baseFileName);
        content.Replace(wxT("$(PluginShortName)"), data.GetPluginName());
        content.Replace(wxT("$(PluginLongName)"), data.GetPluginDescription());
        content.Replace(wxT("$(UserName)"), wxGetUserName().c_str());

        // format the content
        evtFormat.SetString(content);
        EventNotifier::Get()->ProcessEvent( evtFormat );
        content = evtFormat.GetString();
        
        // Write it down
        file.Open(headerFile.GetFullPath(), wxT("w+b"));
        file.Write(content);
        file.Close();

        //add the new project to the workspace
        wxString errMsg;

        //convert the path to be full path as required by the
        //workspace manager
        m_mgr->AddProject(projectFileName);
    }
}