Exemple #1
0
/* ResetWindow */
static short _ResetWindow(LPEXP lpArg, ATOMID idfName, WORD wArg)
{
    ATOMID idWindow;

    /* One argument only */
    if (wArg < 1)
        return KPC_ERROR(IDE_MISSINGARGS, NULLID);

    if (wArg > 1)
        return KPC_ERROR(IDE_TOOMANYARGS, NULLID);

    /* Eval the arg to get the name */
    KappaGetArgAtom(lpArg, 1, idWindow);

    if (!IsValidWindow(idfName, idWindow))
        KappaReturnError;
    else
    {
        OBJECTID idObj = GETOBJECT(idWindow);

        if (!KppCheckObject(idObj, idWindow, idfName, TRUE))
            return NULL;
    }

    if (!KpsResetWindow(idfName, idWindow))
        KappaReturnAtom(lpIDs->idFalse);

    KappaReturnAtom(lpIDs->idTrue);
}
Exemple #2
0
void SWS_TrackListWnd::ClearFilter()
{
	if (IsValidWindow())
		SendMessage(m_hwnd, WM_COMMAND, IDC_CLEAR, 0);
	else
	{
		m_filter.Get()->SetFilter("");
		m_filter.Get()->UpdateReaper(m_bHideFiltered);
	}
}
Exemple #3
0
void SWS_TrackListWnd::Update()
{
	static bool bRecurseCheck = false;
	if (!IsValidWindow() || bRecurseCheck || !m_pLists.GetSize() || m_pLists.Get(0)->UpdatesDisabled())
		return;
	bRecurseCheck = true;
	
	//Update the check boxes
	CheckDlgButton(m_hwnd, IDC_HIDE, m_bHideFiltered ? BST_CHECKED : BST_UNCHECKED);
	CheckDlgButton(m_hwnd, IDC_LINK, m_bLink ? BST_CHECKED : BST_UNCHECKED);
	//Update the filter
	char filter[256];
	GetDlgItemText(m_hwnd, IDC_FILTER, filter, 256);
	if (strcmp(filter, m_filter.Get()->GetFilter()))
		SetDlgItemText(m_hwnd, IDC_FILTER, m_filter.Get()->GetFilter());

	m_filter.Get()->GetFilteredTracks();
	m_filter.Get()->UpdateReaper(m_bHideFiltered);

	m_pLists.Get(0)->Update();

	bRecurseCheck = false;
}
Exemple #4
0
/* DeleteWindow */
static short _DeleteWindow(LPEXP lpArg, ATOMID idfName, WORD wArg)
{
    ATOMID idWindow, idWindowOnly = NULLID;

    if (wArg < 1)
        return KPC_ERROR(IDE_MISSINGARGS, NULLID);

    if (wArg > 2)
        return KPC_ERROR(IDE_TOOMANYARGS, NULLID);

    /* Eval the arg to get the name */
    KappaGetArgAtom(lpArg, 1, idWindow);

    if (!IsValidWindow(idfName, idWindow))
        KappaReturnError;
    else
    {
        OBJECTID idObj = GETOBJECT(idWindow);

        if (!KppCheckObject(idObj, idWindow, idfName, TRUE))
            return NULL;
    }

    /* Eval the arg to get the name */
    if (wArg == 2)
    {
        KappaGetArgAtom(lpArg, 2, idWindowOnly); /* 'IMAGE' */
	if (idWindowOnly != lpIDs->idWidgets)
            return KPC_ERROR(IDE_TOOMANYARGS, NULLID);
    }
		
    if (!KpsDeleteWindow(idWindow, idfName, idWindowOnly, FALSE))
        KappaReturnError;

    KappaReturnAtom(lpIDs->idTrue);
}
Exemple #5
0
static void processServerCommandString(char *string)
{
    char *fullname, filename[MAXPATHLEN], pathname[MAXPATHLEN];
    char *doCommand, *geometry, *langMode, *inPtr;
    int editFlags, stringLen = strlen(string);
    int lineNum, createFlag, readFlag, iconicFlag, lastIconic = 0, tabbed = -1;
    int fileLen, doLen, lmLen, geomLen, charsRead, itemsRead;
    WindowInfo *window, *lastFile = NULL;
    long currentDesktop = QueryCurrentDesktop(TheDisplay, 
       RootWindow(TheDisplay, DefaultScreen(TheDisplay)));

    /* If the command string is empty, put up an empty, Untitled window
       (or just pop one up if it already exists) */
    if (string[0] == '\0') {
    	for (window=WindowList; window!=NULL; window=window->next)
    	    if (!window->filenameSet && !window->fileChanged &&
                isLocatedOnDesktop(window, currentDesktop))
    	    	break;
    	if (window == NULL) {
            EditNewFile(findWindowOnDesktop(tabbed, currentDesktop), NULL, 
                        False, NULL, NULL);
    	    CheckCloseDim();
    	} 
	else {
	    RaiseDocument(window);
            WmClientMsg(TheDisplay, XtWindow(window->shell),
                    "_NET_ACTIVE_WINDOW", 0, 0, 0, 0, 0);
    	    XMapRaised(TheDisplay, XtWindow(window->shell));
    	}
	return;
    }

    /*
    ** Loop over all of the files in the command list
    */
    inPtr = string;
    while (TRUE) {
	
	if (*inPtr == '\0')
	    break;
	    
	/* Read a server command from the input string.  Header contains:
	   linenum createFlag fileLen doLen\n, followed by a filename and -do
	   command both followed by newlines.  This bit of code reads the
	   header, and converts the newlines following the filename and do
	   command to nulls to terminate the filename and doCommand strings */
	itemsRead = sscanf(inPtr, "%d %d %d %d %d %d %d %d %d%n", &lineNum,
		&readFlag, &createFlag, &iconicFlag, &tabbed, &fileLen,
		&doLen, &lmLen, &geomLen, &charsRead);
	if (itemsRead != 9)
    	    goto readError;
	inPtr += charsRead + 1;
	if (inPtr - string + fileLen > stringLen)
	    goto readError;
	fullname = inPtr;
	inPtr += fileLen;
	*inPtr++ = '\0';
	if (inPtr - string + doLen > stringLen)
	    goto readError;
	doCommand = inPtr;
	inPtr += doLen;
	*inPtr++ = '\0';
	if (inPtr - string + lmLen > stringLen)
	    goto readError;
	langMode = inPtr;
	inPtr += lmLen;
	*inPtr++ = '\0';
	if (inPtr - string + geomLen > stringLen)
	    goto readError;
	geometry = inPtr;
	inPtr += geomLen;
	*inPtr++ = '\0';
	
	/* An empty file name means: 
	 *   put up an empty, Untitled window, or use an existing one
	 *   choose a random window for executing the -do macro upon
	 */
	if (fileLen <= 0) {
    	    for (window=WindowList; window!=NULL; window=window->next)
    		if (!window->filenameSet && !window->fileChanged &&
                    isLocatedOnDesktop(window, currentDesktop))
    	    	    break;

    	    if (*doCommand == '\0') {
                if (window == NULL) {
    		    EditNewFile(findWindowOnDesktop(tabbed, currentDesktop), 
                                NULL, iconicFlag, lmLen==0?NULL:langMode, NULL);
    	        } else {
	            if (iconicFlag)
		    	RaiseDocument(window);
		    else
		    	RaiseDocumentWindow(window);
	        }
            } else {
                WindowInfo *win = WindowList;
		/* Starting a new command while another one is still running
		   in the same window is not possible (crashes). */
		while (win != NULL && win->macroCmdData != NULL) {
		    win = win->next;
		}
		
		if (!win) {
		    XBell(TheDisplay, 0);
		} else {
		    /* Raise before -do (macro could close window). */
	            if (iconicFlag)
		    	RaiseDocument(win);
		    else
		    	RaiseDocumentWindow(win);
		    DoMacro(win, doCommand, "-do macro");
		}
	    }
	    CheckCloseDim();
	    return;
	}
	
	/* Process the filename by looking for the files in an
	   existing window, or opening if they don't exist */
	editFlags = (readFlag ? PREF_READ_ONLY : 0) | CREATE |
		(createFlag ? SUPPRESS_CREATE_WARN : 0);
	if (ParseFilename(fullname, filename, pathname) != 0) {
	   fprintf(stderr, "NEdit: invalid file name\n");
           deleteFileClosedProperty2(filename, pathname);
	   break;
	}

    	window = FindWindowWithFile(filename, pathname);
    	if (window == NULL) {
	    /* Files are opened in background to improve opening speed
	       by defering certain time  consuiming task such as syntax
	       highlighting. At the end of the file-opening loop, the 
	       last file opened will be raised to restore those deferred
	       items. The current file may also be raised if there're
	       macros to execute on. */
	    window = EditExistingFile(findWindowOnDesktop(tabbed, currentDesktop),
		    filename, pathname, editFlags, geometry, iconicFlag, 
		    lmLen == 0 ? NULL : langMode, 
		    tabbed == -1? GetPrefOpenInTab() : tabbed, True);

    	    if (window) {
	    	CleanUpTabBarExposeQueue(window);
		if (lastFile && window->shell != lastFile->shell) {
		    CleanUpTabBarExposeQueue(lastFile);
		    RaiseDocument(lastFile);
		}
	    }
	    
	}
	
	/* Do the actions requested (note DoMacro is last, since the do
	   command can do anything, including closing the window!) */
	if (window != NULL) {
            deleteFileOpenProperty(window);
            getFileClosedProperty(window);

	    if (lineNum > 0)
		SelectNumberedLine(window, lineNum);

	    if (*doCommand != '\0') {
		RaiseDocument(window);

                if (!iconicFlag) {
                    WmClientMsg(TheDisplay, XtWindow(window->shell),
                            "_NET_ACTIVE_WINDOW", 0, 0, 0, 0, 0);
		    XMapRaised(TheDisplay, XtWindow(window->shell));
                }

		/* Starting a new command while another one is still running
		   in the same window is not possible (crashes). */
		if (window->macroCmdData != NULL) {
		    XBell(TheDisplay, 0);
		} else {
		    DoMacro(window, doCommand, "-do macro");
		    /* in case window is closed by macro functions
		       such as close() or detach_document() */
		    if (!IsValidWindow(window))
		    	window = NULL;
		    if (lastFile && !IsValidWindow(lastFile))
		    	lastFile = NULL;
		}
	    }
	    
	    /* register the last file opened for later use */
	    if (window) {
	    	lastFile = window;
		lastIconic = iconicFlag;
	    }
	} else {
            deleteFileOpenProperty2(filename, pathname);
            deleteFileClosedProperty2(filename, pathname);
        }
    }
    
    /* Raise the last file opened */
    if (lastFile) {
	CleanUpTabBarExposeQueue(lastFile);
	if (lastIconic)
	    RaiseDocument(lastFile);
	else
	    RaiseDocumentWindow(lastFile);
	CheckCloseDim();
    }
    return;

readError:
    fprintf(stderr, "NEdit: error processing server request\n");
    return;
}