patch 8.1.2174: screen not recognized as supporting "sgr" mouse codes

Problem:    Screen not recognized as supporting "sgr" mouse codes.
Solution:   Recognize screen 4.7. (Jordan Christiansen, closes #5042)
diff --git a/src/term.c b/src/term.c
index cfbd7fe..fa4375e 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4649,8 +4649,8 @@
 		    if (tp[0] == CSI)
 			switch_to_8bit();
 
-		    // rxvt sends its version number: "20703" is 2.7.3.
 		    // Screen sends 40500.
+		    // rxvt sends its version number: "20703" is 2.7.3.
 		    // Ignore it for when the user has set 'term' to xterm,
 		    // even though it's an rxvt.
 		    if (version > 20000)
@@ -4661,6 +4661,7 @@
 			int need_flush = FALSE;
 			int is_iterm2 = FALSE;
 			int is_mintty = FALSE;
+			int is_screen = FALSE;
 
 			// mintty 2.9.5 sends 77;20905;0c.
 			// (77 is ASCII 'M' for mintty.)
@@ -4706,14 +4707,21 @@
 				is_not_xterm = TRUE;
 			}
 
+			// screen sends 83;40500;0 83 is 'S' in ASCII.
+			if (arg[0] == 83)
+			    is_screen = TRUE;
+
 			// Only set 'ttymouse' automatically if it was not set
 			// by the user already.
 			if (!option_was_set((char_u *)"ttym"))
 			{
 			    // Xterm version 277 supports SGR.  Also support
-			    // Terminal.app, iTerm2 and mintty.
-			    if (version >= 277 || is_iterm2 || is_mac_terminal
-				    || is_mintty)
+			    // Terminal.app, iTerm2, mintty, and screen 4.7+.
+			    if ((!is_screen && version >= 277)
+				    || is_iterm2
+				    || is_mac_terminal
+				    || is_mintty
+				    || (is_screen && arg[1] >= 40700))
 				set_option_value((char_u *)"ttym", 0L,
 							  (char_u *)"sgr", 0);
 			    // if xterm version >= 95 use mouse dragging