Exemplo n.º 1
0
static int
ui_window_raise(lua_State* L)
{
	HWND hwnd = NULL;
	HWND rootowner;
	HWND lap;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	rootowner = GetAncestor(hwnd, GA_ROOTOWNER);
	if (rootowner != NULL)
		hwnd = rootowner;
	lap = GetLastActivePopup(hwnd);
	if (lap != NULL)
		hwnd = lap;

	if (hwnd != GetForegroundWindow()) {
		SetForegroundWindow(hwnd);
	} else {
		SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
		             (SWP_ASYNCWINDOWPOS
		              | SWP_NOACTIVATE
		              | SWP_NOMOVE
		              | SWP_NOOWNERZORDER
		              | SWP_NOSIZE));
	}
	return 0;
}
Exemplo n.º 2
0
static int
ui_window_lower(lua_State* L)  /* emulate Alt-Esc. */
{
	HWND hwnd = NULL;
	HWND root;
	HWND next_hwnd;
	BOOL syncp = FALSE;
	Crj_ParseArgs(L, "| u Q", &hwnd, &syncp);
	hwnd = GetTargetWindow(hwnd);

	root = GetAncestor(hwnd, GA_ROOT);
	if (root != NULL)
		hwnd = root;

	if (!IsTopmostP(hwnd)) {
		if (hwnd == GetForegroundWindow()) {
			next_hwnd = GetNextAppWindow(hwnd, FALSE);
			if (next_hwnd != NULL)
				SetForegroundWindow(next_hwnd);
		}
		SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0,
		             (((!syncp) ? SWP_ASYNCWINDOWPOS : 0)
		              | SWP_NOACTIVATE
		              | SWP_NOMOVE
		              | SWP_NOOWNERZORDER
		              | SWP_NOSIZE));
	} else {
		if (hwnd == GetForegroundWindow()) {
			next_hwnd = GetNextAppWindow(hwnd, TRUE);
			if (next_hwnd != NULL)
				SetForegroundWindow(next_hwnd);
		}
	}
	return 0;
}
Exemplo n.º 3
0
static int
ui_window_get_title_name(lua_State* L)
{
	HWND hwnd = NULL;
	int length;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	SetLastError(ERROR_SUCCESS);
	length = GetWindowTextLength(hwnd);
	if (0 < length) {
		TCHAR buft[length + 1];  /* the last NUL is not counted. */
		char bufu[Crj_NUMBER_OF(buft) * Utf8_NATIVE_RATIO];
		int last;

		SetLastError(ERROR_SUCCESS);
		last = GetWindowText(hwnd, buft, Crj_NUMBER_OF(buft));
		if ((!last) && (GetLastError() != ERROR_SUCCESS))
			return luaL_error(L, "GetWindowText failed");
		buft[Crj_NUMBER_OF(buft) - 1] = TEXT('\0');

		if (!Utf8_FromNative(bufu, Crj_NUMBER_OF(bufu), buft, -1))
			return luaL_error(L, "Utf8_FromNative failed");
		lua_pushstring(L, bufu);
	} else {
		if (GetLastError() != ERROR_SUCCESS)
			return luaL_error(L, "GetWindowText failed");
		lua_pushstring(L, "");
	}
	return 1;
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
#if 0
	HWND worker;
	HWND defView;
	HWND listView;

	if(!FindDesktopWindows(worker, defView, listView))
	{
		return 1;
	}
#endif

	HWND testWindow = GetTargetWindow();

	DWORD pid;
	DWORD tid = GetWindowThreadProcessId(testWindow, &pid);
	GenericAutoHandle process(OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_READ | PROCESS_VM_OPERATION | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION, FALSE, pid));

	if(process.IsInvalid())
	{
		return 1;
	}

	std::string dllPath = util::getExeDirectory();
	dllPath.insert(dllPath.size(), "TestInjectorDLL.dll");
	//dllPath.insert(dllPath.size(), "TestOGLInjectorDLL.dll");
	//InjectProcess64(process, dllPath.c_str(), "InjectorCrtStubMain");
	InjectProcess32(process, dllPath.c_str(), "InjectorCrtStubMain");

	return 0;
}
Exemplo n.º 5
0
static int
ui_window_restore(lua_State* L)
{
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	PostMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
	return 0;
}
Exemplo n.º 6
0
static int
ui_window_resizablep(lua_State* L)
{
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	lua_pushboolean(L, GetWindowLongPtr(hwnd, GWL_STYLE) & WS_SIZEBOX);
	return 1;
}
Exemplo n.º 7
0
static int
ui_window_maximizedp(lua_State* L)
{
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	lua_pushboolean(L, IsZoomed(hwnd));
	return 1;
}
Exemplo n.º 8
0
static int
ui_window_get_exstyle(lua_State* L)
{
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	lua_pushnumber(L, (lua_Number)GetWindowLongPtr(hwnd, GWL_EXSTYLE));
	return 1;
}
Exemplo n.º 9
0
static int
ui_window_always_on_topp(lua_State* L)
{
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	lua_pushboolean(L, IsTopmostP(hwnd));
	return 1;
}
Exemplo n.º 10
0
static int
ui_window_set_exstyle(lua_State* L)
{
	LONG style;
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "l | u", &style,  &hwnd);
	hwnd = GetTargetWindow(hwnd);

	SetWindowLong(hwnd, GWL_EXSTYLE, style);
	return 0;
}
Exemplo n.º 11
0
static int
ui_window_maximize(lua_State* L)
{
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	PostMessage(hwnd, WM_SYSCOMMAND,
	            (IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE),
	            0);
	return 0;
}
Exemplo n.º 12
0
static int
ui_window_refresh(lua_State* L)
{
	HWND hwnd = NULL;
	UINT flags = 0;
	Crj_ParseArgs(L, "| I u", &flags, &hwnd);
	flags |= SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER;
	hwnd = GetTargetWindow(hwnd);

	SetWindowPos(hwnd, NULL, 0, 0, 0, 0, flags);
	return 0;
}
Exemplo n.º 13
0
/* Size --------------------------------------------------------------- {{{2 */

