Skip to content

Commit

Permalink
Clipboard stuff (#16)
Browse files Browse the repository at this point in the history
* Make online chatbox paste clipboard on ctrl+V

* Add lua function GetClipboard

* Add clipboard pasting(ctrl+v) to songsearch input

* Remove unnecesary windows specific include
  • Loading branch information
nico-abram authored and MinaciousGrace committed Nov 14, 2017
1 parent 505ab41 commit f0c1bc0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
local searchstring = ""
local englishes = {"a", "b", "c", "d", "e","f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",";"}
local englishes = {"?","-",".",",","1","2","3","4","5","6","7","8","9","0","a", "b", "c", "d", "e","f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",";"}
local frameX = 10
local frameY = 180+capWideScale(get43size(120),120)
local active = false
local whee
local lastsearchstring = ""
local CtrlPressed = false

local function searchInput(event)
if event.type ~= "InputEventType_Release" and active == true then
Expand All @@ -25,7 +26,9 @@ local function searchInput(event)
elseif event.DeviceInput.button == "DeviceButton_delete" then
searchstring = ""
elseif event.DeviceInput.button == "DeviceButton_=" then
searchstring = searchstring.."="
searchstring = searchstring.."="
elseif event.DeviceInput.button == "DeviceButton_v" and CtrlPressed then
searchstring = searchstring..HOOKS:GetClipboard()
else
for i=1,#englishes do -- add standard characters to string
if event.DeviceInput.button == "DeviceButton_"..englishes[i] then
Expand All @@ -39,6 +42,13 @@ local function searchInput(event)
lastsearchstring = searchstring
end
end
if event.DeviceInput.button == "DeviceButton_right ctrl" or event.DeviceInput.button == "DeviceButton_left ctrl" then
if event.type == "InputEventType_Release" then
CtrlPressed = false
else
CtrlPressed = true
end
end
end

local t = Def.ActorFrame{
Expand Down
25 changes: 23 additions & 2 deletions src/ScreenNetSelectBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Font.h"
#include "RageDisplay.h"
#include "PlayerState.h"
#include "arch/ArchHooks/ArchHooks.h"

#define CHAT_TEXT_OUTPUT_WIDTH THEME->GetMetricF(m_sName,"ChatTextOutputWidth")
#define CHAT_TEXT_INPUT_WIDTH THEME->GetMetricF(m_sName,"ChatTextInputWidth")
Expand Down Expand Up @@ -91,8 +92,15 @@ bool ScreenNetSelectBase::Input(const InputEventPlus &input)

//If holding control skip chatbox input
//This allows lua input bindings to work on regular keys+control
if(bHoldingCtrl)
if(bHoldingCtrl) {
wchar_t ch = INPUTMAN->DeviceInputToChar(input.DeviceI, false);
MakeUpper(&ch, 1);
if (ch == 'V')
{
PasteClipboard();
}
return ScreenWithMenuElements::Input(input);
}

switch(input.DeviceI.button)
{
Expand Down Expand Up @@ -130,6 +138,7 @@ bool ScreenNetSelectBase::Input(const InputEventPlus &input)
UpdateTextInput();
break;
default:

wchar_t c;
c = INPUTMAN->DeviceInputToChar(input.DeviceI, true);

Expand Down Expand Up @@ -180,7 +189,13 @@ void ScreenNetSelectBase::TweenOffScreen()

void ScreenNetSelectBase::UpdateTextInput()
{
m_textChatInput.SetText( m_sTextInput );
m_textChatInput.SetText(m_sTextInput);
}

void ScreenNetSelectBase::PasteClipboard()
{
m_sTextInput.append(HOOKS->GetClipboard() );
UpdateTextInput();
}

void ScreenNetSelectBase::UpdateUsers()
Expand Down Expand Up @@ -813,6 +828,11 @@ class LunaScreenNetSelectBase : public Luna<ScreenNetSelectBase>
lua_pushnumber(L, p->GetLines());
return 1;
}
static int PasteClipboard(T* p, lua_State *L)
{
p->PasteClipboard();
return 1;
}
public:
LunaScreenNetSelectBase()
{
Expand All @@ -831,6 +851,7 @@ class LunaScreenNetSelectBase : public Luna<ScreenNetSelectBase>
ADD_METHOD(ShowPreviousMsg);
ADD_METHOD(GetChatScroll);
ADD_METHOD(GetChatLines);
ADD_METHOD(PasteClipboard);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/ScreenNetSelectBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ScreenNetSelectBase : public ScreenWithMenuElements
void ShowNextMsg();
unsigned int GetScroll() { return scroll; }
unsigned int GetLines() { return m_textChatOutput.lines; }
void PasteClipboard();
// Lua
void PushSelf(lua_State *L) override;
private:
Expand Down

0 comments on commit f0c1bc0

Please sign in to comment.