Special-case all lines being selected in validate_adjoinable

GetSortedSelection is kinda slow with large selections and all lines
being selected is an easy thing to special-case.
Fix the legacy clipboard include
Eliminate uses of dynamic_cast on everything but GUI widgets
Debloatify some stuff
Slightly optimize returning strings to lua from ffi functions
Eliminate a pointless set that only ever had zero or one entries