Seven wickets are all that stand between Sri Lanka and a first Test victory after a successful third day against Pakistan in Galle.