mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-11-01 02:58:12 +08:00 
			
		
		
		
	Parse mouse middle
This commit is contained in:
		| @@ -41,6 +41,14 @@ class DrawKey : public Component { | |||||||
|         code += L"mouse_left_move(" +  // |         code += L"mouse_left_move(" +  // | ||||||
|                 std::to_wstring(keys[i].mouse_x()) + L"," + |                 std::to_wstring(keys[i].mouse_x()) + L"," + | ||||||
|                 std::to_wstring(keys[i].mouse_y()) + L")"; |                 std::to_wstring(keys[i].mouse_y()) + L")"; | ||||||
|  |       } else if (keys[i].is_mouse_middle_down()) { | ||||||
|  |         code += L"mouse_middle_down(" +  // | ||||||
|  |                 std::to_wstring(keys[i].mouse_x()) + L"," + | ||||||
|  |                 std::to_wstring(keys[i].mouse_y()) + L")"; | ||||||
|  |       } else if (keys[i].is_mouse_middle_move()) { | ||||||
|  |         code += L"mouse_middle_move(" +  // | ||||||
|  |                 std::to_wstring(keys[i].mouse_x()) + L"," + | ||||||
|  |                 std::to_wstring(keys[i].mouse_y()) + L")"; | ||||||
|       } else if (keys[i].is_mouse_right_down()) { |       } else if (keys[i].is_mouse_right_down()) { | ||||||
|         code += L"mouse_right_down(" +  // |         code += L"mouse_right_down(" +  // | ||||||
|                 std::to_wstring(keys[i].mouse_x()) + L"," + |                 std::to_wstring(keys[i].mouse_x()) + L"," + | ||||||
|   | |||||||
| @@ -32,6 +32,8 @@ struct Event { | |||||||
|   static Event MouseUp(std::string, int x, int y); |   static Event MouseUp(std::string, int x, int y); | ||||||
|   static Event MouseLeftMove(std::string, int x, int y); |   static Event MouseLeftMove(std::string, int x, int y); | ||||||
|   static Event MouseLeftDown(std::string, int x, int y); |   static Event MouseLeftDown(std::string, int x, int y); | ||||||
|  |   static Event MouseMiddleMove(std::string, int x, int y); | ||||||
|  |   static Event MouseMiddleDown(std::string, int x, int y); | ||||||
|   static Event MouseRightMove(std::string, int x, int y); |   static Event MouseRightMove(std::string, int x, int y); | ||||||
|   static Event MouseRightDown(std::string, int x, int y); |   static Event MouseRightDown(std::string, int x, int y); | ||||||
|  |  | ||||||
| @@ -59,6 +61,8 @@ struct Event { | |||||||
|  |  | ||||||
|   bool is_mouse_left_down() const { return type_ == Type::MouseLeftDown; } |   bool is_mouse_left_down() const { return type_ == Type::MouseLeftDown; } | ||||||
|   bool is_mouse_left_move() const { return type_ == Type::MouseLeftMove; } |   bool is_mouse_left_move() const { return type_ == Type::MouseLeftMove; } | ||||||
|  |   bool is_mouse_middle_down() const { return type_ == Type::MouseMiddleDown; } | ||||||
|  |   bool is_mouse_middle_move() const { return type_ == Type::MouseMiddleMove; } | ||||||
|   bool is_mouse_right_down() const { return type_ == Type::MouseRightDown; } |   bool is_mouse_right_down() const { return type_ == Type::MouseRightDown; } | ||||||
|   bool is_mouse_right_move() const { return type_ == Type::MouseRightMove; } |   bool is_mouse_right_move() const { return type_ == Type::MouseRightMove; } | ||||||
|   bool is_mouse_up() const { return type_ == Type::MouseUp; } |   bool is_mouse_up() const { return type_ == Type::MouseUp; } | ||||||
| @@ -79,6 +83,8 @@ struct Event { | |||||||
|     MouseUp, |     MouseUp, | ||||||
|     MouseLeftDown, |     MouseLeftDown, | ||||||
|     MouseLeftMove, |     MouseLeftMove, | ||||||
|  |     MouseMiddleDown, | ||||||
|  |     MouseMiddleMove, | ||||||
|     MouseRightDown, |     MouseRightDown, | ||||||
|     MouseRightMove, |     MouseRightMove, | ||||||
|   }; |   }; | ||||||
|   | |||||||
| @@ -73,6 +73,22 @@ Event Event::MouseRightDown(std::string input, int x, int y) { | |||||||
|   return event; |   return event; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // static | ||||||
|  | Event Event::MouseMiddleMove(std::string input, int x, int y) { | ||||||
|  |   Event event; | ||||||
|  |   event.input_ = std::move(input); | ||||||
|  |   event.type_ = Type::MouseMiddleMove; | ||||||
|  |   event.mouse_ = {x, y}; | ||||||
|  |   return event; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // static | ||||||
|  | Event Event::Special(std::string input) { | ||||||
|  |   Event event; | ||||||
|  |   event.input_ = std::move(input); | ||||||
|  |   return event; | ||||||
|  | } | ||||||
|  |  | ||||||
| // static | // static | ||||||
| Event Event::MouseRightMove(std::string input, int x, int y) { | Event Event::MouseRightMove(std::string input, int x, int y) { | ||||||
|   Event event; |   Event event; | ||||||
| @@ -83,9 +99,11 @@ Event Event::MouseRightMove(std::string input, int x, int y) { | |||||||
| } | } | ||||||
|  |  | ||||||
| // static | // static | ||||||
| Event Event::Special(std::string input) { | Event Event::MouseMiddleDown(std::string input, int x, int y) { | ||||||
|   Event event; |   Event event; | ||||||
|   event.input_ = std::move(input); |   event.input_ = std::move(input); | ||||||
|  |   event.type_ = Type::MouseMiddleDown; | ||||||
|  |   event.mouse_ = {x, y}; | ||||||
|   return event; |   return event; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -66,6 +66,16 @@ void TerminalInputParser::Send(TerminalInputParser::Output output) { | |||||||
|                                   output.mouse.y)); |                                   output.mouse.y)); | ||||||
|       break; |       break; | ||||||
|  |  | ||||||
|  |     case MOUSE_MIDDLE_DOWN: | ||||||
|  |       out_->Send(Event::MouseMiddleDown(std::move(pending_), output.mouse.x, | ||||||
|  |                                       output.mouse.y)); | ||||||
|  |       break; | ||||||
|  |  | ||||||
|  |     case MOUSE_MIDDLE_MOVE: | ||||||
|  |       out_->Send(Event::MouseMiddleMove(std::move(pending_), output.mouse.x, | ||||||
|  |                                   output.mouse.y)); | ||||||
|  |       break; | ||||||
|  |  | ||||||
|     case MOUSE_RIGHT_DOWN: |     case MOUSE_RIGHT_DOWN: | ||||||
|       out_->Send(Event::MouseRightDown(std::move(pending_), output.mouse.x, |       out_->Send(Event::MouseRightDown(std::move(pending_), output.mouse.x, | ||||||
|                                       output.mouse.y)); |                                       output.mouse.y)); | ||||||
| @@ -211,6 +221,11 @@ TerminalInputParser::Output TerminalInputParser::ParseMouse( | |||||||
|     case 64: |     case 64: | ||||||
|       return Output(MOUSE_LEFT_MOVE, arguments[1], arguments[2]); |       return Output(MOUSE_LEFT_MOVE, arguments[1], arguments[2]); | ||||||
|  |  | ||||||
|  |     case 33: | ||||||
|  |       return Output(MOUSE_MIDDLE_DOWN, arguments[1], arguments[2]); | ||||||
|  |     case 65: | ||||||
|  |       return Output(MOUSE_MIDDLE_MOVE, arguments[1], arguments[2]); | ||||||
|  |  | ||||||
|     case 34: |     case 34: | ||||||
|       return Output(MOUSE_RIGHT_DOWN, arguments[1], arguments[2]); |       return Output(MOUSE_RIGHT_DOWN, arguments[1], arguments[2]); | ||||||
|     case 66: |     case 66: | ||||||
|   | |||||||
| @@ -28,6 +28,8 @@ class TerminalInputParser { | |||||||
|     MOUSE_MOVE, |     MOUSE_MOVE, | ||||||
|     MOUSE_LEFT_DOWN, |     MOUSE_LEFT_DOWN, | ||||||
|     MOUSE_LEFT_MOVE, |     MOUSE_LEFT_MOVE, | ||||||
|  |     MOUSE_MIDDLE_DOWN, | ||||||
|  |     MOUSE_MIDDLE_MOVE, | ||||||
|     MOUSE_RIGHT_DOWN, |     MOUSE_RIGHT_DOWN, | ||||||
|     MOUSE_RIGHT_MOVE, |     MOUSE_RIGHT_MOVE, | ||||||
|   }; |   }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ArthurSonzogni
					ArthurSonzogni