示例#1
0
/*
 * Display all files in the current screen (all viewports), and then show the
 * remaining stuff on the screen (position in each viewport and workspace
 * marker).
 */
void
showFILES(RING * gbl, int reset_cols)
{
    unsigned current = curview;
    int j;
    unsigned k;

    TRACE(("showFILES(%s,%d)\n", gbl->new_wd, reset_cols));
    if (reset_cols)
	for (j = 0; j < CCOL_MAX; j++)
	    gbl->cmdcol[j] = 0;

    save_view(gbl);
    for (k = 0; k < maxview; k++) {
	show_view(vue->gbl);
	if (maxview > 1) {
	    if (vue->gbl != viewlist[current].gbl)
		show_what(vue);
	    next_view();
	}
    }
    showMARK(gbl->Xbase);
    clear_work();
    showC(gbl);
    TRACE(("...done showFILES\n"));
}
示例#2
0
/*
 * Move cursor to the "other" view.
 */
RING *
tab2VIEW(RING * gbl)
{
    save_view(gbl);
    if (maxview > 1) {
	next_view();
	if (ring_view())
	    showC(vue->gbl);
	showMARK(vue->gbl->Xbase);
    } else
	dedmsg(gbl, "no other viewport");
    return vue->gbl;
}
示例#3
0
/*
 * Close the current viewport, advance to the next one, if available, and show
 * the new screen contents.
 */
