Word count on selection

How a word counter might be implemented (show different contents in the “counter area”, depending on what is / is not selected):

Related: Word count for selected text