mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 15:02:11 +00:00
added Edit menu
This commit is contained in:
parent
9fbed3223c
commit
7feb35813c
@ -50,4 +50,10 @@
|
||||
|
||||
#define JS_CONSOLE 40100
|
||||
|
||||
#define VIEWER_EDIT_CUT 40201
|
||||
#define VIEWER_EDIT_COPY 40202
|
||||
#define VIEWER_EDIT_PASTE 40203
|
||||
#define VIEWER_EDIT_SELECTALL 40204
|
||||
#define VIEWER_EDIT_FINDINPAGE 40205
|
||||
|
||||
#endif /* resources_h___ */
|
||||
|
@ -45,6 +45,17 @@ VIEWER MENU DISCARDABLE
|
||||
}
|
||||
MENUITEM "&Exit", VIEWER_EXIT
|
||||
}
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "Cu&t", VIEWER_EDIT_CUT, GRAYED
|
||||
MENUITEM "&Copy", VIEWER_EDIT_COPY
|
||||
MENUITEM "&Paste", VIEWER_EDIT_PASTE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select &All", VIEWER_EDIT_SELECTALL, HELP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Find in Page", VIEWER_EDIT_FINDINPAGE
|
||||
, GRAYED
|
||||
END
|
||||
POPUP "&Debug"
|
||||
{
|
||||
MENUITEM "&Visual Debugging", VIEWER_VISUAL_DEBUGGING
|
||||
@ -78,7 +89,7 @@ PRINTPREVIEW MENU DISCARDABLE
|
||||
}
|
||||
}
|
||||
|
||||
JSCONSOLE_MENU MENU DISCARDABLE
|
||||
JSCONSOLE_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
@ -103,9 +114,9 @@ BEGIN
|
||||
POPUP "&Commands"
|
||||
BEGIN
|
||||
MENUITEM "&Evaluate All\tF5", ID_COMMANDSEVALALL
|
||||
MENUITEM "Evaluate &Selection\tF10", ID_COMMANDSEVALSEL
|
||||
MENUITEM "Evaluate &Selection\tF10", ID_COMMANDSEVALSEL
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Inspector", ID_COMMANDSINSPECTOR
|
||||
MENUITEM "&Inspector", ID_COMMANDSINSPECTOR
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
@ -115,6 +126,6 @@ END
|
||||
|
||||
ACCELERATOR_TABLE ACCELERATORS
|
||||
BEGIN
|
||||
VK_F5, ID_COMMANDSEVALALL, VIRTKEY
|
||||
VK_F10, ID_COMMANDSEVALSEL, VIRTKEY
|
||||
VK_F5, ID_COMMANDSEVALALL, VIRTKEY
|
||||
VK_F10, ID_COMMANDSEVALSEL, VIRTKEY
|
||||
END
|
||||
|
@ -49,6 +49,11 @@
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsDocLoader.h"
|
||||
|
||||
// Selection Repaint includes
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIViewManager.h"
|
||||
|
||||
// JSConsole window
|
||||
JSConsole *gConsole = NULL;
|
||||
|
||||
@ -138,7 +143,7 @@ NS_IMETHODIMP DocObserver::SetTitle(const nsString& aTitle)
|
||||
::SetWindowText(wd->window, cp);
|
||||
delete cp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -292,6 +297,80 @@ OpenHTMLFile(WindowData* wd)
|
||||
}
|
||||
}
|
||||
|
||||
// Selects all the Content
|
||||
static void
|
||||
SelectAll(WindowData* wd)
|
||||
{
|
||||
if (wd->ww != nsnull) {
|
||||
nsIDocument* doc = wd->ww->GetDocument();
|
||||
if (doc != nsnull) {
|
||||
doc->SelectAll();
|
||||
wd->ww->ShowFrameBorders(PR_FALSE);
|
||||
/*PRInt32 numShells = doc->GetNumberOfShells();
|
||||
for (PRInt32 i=0;i<numShells;i++) {
|
||||
nsIPresShell * shell = doc->GetShellAt(i);
|
||||
//nsIViewManager * viewMgr = shell->GetViewManager();
|
||||
nsIFrame * frame = shell->GetRootFrame();
|
||||
nsRect rect;
|
||||
nsIView * view;
|
||||
nsPoint pnt;
|
||||
frame->GetOffsetFromView(pnt, view);
|
||||
frame->GetRect(rect);
|
||||
rect.x = pnt.x;
|
||||
rect.y = pnt.y;
|
||||
if (view != nsnull) {
|
||||
nsIViewManager * viewMgr = view->GetViewManager();
|
||||
if (viewMgr != nsnull) {
|
||||
viewMgr->UpdateView(view, rect, 0);
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(shell);
|
||||
//NS_IF_RELEASE(frame);
|
||||
}*/
|
||||
|
||||
NS_IF_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Selects all the Content
|
||||
static void
|
||||
CopyTextContent(WindowData* wd, HWND aHWnd)
|
||||
{
|
||||
HGLOBAL hGlobalMemory;
|
||||
PSTR pGlobalMemory;
|
||||
|
||||
if (wd->ww != nsnull) {
|
||||
nsIDocument* doc = wd->ww->GetDocument();
|
||||
if (doc != nsnull) {
|
||||
// Get Text from Selection
|
||||
nsString text;
|
||||
doc->GetSelectionText(text);
|
||||
|
||||
// Copy text to Global Memory Area
|
||||
hGlobalMemory = (HGLOBAL)GlobalAlloc(GHND, text.Length()+1);
|
||||
if (hGlobalMemory != NULL) {
|
||||
pGlobalMemory = (PSTR) GlobalLock(hGlobalMemory);
|
||||
char * str = text.ToNewCString();
|
||||
char * s = str;
|
||||
for (int i=0;i<text.Length();i++) {
|
||||
*pGlobalMemory++ = *s++;
|
||||
}
|
||||
delete str;
|
||||
|
||||
// Put data on Clipboard
|
||||
GlobalUnlock(hGlobalMemory);
|
||||
OpenClipboard(aHWnd);
|
||||
EmptyClipboard();
|
||||
SetClipboardData(CF_TEXT, hGlobalMemory);
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long PASCAL
|
||||
WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam)
|
||||
{
|
||||
@ -319,6 +398,23 @@ WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam)
|
||||
OpenHTMLFile(wd);
|
||||
break;
|
||||
|
||||
case VIEWER_EDIT_CUT:
|
||||
break;
|
||||
|
||||
case VIEWER_EDIT_COPY:
|
||||
CopyTextContent(wd, hWnd);
|
||||
break;
|
||||
|
||||
case VIEWER_EDIT_PASTE:
|
||||
break;
|
||||
|
||||
case VIEWER_EDIT_SELECTALL:
|
||||
SelectAll(wd);
|
||||
break;
|
||||
|
||||
case VIEWER_EDIT_FINDINPAGE:
|
||||
break;
|
||||
|
||||
case VIEWER_DEMO0:
|
||||
case VIEWER_DEMO1:
|
||||
case VIEWER_DEMO2:
|
||||
@ -375,7 +471,7 @@ WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam)
|
||||
|
||||
// load the accelerator table for the console
|
||||
if (!JSConsole::sAccelTable) {
|
||||
JSConsole::sAccelTable = LoadAccelerators(gInstance,
|
||||
JSConsole::sAccelTable = LoadAccelerators(gInstance,
|
||||
MAKEINTRESOURCE(ACCELERATOR_TABLE));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user