static RING *
quit_view(RING * gbl)
{
    unsigned j;

    TRACE(("quit_view %d of %d\n", curview, maxview));
    if (maxview > 1) {
	maxview--;
	for (j = curview; j < maxview; j++)
	    viewlist[j] = viewlist[j + 1];
	viewlist[0].base_row = 0;
	curview--;
	next_view();		/* load current-viewport */
	if (ring_view())
	    showFILES(vue->gbl, FALSE);
    } else
	dedmsg(gbl, "no more viewports to quit");
    return vue->gbl;
}
示例#4
0
LRESULT editwin_info::edit_proc(UINT message, WPARAM wparam, LPARAM lparam)
{
	TCHAR buffer[MAX_EDIT_STRING];

	// handle a few messages
	switch (message)
	{
	// key down: handle navigation in the attached view
	case WM_SYSKEYDOWN:
		if (wparam != VK_F10)
			return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
		// (fall through)
	case WM_KEYDOWN:
		switch (wparam)
		{
		case VK_UP:
			if (m_last_history < (m_history_count - 1))
				m_last_history++;
			else
				m_last_history = 0;
			SendMessage(m_editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)&m_history[m_last_history][0]);
			SendMessage(m_editwnd, EM_SETSEL, (WPARAM)MAX_EDIT_STRING, (LPARAM)MAX_EDIT_STRING);
			break;

		case VK_DOWN:
			if (m_last_history > 0)
				m_last_history--;
			else if (m_history_count > 0)
				m_last_history = m_history_count - 1;
			else
				m_last_history = 0;
			SendMessage(m_editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)&m_history[m_last_history][0]);
			SendMessage(m_editwnd, EM_SETSEL, (WPARAM)MAX_EDIT_STRING, (LPARAM)MAX_EDIT_STRING);
			break;

		case VK_PRIOR:
			if (m_views[0] != nullptr)
				m_views[0]->send_pageup();
			break;

		case VK_NEXT:
			if (m_views[0] != nullptr)
				m_views[0]->send_pagedown();
			break;

		case VK_TAB:
			if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
				prev_view(nullptr);
			else
				next_view(nullptr);
			set_ignore_char_lparam(lparam);
			break;

		default:
			if (handle_key(wparam, lparam))
				set_ignore_char_lparam(lparam);
			else
				return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
			break;
		}
		break;

	// char: handle the return key
	case WM_CHAR:

		// ignore chars associated with keys we've handled
		if (check_ignore_char_lparam(lparam))
		{
			if (waiting_for_debugger() || !seq_pressed())
			{
				switch (wparam)
				{
				case 13:
					{
						// fetch the text
						SendMessage(m_editwnd, WM_GETTEXT, (WPARAM)ARRAY_LENGTH(buffer), (LPARAM)buffer);

						// add to the history if it's not a repeat of the last one
						if (buffer[0] != 0 && _tcscmp(buffer, &m_history[0][0]))
						{
							memmove(&m_history[1][0], &m_history[0][0], (HISTORY_LENGTH - 1) * MAX_EDIT_STRING * sizeof(TCHAR));
							_tcscpy(&m_history[0][0], buffer);
							if (m_history_count < HISTORY_LENGTH)
								m_history_count++;
						}
						m_last_history = m_history_count - 1;

						// process
						{
							auto utf8_buffer = osd::text::from_tstring(buffer);
							process_string(utf8_buffer.c_str());
						}
						break;
					}

				case 27:
					{
						// fetch the text
						SendMessage(m_editwnd, WM_GETTEXT, (WPARAM)sizeof(buffer), (LPARAM)buffer);

						// if it's not empty, clear the text
						if (_tcslen(buffer) > 0)
						{
							set_ignore_char_lparam(lparam);
							set_editwnd_text(m_edit_defstr.c_str());
							editwnd_select_all();
						}
						break;
					}

				default:
					return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
				}
			}
		}
		break;

	// everything else: defaults
	default:
		return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
	}

	return 0;
}
示例#5
0
LRESULT editwin_info::edit_proc(UINT message, WPARAM wparam, LPARAM lparam)
{
	// handle a few messages
	switch (message)
	{
	// key down: handle navigation in the attached view
	case WM_SYSKEYDOWN:
		if (wparam != VK_F10)
			return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
		// (fall through)
	case WM_KEYDOWN:
		switch (wparam)
		{
		case VK_UP:
			if (!m_history.empty())
			{
				m_last_history++;
				if (m_last_history >= m_history.size())
					m_last_history = 0;
				auto const &entry(m_history[m_last_history]);
				SendMessage(m_editwnd, WM_SETTEXT, WPARAM(0), LPARAM(entry.c_str()));
				SendMessage(m_editwnd, EM_SETSEL, WPARAM(entry.length()), LPARAM(entry.length()));
			}
			break;

		case VK_DOWN:
			if (!m_history.empty())
			{
				if (m_last_history > 0)
					m_last_history--;
				else
					m_last_history = m_history.size() - 1;
				auto const &entry(m_history[m_last_history]);
				SendMessage(m_editwnd, WM_SETTEXT, WPARAM(0), LPARAM(entry.c_str()));
				SendMessage(m_editwnd, EM_SETSEL, WPARAM(entry.length()), LPARAM(entry.length()));
			}
			break;

		case VK_PRIOR:
			if (m_views[0] != nullptr)
				m_views[0]->send_pageup();
			break;

		case VK_NEXT:
			if (m_views[0] != nullptr)
				m_views[0]->send_pagedown();
			break;

		case VK_TAB:
			if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
				prev_view(nullptr);
			else
				next_view(nullptr);
			set_ignore_char_lparam(lparam);
			break;

		default:
			if (handle_key(wparam, lparam))
				set_ignore_char_lparam(lparam);
			else
				return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
			break;
		}
		break;

	// char: handle the return key
	case WM_CHAR:

		// ignore chars associated with keys we've handled
		if (check_ignore_char_lparam(lparam))
		{
			if (waiting_for_debugger() || !seq_pressed())
			{
				TCHAR buffer[MAX_EDIT_STRING];

				switch (wparam)
				{
				case 13: // carriage return
					{
						// fetch the text
						SendMessage(m_editwnd, WM_GETTEXT, WPARAM(ARRAY_LENGTH(buffer)), LPARAM(buffer));

						// add to the history if it's not a repeat of the last one
						if (buffer[0] && (m_history.empty() || _tcscmp(buffer, m_history[0].c_str())))
						{
							while (m_history.size() >= HISTORY_LENGTH)
								m_history.pop_back();
							m_history.emplace_front(buffer);
						}
						m_last_history = m_history.size() - 1;

						// process
						{
							auto utf8_buffer = osd::text::from_tstring(buffer);
							process_string(utf8_buffer.c_str());
						}
					}
					break;

				case 27: // escape
					{
						// fetch the text
						SendMessage(m_editwnd, WM_GETTEXT, WPARAM(sizeof(buffer)), LPARAM(buffer));

						// if it's not empty, clear the text
						if (_tcslen(buffer) > 0)
						{
							set_ignore_char_lparam(lparam);
							set_editwnd_text(m_edit_defstr.c_str());
							editwnd_select_all();
						}
					}
					break;

				default:
					return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
				}
			}
		}
		break;

	// everything else: defaults
	default:
		return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
	}

	return 0;
}
示例#6
0
void ViewWorkspace::on_input_message(clan::GUIMessage_Input msg)
{
	clan::Canvas canvas = get_canvas();
	clan::InputEvent input_event = msg.input_event;
	if (input_event.type == clan::InputEvent::pressed && input_event.id == clan::mouse_left)
	{
		clan::Point mouse_pos = input_event.mouse_pos;
		for (std::vector<ViewPage>::size_type page_index = 0; page_index < pages.size(); page_index++)
		{
			if (pages[page_index].position.contains(mouse_pos))
			{
				clan::SpanLayout::HitTestResult result = pages[page_index].span.hit_test(canvas, mouse_pos);
				if (page_index == current_page_index && result.type == clan::SpanLayout::HitTestResult::inside && result.object_id == 0)
				{
					if (!cb_view_close.is_null())
						cb_view_close.invoke(pages[page_index].view);
				}
				else
				{
					show_view(page_index);
				}
				break;
			}
		}
		msg.consumed = true;
	}
	else if (input_event.type == clan::InputEvent::released && input_event.id == clan::mouse_left)
	{
		msg.consumed = true;
	}
	else if (input_event.type == clan::InputEvent::pointer_moved)
	{
		bool new_hot_state = false;
		clan::Point mouse_pos = input_event.mouse_pos;
		bool no_match = true;
		for (std::vector<ViewPage>::size_type page_index = 0; page_index < pages.size(); page_index++)
		{
			if (pages[page_index].position.contains(mouse_pos))
			{
				no_match = false;
				clan::SpanLayout::HitTestResult result = pages[page_index].span.hit_test(canvas, mouse_pos);
				if (page_index == current_page_index && result.type == clan::SpanLayout::HitTestResult::inside && result.object_id == 0)
				{
					new_hot_state = true;
				}
			}
		}

		if (new_hot_state != hot)
		{
			hot = new_hot_state;
			request_repaint();
		}
		msg.consumed = true;
	}
	else if (input_event.type == clan::InputEvent::pressed && input_event.ctrl)
	{
		switch (input_event.id)
		{
		case clan::keycode_tab:
			if (input_event.shift)
				previous_view();
			else
				next_view();
			msg.consumed = true;
			break;
		}
	}
}