static int
ui_window_minimizedp(lua_State* L)
{
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	lua_pushboolean(L, IsIconic(hwnd));
	return 1;
}

static int
ui_window_maximizedp(lua_State* L)
{
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	lua_pushboolean(L, IsZoomed(hwnd));
	return 1;
}


static int
ui_window_resizablep(lua_State* L)
{
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	lua_pushboolean(L, GetWindowLongPtr(hwnd, GWL_STYLE) & WS_SIZEBOX);
	return 1;
}




static int ui_window_lower(lua_State*);  /* forward */
static int
ui_window_minimize(lua_State* L)
{
	HWND hwnd = NULL;
	BOOL use_alt_methodp = FALSE;
	Crj_ParseArgs(L, "| u Q", &hwnd, &use_alt_methodp);
	hwnd = GetTargetWindow(hwnd);

	if (IsIconic(hwnd)) {
		PostMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
	} else {
		if (!use_alt_methodp) {
			PostMessage(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
		} else {
			/* NOTE: To avoid trimming the working set of the
			 * target window, use ShowWindow with SW_SHOWMINIMIZED
			 * or SW_SHOWMINNOACTIVE to minimize the target window.
			 * See <http://support.microsoft.com/kb/293215/en-us>
			 * for more detail.
			 *
			 * But this method does not maintain Z-order properly,
			 * so that we have to do it manually by using
			 * ui.window.lower.
			 */
			if (IsTopmostP(hwnd)) {
				/* Place topmost hwnd to the bottom of topmost
				 * windows.  Because ui.window.lower emulates
				 * Alt-Esc and it does not maintain Z-order as
				 * WM_SYSCOMMAND/SC_MINIMIZE does, so that we
				 * have to do manually in this case.
				 */
				HWND bottom_hwnd =GetBottomTopmostWindow(hwnd);
				if (bottom_hwnd != NULL) {
					SetWindowPos(hwnd, bottom_hwnd,
					             0, 0, 0, 0,
					             (SWP_ASYNCWINDOWPOS
					              | SWP_NOACTIVATE
					              | SWP_NOMOVE
					              | SWP_NOOWNERZORDER
					              | SWP_NOSIZE));
				}
			}

			lua_pushcfunction(L, ui_window_lower);
			lua_pushlightuserdata(L, hwnd);
			lua_pushboolean(L, !IsHungAppWindow(hwnd));
			Crj_Call(L, 2, 0);

			ShowWindow(hwnd, SW_SHOWMINNOACTIVE);
		}
	}
	return 0;
}
Exemplo n.º 14
0
static int
ui_window_post_message(lua_State* L)
{
	HWND hwnd = NULL;
	UINT msg = WM_NULL;
	WPARAM wp = 0;
	LPARAM lp = 0;
	Crj_ParseArgs(L, "| u I I L", &hwnd, &msg, &wp, &lp);
	hwnd = GetTargetWindow(hwnd);

	PostMessage(hwnd, msg, wp, lp);
	return 0;
}
Exemplo n.º 15
0
static int
ui_window_get_placement(lua_State* L)
{
	HWND hwnd = NULL;
	RECT rect;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	GetWindowRect(hwnd, &rect);
	lua_pushinteger(L, RECT_X(rect));
	lua_pushinteger(L, RECT_Y(rect));
	lua_pushinteger(L, RECT_WIDTH(rect));
	lua_pushinteger(L, RECT_HEIGHT(rect));
	return 4;
}
Exemplo n.º 16
0
static int
ui_window_set_always_on_top(lua_State* L)
{
	HWND hwnd = NULL;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	SetWindowPos(hwnd, (IsTopmostP(hwnd) ? HWND_NOTOPMOST : HWND_TOPMOST),
	             0, 0, 0, 0,
	             (SWP_ASYNCWINDOWPOS
	              | SWP_NOACTIVATE
	              | SWP_NOMOVE
	              | SWP_NOOWNERZORDER
	              | SWP_NOSIZE));
	return 0;
}
Exemplo n.º 17
0
wxSTEditor* wxSTEditorFindReplacePanel::GetEditor() const
{
    wxWindow* targetWindow = GetTargetWindow();
    wxSTEditor* edit = NULL;

    if (targetWindow)
    {
        if (wxDynamicCast(targetWindow, wxSTEditorNotebook))
            edit = wxDynamicCast(targetWindow, wxSTEditorNotebook)->GetEditor();
        else if (wxDynamicCast(targetWindow, wxSTEditorSplitter))
            edit = wxDynamicCast(targetWindow, wxSTEditorSplitter)->GetEditor();
        else if (wxDynamicCast(targetWindow, wxSTEditor))
            edit = wxDynamicCast(targetWindow, wxSTEditor);
    }

    return edit;
}
Exemplo n.º 18
0
static int
ui_window_resize(lua_State* L)
{
	HWND hwnd = NULL;
	int width;
	int height;
	Crj_ParseArgs(L, "i i | u", &width, &height, &hwnd);
	hwnd = GetTargetWindow(hwnd);

	SetWindowPos(hwnd, NULL, 0, 0, width, height,
	             (SWP_ASYNCWINDOWPOS
	              | SWP_NOACTIVATE
	              | SWP_NOMOVE
	              | SWP_NOOWNERZORDER
	              | SWP_NOZORDER));
	return 0;
}
Exemplo n.º 19
0
window_ptr GetTargetWindow(const point& pt, WindowBase::children_t& list)
{
    window_ptr ret;
    WindowBase::child_riter i = list.rbegin();
    WindowBase::child_riter end = list.rend();
    while(i != end)
    {
        window_ptr p = (*i);
        ++i;
        if (!p->hitTest(pt)) continue;

        ret = GetTargetWindow(pt, p->getChildren());
        if(!ret) ret = p;
        break;
    }
    return ret;
}
Exemplo n.º 20
0
static int
ui_window__move(lua_State* L)
{
	HWND hwnd = NULL;
	int x;
	int y;
	Crj_ParseArgs(L, "i i | u", &x, &y, &hwnd);
	hwnd = GetTargetWindow(hwnd);

	SetWindowPos(hwnd, NULL, x, y, 0, 0,
	             (SWP_ASYNCWINDOWPOS
	              | SWP_NOACTIVATE
	              | SWP_NOOWNERZORDER
	              | SWP_NOSIZE
	              | SWP_NOZORDER));
	return 0;
}
Exemplo n.º 21
0
static int
ui_window_get_class_name(lua_State* L)
{
	HWND hwnd = NULL;
	TCHAR buft[256];  /* this limit is documented in MSDN. */
	char bufu[Crj_NUMBER_OF(buft) * Utf8_NATIVE_RATIO];
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	if (!GetClassName(hwnd, buft, Crj_NUMBER_OF(buft)))
		return luaL_error(L, "GetClassName failed");
	buft[Crj_NUMBER_OF(buft) - 1] = TEXT('\0');
	if (!Utf8_FromNative(bufu, Crj_NUMBER_OF(bufu), buft, -1))
		return luaL_error(L, "Utf8_FromNative failed");
	lua_pushstring(L, bufu);
	return 1;
}
Exemplo n.º 22
0
static int
ui_window_set_alpha(lua_State* L)
{
	int alpha;
	HWND hwnd = NULL;
	LONG exstyle;
	Crj_ParseArgs(L, "i | u", &alpha, &hwnd);
	hwnd = GetTargetWindow(hwnd);

	exstyle = GetWindowLong(hwnd, GWL_EXSTYLE);
	if (exstyle & WS_EX_LAYERED) {
		SetWindowLong(hwnd, GWL_EXSTYLE, exstyle & ~WS_EX_LAYERED);
	} else {
		SetWindowLong(hwnd, GWL_EXSTYLE, exstyle | WS_EX_LAYERED);
		if (alpha < 0)
			alpha = 0;
		if (255 < alpha)
			alpha = 255;
		SetLayeredWindowAttributes(hwnd, 0, alpha, LWA_ALPHA);
	}
	InvalidateRect(hwnd, NULL, TRUE);
	return 0;
}
Exemplo n.º 23
0
/***********************************************************************
 *
 *  Procedure:
 *	main - start of module
 *
 ***********************************************************************/
int main(int argc, char **argv)
{
  char *temp, *s;
  FILE *file;
  char *display_name = NULL;
  int Clength;
  char *tline;

  /* Save the program name for error messages and config parsing */
  temp = argv[0];
  s=strrchr(argv[0], '/');
  if (s != NULL)
    temp = s + 1;
  
  MyName = safemalloc(strlen(temp)+2);
  strcpy(MyName,"*");
  strcat(MyName, temp);
  Clength = strlen(MyName);

  if((argc != 6)&&(argc != 7))
    {
      fprintf(stderr,"%s Version %s should only be executed by fvwm!\n",MyName,
	      VERSION);
      exit(1);
    }

  /* Dead pipe == dead fvwm */
  signal (SIGPIPE, DeadPipe);  

  fd[0] = atoi(argv[1]);
  fd[1] = atoi(argv[2]);

  /* An application window may have already been selected - look for it */
  sscanf(argv[4],"%x",(unsigned int *)&app_win);

  /* Open the Display */
  if (!(dpy = XOpenDisplay(display_name))) 
    {
      fprintf(stderr,"%s: can't open display %s", MyName,
	      XDisplayName(display_name));
      exit (1);
    }
  x_fd = XConnectionNumber(dpy);
  screen= DefaultScreen(dpy);
  Root = RootWindow(dpy, screen);
  d_depth = DefaultDepth(dpy, screen);

  ScreenHeight = DisplayHeight(dpy,screen);
  ScreenWidth = DisplayWidth(dpy,screen);
  
  SetMessageMask(fd,M_CONFIGURE_WINDOW|M_WINDOW_NAME|M_ICON_NAME|
		 M_RES_CLASS| M_RES_NAME| M_END_WINDOWLIST|M_CONFIG_INFO|
		 M_END_CONFIG_INFO);
  /* scan config file for set-up parameters */
  /* Colors and fonts */

  GetConfigLine(fd,&tline);
  
  while(tline != (char *)0)
    {
      if(strlen(tline)>1)
	{
	  if(strncasecmp(tline, CatString3(MyName,"Font",""),Clength+4)==0)
	    {
	      CopyString(&font_string,&tline[Clength+4]);
	    }
	  else if(strncasecmp(tline,CatString3(MyName,"Fore",""),
				Clength+4)==0)
	    {
	      CopyString(&ForeColor,&tline[Clength+4]);
	    }
	  else if(strncasecmp(tline,CatString3(MyName, "Back",""),
				Clength+4)==0)
	    {
	      CopyString(&BackColor,&tline[Clength+4]);
	    }	
	}
      GetConfigLine(fd,&tline);
    }

  if(app_win == 0)
    GetTargetWindow(&app_win);

  fd_width = GetFdWidth();

  /* Create a list of all windows */
  /* Request a list of all windows,
   * wait for ConfigureWindow packets */
  SendInfo(fd,"Send_WindowList",0);

  Loop(fd);

  return 0;
}
Exemplo n.º 24
0
WindowBase* System::getTargetWindow(const point& pt) const
{
    return GetTargetWindow(pt, m_rootWindow->getChildren()).get();
}
Exemplo n.º 25
0
void InjectorProc(void *injectorModule, unsigned int dataSize, const void *data)
{
	util::dcout << "In inject proc." << std::endl;

#if 0
	util::dcout << "Waiting for debugger ..." << std::endl;

	if(IsDebuggerPresent() == FALSE)
	{
		while(IsDebuggerPresent() == FALSE)
		{
			Sleep(100);
		}

		DebugBreak();
	}

	util::dcout << "Debugger attached." << std::endl;
#endif

	HWND targetWindow = GetTargetWindow();
	if(targetWindow == NULL)
	{
		util::dcout << "Cannot find window !" << std::endl;

		return;
	}

	CheckWindow(targetWindow);

	OpenGLDrawData oglData;
	oglData.window = targetWindow;
	if(!InitOpenGLContext(oglData))
	{
		return;
	}
	InitOpenGL(oglData);

	MemoryDC memoryDC(oglData.width, oglData.height);
	oglData.memoryDC = &memoryDC;
	Init(oglData);

	wglMakeCurrent(NULL, NULL);
	g_oglData = &oglData;

	//MakeWindowFullyTransparent(targetWindow);
	WNDPROC originalWndProc = (WNDPROC)GetWindowLongPtr(targetWindow, GWLP_WNDPROC);
	g_originalWndProc = originalWndProc;
	SetWindowLongPtr(targetWindow, GWLP_WNDPROC, (LONG_PTR)HookWndProc);
	InvalidateRect(targetWindow, NULL, TRUE);

	//DrawLoop(oglData);
	//DrawFrame(oglData);
	Sleep(30000);

	wglMakeCurrent(oglData.oglDC, oglData.oglContext);
	DeInit(oglData);
	FreeOpenGLContext(oglData);

	SetWindowLongPtr(targetWindow, GWLP_WNDPROC, (LONG_PTR)originalWndProc);
	//MakeWindowUndo(targetWindow);
	InvalidateRect(targetWindow, NULL, TRUE);

	util::dcout << "Exiting inject proc." << std::endl;
}
Exemplo n.º 26
0
void wxSTEditorFindReplacePanel::Send(wxFindDialogEvent& event)
{
    // we copy the data to dialog->GetData() as well
    m_findReplaceData->SetFlags(event.GetFlags());

    m_findReplaceData->SetFindString(event.GetFindString());
    if (!event.GetFindString().IsEmpty())
        m_findReplaceData->AddFindString(event.GetFindString());

    if ( HasFlag(wxFR_REPLACEDIALOG) &&
         (event.GetEventType() == wxEVT_COMMAND_FIND_REPLACE ||
          event.GetEventType() == wxEVT_COMMAND_FIND_REPLACE_ALL) )
    {
        m_findReplaceData->SetReplaceString(event.GetReplaceString());
        m_findReplaceData->AddReplaceString(event.GetReplaceString());
    }

    // translate wxEVT_COMMAND_FIND_NEXT to wxEVT_COMMAND_FIND if needed
    if ( event.GetEventType() == wxEVT_COMMAND_FIND_NEXT )
    {
        if ( m_findReplaceData->GetFindString() != m_lastSearch )
        {
            event.SetEventType(wxEVT_COMMAND_FIND);
            m_lastSearch = m_findReplaceData->GetFindString();
        }
    }

    // ExtraLong is the line number pressed in the find all editor
    //  when -1 it means that we want a new find all search
    if (m_findReplaceData->HasFlag(STE_FR_FINDALL) && m_resultEditor &&
        (event.GetExtraLong() == -1) &&
        ((event.GetEventType() == wxEVT_COMMAND_FIND) ||
         (event.GetEventType() == wxEVT_COMMAND_FIND_NEXT)))
    {
        m_findReplaceData->GetFindAllStrings()->Clear();
        m_resultEditor->SetReadOnly(false);
        m_resultEditor->SetText(wxEmptyString);
        m_resultEditor->SetReadOnly(true);
    }

    wxWindow *target = GetTargetWindow();

    // first send event to ourselves then to the target
    if ( !GetEventHandler()->ProcessEvent(event) && target )
    {
        // the event is not propagated upwards to the parent automatically
        // because the dialog is a top level window, so do it manually as
        // in 9 cases of 10 the message must be processed by the dialog
        // owner and not the dialog itself
        (void)target->GetEventHandler()->ProcessEvent(event);
    }

    if (m_findReplaceData->HasFlag(STE_FR_FINDALL) && m_resultEditor &&
        (event.GetExtraLong() == -1) &&
        ((event.GetEventType() == wxEVT_COMMAND_FIND) ||
         (event.GetEventType() == wxEVT_COMMAND_FIND_NEXT)))
    {
        wxSTEditor* edit = GetEditor();
        if (edit)
        {
            m_resultEditor->SetLanguage(edit->GetLanguageId());
        }

        wxArrayString* findAllStrings = m_findReplaceData->GetFindAllStrings();
        size_t n, count = findAllStrings->GetCount();
        wxString str;
        for (n = 0; n < count; n++)
            str += findAllStrings->Item(n).AfterFirst(wxT('|'));

        m_resultEditor->Clear();
        m_resultEditor->ClearAllIndicators();

        m_resultEditor->SetReadOnly(false);
        m_resultEditor->SetText(str);
        m_resultEditor->SetReadOnly(true);
        m_resultEditor->Colourise(0, -1);

        wxSTEditorStyles::GetGlobalEditorStyles().SetEditorStyle( 3, STE_STYLE_STRING,
                                                                m_resultEditor, false);
        wxSTEditorStyles::GetGlobalEditorStyles().SetEditorStyle( 4, STE_STYLE_NUMBER,
                                                                m_resultEditor, false);

        for (n = 0; n < count; n++)
        {
            str = findAllStrings->Item(n).AfterFirst(wxT('|'));
            int pos = m_resultEditor->PositionFromLine(n);
            m_resultEditor->StartStyling(pos, 31);
            int length = str.BeforeFirst(wxT('(')).Length() - 1;
            m_resultEditor->SetStyling(length, 3);

            pos = pos + length + 1;
            m_resultEditor->StartStyling(pos, 31);
            length = str.AfterFirst(wxT('(')).BeforeFirst(wxT(')')).Length() + 2;
            m_resultEditor->SetStyling(length, 4);
        }

        m_resultEditor->IndicateAllStrings(m_findReplaceData->GetFindString(),
                                           m_findReplaceData->GetFlags(),
                                           wxSTC_INDIC0_MASK);
    }

    UpdateButtons();
}
Exemplo n.º 27
0
/*
 *
 *  Procedure:
 *      main - start of module
 *
 */
int main(int argc, char **argv)
{
  char *tline;

  module = ParseModuleArgs(argc,argv,0); /* no alias allowed */
  if (module==NULL)
  {
    fprintf(stderr,"FvwmScroll Version %s should only be executed by fvwm!\n",
	    VERSION);
    exit(1);
  }

  if(module->user_argc >= 1)
  {
    extern int Reduction_H;
    extern int Percent_H;
    int len;
    len = strlen(module->user_argv[0])-1;
    if (len >= 0 && module->user_argv[0][len] == 'p')
    {
      module->user_argv[0][len] = '\0';
      Percent_H = atoi(module->user_argv[0]);
    }
    else
    {
      Reduction_H = atoi(module->user_argv[0]);
    }
  }

  if(module->user_argc >= 2)
  {
    extern int Reduction_V;
    extern int Percent_V;
    int len;
    len = strlen(module->user_argv[1])-1;
    if (len >= 0 && module->user_argv[1][len] == 'p')
    {
      module->user_argv[1][len] = '\0';
      Percent_V = atoi(module->user_argv[1]);
    }
    else
    {
      Reduction_V = atoi(module->user_argv[1]);
    }
  }

  /* Dead pipe == dead fvwm */
  signal (SIGPIPE, DeadPipe);

  fd[0] = module->to_fvwm;
  fd[1] = module->from_fvwm;

  /* Open the Display */
  if (!(dpy = XOpenDisplay(NULL)))
  {
    fprintf(stderr,"%s: can't open display\n", module->name);
    exit (1);
  }
  x_fd = XConnectionNumber(dpy);
  screen= DefaultScreen(dpy);
  Root = RootWindow(dpy, screen);

  ScreenHeight = DisplayHeight(dpy,screen);
  ScreenWidth = DisplayWidth(dpy,screen);

  SetMessageMask(fd, M_CONFIG_INFO | M_END_CONFIG_INFO | M_SENDCONFIG);
  SetMessageMask(fd, MX_PROPERTY_CHANGE);
  flib_init_graphics(dpy);

  /* scan config file for set-up parameters */
  /* Colors and fonts */
  InitGetConfigLine(fd,CatString3("*",module->name,0));
  GetConfigLine(fd,&tline);

  while(tline != (char *)0)
  {
    if(strlen(tline)>1)
    {
      if(strncasecmp(tline,CatString3("*",module->name, "Back"),
		     module->namelen+4)==0)
      {
	CopyString(&BackColor,&tline[module->namelen+4]);
	colorset = -1;
      }
      else if(strncasecmp(tline,CatString3("*",module->name,"Colorset"),
                          module->namelen+8)==0)
      {
	sscanf(&tline[module->namelen+8], "%d", &colorset);
	AllocColorset(colorset);
      }
      else if(strncasecmp(tline, "Colorset", 8) == 0)
      {
	LoadColorset(&tline[8]);
      }
    }
    GetConfigLine(fd,&tline);
  }

  XSetErrorHandler(ErrorHandler);

  if(module->window == 0)
    GetTargetWindow(&module->window);

  if(module->window == 0)
    return 0;

  fd_width = GetFdWidth();

  GrabWindow(module->window);

  /* tell fvwm we're running */
  SendFinishedStartupNotification(fd);

  Loop(module->window);
  return 0;
}