[RDY] Refactoring of two-iteration anti-pattern in msg_show_console_dialog()

The 2 iterations here should have been separate functions from the beginning, as the 2 iterations of the loop are completely different.

The changes have been done in 3 separate commits so as to make the changes easy to follow.
Commit1: Simply split the two iterations into separate code one after the other
Commit2: Make 2 new functions for each
Commit3: Make style changes to the new functions to conform to the required coding style.