wyBool 
ExportAsSimpleSQL::WriteToFile(wyString &buffer)
{
    DWORD       dwbyteswritten;
	wyInt32	    ret;
	wyString    error;
		
	
	m_buffer.Add(buffer.GetString());
	
	//if size of filebuffer is more then write to file
	if(m_buffer.GetLength() >=  SIZE_8K)
	{
		ret = WriteFile(m_filename, m_buffer.GetString(), m_buffer.GetLength(), &dwbyteswritten, NULL);
		m_buffer.Clear();
        
		if(!ret)
		{
			error.Sprintf(_("Error no : %d"), GetLastError());
			MessageBox(m_hwnd, error.GetAsWideChar(), pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONERROR);
			return wyFalse;
		}
	}
	
	return wyTrue;
}
Exemplo n.º 2
0
//Function adds text in the edit box.
void
TabMessage::AddText(wyString& str)
{
    SendMessage(m_hwnd, SCI_SETREADONLY, false, 0);
    SendMessage(m_hwnd, SCI_SETTEXT, 0, (LPARAM)str.GetString());
    SendMessage(m_hwnd, SCI_SETREADONLY, true, 0);
    SendMessage(m_hwndcombo, CB_SETCURSEL, 0, 0);
}
void
FindAndReplace::NotFoundMsg(wyString tofind)
{

	wyString msg;
	
	msg.AddSprintf(_("Finished searching the document. Cannot find \"%s\""), tofind.GetString());
	
    ShowMessage(msg.GetAsWideChar(), MB_OK | MB_ICONINFORMATION);
}
wyInt32
FindAndReplace::Replace(wyInt32 posfind, wyInt32 endposition,
					         wyString &replacewhat, wyString &replacewith,
					         wyUInt32 wholeworld, wyUInt32 matchcase)
{   
   
	wyInt32   lastmatch    = posfind;
	wyInt32   replacements = 0;
	
	//Replacement loop
	while(posfind != -1)
	{
		wyInt32 lentarget   = SendMessage(m_hwndedit, SCI_GETTARGETEND, 0, 0) - SendMessage(m_hwndedit, SCI_GETTARGETSTART, 0, 0);
		
		wyInt32 movepasteol = 0;

		wyInt32 replacelen  = replacewith.GetLength();

		wyInt32 lenreplaced = replacelen;
		
		::SendMessage(m_hwndedit, SCI_REPLACETARGET, replacelen, (LPARAM)replacewith.GetString());
		
		//Modify for change caused by replacement
		endposition += lenreplaced - lentarget;
		
		// For the special cases of start of line and end of line
		// something better could be done but there are too many special cases
		lastmatch = posfind + lenreplaced + movepasteol;
		
		if(lentarget == 0)
		{
			lastmatch = SendMessage(m_hwndedit, SCI_POSITIONAFTER, lastmatch, 0);
		}

		if(lastmatch >= endposition)
		{
			// Run off the end of the document/selection with an empty match
			posfind = -1;
		}
		else 
		{
			::SendMessage(m_hwndedit, SCI_SETTARGETSTART, lastmatch, 0);
			::SendMessage(m_hwndedit, SCI_SETTARGETEND, endposition, 0);
			
			posfind = SendMessage(m_hwndedit, SCI_SEARCHINTARGET, replacewhat.GetLength(), (LPARAM)replacewhat.GetString());
		}
		
	    replacements++;
	}
		::SendMessage(m_hwndedit, SCI_SETSEL, lastmatch, lastmatch);

		::SendMessage(m_hwndedit, SCI_ENDUNDOACTION, 0, 0);

		return replacements;
}
Exemplo n.º 5
0
wyInt32
EditorBase::ExecuteQueryThread(wyString query, wyInt32 *stop, MDIWindow *wnd, wyInt32& curline, wyBool isanalyze)
{
	wyInt32			 start=0, end=0, *err = 0;
	QueryThread		 thd;
	HANDLE			 evt;
	QueryResultList	 *list = NULL;
	wyString         *str = new wyString;
    wyString        *querystr;
	PMYSQL			tmpmysql;

    err = new wyInt32;
	*err = 0;
    querystr   = new wyString();
    querystr->SetAs(query.GetString());

	wnd->m_stopmysql=  wnd->m_mysql;

    tmpmysql = &wnd->m_stopmysql;
   		
    QUERYTHREADPARAMS *param = new QUERYTHREADPARAMS;
    list = new QueryResultList;

    param->startpos = start; 
    param->endpos = end; 
    param->linenum = curline;
    param->executestatus = EXECUTE_ALL;
	param->query = querystr;
    param->stop = stop; 
    param->list = list; 
    param->str = str;
	param->tab = wnd->GetActiveTabEditor()->m_pctabmgmt; 
    param->tunnel = wnd->m_tunnel; 
    param->mysql = &wnd->m_mysql; 
	param->error = err;	
    param->isadvedit = m_isadvedit; 
    param->lpcs = &wnd->m_cs;
    param->wnd  = wnd;
	param->isprofile = wyTrue;
	param->m_highlimitvalue = -1;
	param->m_lowlimitvalue = -1;
	param->m_iseditor = isanalyze;
	param->executeoption = ALL;
	param->isedit = wyFalse;
	param->tmpmysql = tmpmysql; 
	param->isexplain = wyFalse;

    InitializeExecution(param);

   	evt = thd.Execute(param);
	return 1;
}
Exemplo n.º 6
0
// Function to create a favorite file or folder in the given path //
wyBool 
FavoriteBase::InsertFavoriteItem(wyString &path, wyBool isfolder , wyString &favquery)
{	
	DWORD				byteswritten;
	HANDLE				hfile;
	//const unsigned char utf8bom[10] = {unsigned char(0xEF), unsigned char(0xBB), unsigned char(0xBF)};
			
	// if the favorite is file type then add the extension//
	if(!isfolder)
	{
		path.Add(".sql");

        hfile = ::CreateFile(path.GetAsWideChar(), GENERIC_WRITE, 0, NULL, CREATE_NEW,
								   NULL, NULL);

		if(hfile  == INVALID_HANDLE_VALUE)
		{
            if(::GetLastError() == ERROR_FILE_EXISTS)
			{
                if(::MessageBox(NULL, _(L"The name you have entered for the shortcut already exists in Favorites menu.\nWould you like to overwrite it?"), _(L"Add Favorite"), MB_YESNO | MB_TASKMODAL | MB_ICONINFORMATION | MB_DEFBUTTON2) == IDYES)
				{
                    hfile = ::CreateFile(path.GetAsWideChar(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, NULL, NULL);
					
					if(hfile  == INVALID_HANDLE_VALUE)
                         OnError(_("Cannot write into Favorite File"));
				}
				else
					return wyFalse;			
			}
			else
			    return OnError(_("Cannot write into Favorite File"));
		}
		
		//if (!::WriteFile(hfile,  utf8bom, 3, &byteswritten , NULL))
		//	return OnError("Cannot write into Favorite File");

        if (!::WriteFile(hfile,  favquery.GetString(), favquery.GetLength(), &byteswritten , NULL))
			return OnError(_("Cannot write into Favorite File"));

        ::CloseHandle(hfile);
	}
    else if(!::CreateDirectory(path.GetAsWideChar(), NULL))
	  return OnError(_("Cannot create Favorite Folder"));
	
    return wyTrue;
}
Exemplo n.º 7
0
// function to process file type Favorite//
wyBool
FavoriteBase::AddFile(HMENU hmenu, wyString &parentpath,  wyWChar *filename)
{
	wyInt32				i , j=0;
	wyUInt32			lengthwchar = 1;
	wyWChar				ext[_MAX_EXT] = {0} , *data = {0};
	wyChar				*path = {0};
	MENUITEMINFO		lpmii={0};
	
	parentpath.GetAsWideChar(&lengthwchar);
	
	path = AllocateBuff(parentpath.GetLength() + 2);
	data = AllocateBuffWChar(wcslen(filename) + 2);

	wcscpy(data, (wyWChar*)filename);
	strcpy(path, (wyChar*)parentpath.GetString());

	for(i = wcslen(data) - 1; i && data[i]!='.'; i--, j++)
		ext[j] = data[i];
	
	if(wcsnicmp(ext, L"lqs", 3) != 0)
		return wyFalse;

	ext[j] = 0;
	data[i] = 0;
	
	lpmii.cbSize		= sizeof(MENUITEMINFO);
	lpmii.fMask			= MIIM_STRING|MIIM_ID|MIIM_DATA;
	lpmii.wID			= m_menuid++;
	lpmii.dwItemData	= (ULONG_PTR)path;
	lpmii.cch			= wcslen(data);
	lpmii.dwTypeData	= data;
	
    VERIFY(::InsertMenuItem(hmenu, -1, TRUE, &lpmii));

	free(data);

    return wyTrue;
}
wyInt32
FindAndReplace::ReplaceAll(wyString& replacewhat, wyString& replacewith, wyUInt32 wholeworld, wyUInt32 matchcase)
{
	if (replacewhat.GetLength() == 0)
	{
		return -1;
	}

	wyInt32 startposition	= 0;
	wyInt32 endposition		= SendMessage(m_hwndedit, SCI_GETLENGTH, 0, 0);

	wyInt32 flags = 0;
	
	if(wholeworld)flags = SCFIND_WHOLEWORD;
	if(matchcase)flags  = SCFIND_MATCHCASE;

	::SendMessage(m_hwndedit, SCI_SETTARGETSTART, startposition, 0);
	::SendMessage(m_hwndedit, SCI_SETTARGETEND, endposition, 0);
	::SendMessage(m_hwndedit, SCI_SETSEARCHFLAGS, flags, 0);
	
	wyInt32 posfind = SendMessage(m_hwndedit, SCI_SEARCHINTARGET, replacewhat.GetLength(), (LPARAM)replacewhat.GetString());

	if((posfind != -1) && (posfind <= endposition))
	{

		::SendMessage(m_hwndedit, SCI_BEGINUNDOACTION, 0, 0);
			
		return Replace(posfind, endposition,
			                    replacewhat, replacewith,
     				            wholeworld, matchcase);
	}

	return 0;
}
Exemplo n.º 9
0
void
EditorFont::SetLexerWords(HWND hwndedit, wyString &keys, wyString &funcs)
{
	SendMessage(hwndedit, SCI_SETKEYWORDS, (WPARAM)0, (LPARAM)keys.GetString());
	SendMessage(hwndedit, SCI_SETKEYWORDS, (WPARAM)3, (LPARAM)funcs.GetString());
}
Exemplo n.º 10
0
wyBool 
FavoriteBase::OnError(wyString errmsg)
{
    DisplayErrorText(::GetLastError(), errmsg.GetString());
    return wyFalse;
}